Skip to content

Commit c918898

Browse files
committed
Merge remote-tracking branch 'origin/0.10.x-merge-up-into-0.11.x_6013efa0677ab2.34585191' into 0.11.x
# Conflicts: # CHANGELOG.md
2 parents e3750f0 + 45ee6db commit c918898

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ All notable changes to this project will be documented in this file, in reverse
2424

2525
- Nothing.
2626

27+
## 0.10.3 - 2021-01-29
28+
29+
30+
-----
31+
32+
### Release Notes for [0.10.3](https://github.com/open-code-modeling/php-code-ast/milestone/23)
33+
34+
0.10.x bugfix release (patch)
35+
36+
### 0.10.3
37+
38+
- Total issues resolved: **1**
39+
- Total pull requests resolved: **0**
40+
- Total contributors: **1**
41+
42+
#### bug
43+
44+
- [63: Fix invalid class namespace](https://github.com/open-code-modeling/php-code-ast/issues/63) thanks to @sandrokeil
45+
2746
## 0.10.2 - 2021-01-20
2847

2948

src/Package/Psr4Info.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ public function getFullyQualifiedClassNameFromFilename(string $filename): string
8686
public function getClassNamespace(string $fcqn): string
8787
{
8888
$namespace = $this->normalizeNamespace($fcqn);
89-
$namespace = \substr($namespace, 0, \strrpos($namespace, '/'));
9089

91-
return $this->normalizeNamespace($this->getPackagePrefix() . '\\' . $namespace);
90+
return \substr($namespace, 0, \strrpos($namespace, '\\'));
9291
}
9392

9493
public function getClassName(string $fqcn): string

tests/Package/Psr4InfoTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public function providerForGetPathAndNameFromFilename(): array
329329
* @dataProvider providerForGetFullyQualifiedClassNameFromFilename
330330
* @covers \OpenCodeModeling\CodeAst\Package\Psr4Info::getFullyQualifiedClassNameFromFilename
331331
*/
332-
public function it_returns_fqcn_from_filename($expected, $sourceFolder, $packagePrefix, $filename): void
332+
public function it_returns_fqcn_from_filename($expectedFqcn, $expectedClassNamespace, $expectedClassName, $sourceFolder, $packagePrefix, $filename): void
333333
{
334334
$psr4Info = new Psr4Info(
335335
$sourceFolder,
@@ -338,7 +338,11 @@ public function it_returns_fqcn_from_filename($expected, $sourceFolder, $package
338338
$this->filterNamespaceToDirectory()
339339
);
340340

341-
self::assertSame($expected, $psr4Info->getFullyQualifiedClassNameFromFilename($filename));
341+
$fqcn = $psr4Info->getFullyQualifiedClassNameFromFilename($filename);
342+
343+
self::assertSame($expectedFqcn, $fqcn);
344+
self::assertSame($expectedClassNamespace, $psr4Info->getClassNamespace($fqcn));
345+
self::assertSame($expectedClassName, $psr4Info->getClassName($fqcn));
342346
}
343347

344348
/**
@@ -351,12 +355,16 @@ public function providerForGetFullyQualifiedClassNameFromFilename(): array
351355
return [
352356
[
353357
'MyVendor\MyPackage\ModelPath\UserPath\User',
358+
'MyVendor\MyPackage\ModelPath\UserPath',
359+
'User',
354360
'src',
355361
'\MyVendor\MyPackage\\',
356362
'src/ModelPath/UserPath/User.php',
357363
],
358364
[
359365
'MyVendor\MyPackage\ModelPath\UserPath\User',
366+
'MyVendor\MyPackage\ModelPath\UserPath',
367+
'User',
360368
'src',
361369
'\MyVendor\MyPackage\\',
362370
'src/ModelPath/UserPath/User',

0 commit comments

Comments
 (0)