Skip to content

Commit 99926d6

Browse files
authored
Merge pull request #456 from phpDocumentor/fix/invalid-fqsen-define
Fix: issue with invalid defines
2 parents 316073f + f66a2df commit 99926d6

File tree

6 files changed

+88
-90
lines changed

6 files changed

+88
-90
lines changed

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"phpdocumentor/reflection-common": "^2.1",
2525
"phpdocumentor/reflection-docblock": "^5",
2626
"phpdocumentor/type-resolver": "^1.2",
27+
"symfony/polyfill-php80": "^1.28",
2728
"webmozart/assert": "^1.7"
2829
},
2930
"require-dev": {

composer.lock

+84-84
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rector.php

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
// register a single rule
1616
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
1717
$rectorConfig->rule(Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class);
18-
$rectorConfig->rule(Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
19-
$rectorConfig->rule(Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector::class);
2018
$rectorConfig->importNames();
2119

2220
// define sets of rules

src/phpDocumentor/Reflection/Php/Factory/Define.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
use function assert;
3333
use function sprintf;
34-
use function strpos;
3534

3635
/**
3736
* Strategy to convert `define` expressions to ConstantElement
@@ -145,7 +144,7 @@ private function fqsenFromExpression(Expr $nameString, ContextStack $context): ?
145144

146145
private function fqsenFromString(string $nameString): Fqsen
147146
{
148-
if (strpos($nameString, '\\') === false) {
147+
if (str_starts_with($nameString, '\\') === false) {
149148
return new Fqsen(sprintf('\\%s', $nameString));
150149
}
151150

tests/integration/ProjectCreationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function testWithGlobalConstants() : void
206206
$this->assertArrayHasKey('\\Luigi\\OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants());
207207
$this->assertArrayHasKey('\\Luigi\\MAX_OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants());
208208
$this->assertArrayHasKey('\\OUTSIDE_OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants());
209-
$this->assertArrayHasKey('\\Luigi_OUTSIDE_OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants());
209+
$this->assertArrayHasKey('\\LuigiFoo\\_OUTSIDE_OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants());
210210
}
211211

212212
public function testInterfaceExtends() : void

tests/integration/data/Luigi/constants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const OVEN_TEMPERATURE = 9001;
66
define('\\Luigi\\MAX_OVEN_TEMPERATURE', 9002);
77
define('OUTSIDE_OVEN_TEMPERATURE', 9002);
8-
define(__NAMESPACE__ . '_OUTSIDE_OVEN_TEMPERATURE', 9002);
8+
define(__NAMESPACE__ . 'Foo\\_OUTSIDE_OVEN_TEMPERATURE', 9002);
99
$v = 1;
1010
define($v . '_OUTSIDE_OVEN_TEMPERATURE', 9002);
1111

0 commit comments

Comments
 (0)