diff --git a/composer.json b/composer.json index 770c5fde..95cfe38c 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "phpdocumentor/reflection-common": "^2.1", "phpdocumentor/reflection-docblock": "^5", "phpdocumentor/type-resolver": "^1.2", + "symfony/polyfill-php80": "^1.28", "webmozart/assert": "^1.7" }, "require-dev": { diff --git a/composer.lock b/composer.lock index f876cc50..9bbfcfb5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5ff3144554baf45d61d5b685dc587f73", + "content-hash": "4adf8ccefab99393b246acaf903ad069", "packages": [ { "name": "doctrine/deprecations", @@ -324,6 +324,89 @@ }, "time": "2023-09-26T12:28:12+00:00" }, + { + "name": "symfony/polyfill-php80", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-26T09:26:14+00:00" + }, { "name": "webmozart/assert", "version": "1.11.0", @@ -1611,16 +1694,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.37", + "version": "1.10.38", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "058ba07e92f744d4dcf6061ae75283d0c6456f2e" + "reference": "5302bb402c57f00fb3c2c015bac86e0827e4b691" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/058ba07e92f744d4dcf6061ae75283d0c6456f2e", - "reference": "058ba07e92f744d4dcf6061ae75283d0c6456f2e", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5302bb402c57f00fb3c2c015bac86e0827e4b691", + "reference": "5302bb402c57f00fb3c2c015bac86e0827e4b691", "shasum": "" }, "require": { @@ -1669,7 +1752,7 @@ "type": "tidelift" } ], - "time": "2023-10-02T16:18:37+00:00" + "time": "2023-10-06T14:19:14+00:00" }, { "name": "phpstan/phpstan-php-parser", @@ -2296,21 +2379,21 @@ }, { "name": "rector/rector", - "version": "0.18.4", + "version": "0.18.5", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "d99a91176b7eb7f2b6d509a6486b3661c6dfd370" + "reference": "2a3b82f317e431fc142d21f3303891a4e64c96eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/d99a91176b7eb7f2b6d509a6486b3661c6dfd370", - "reference": "d99a91176b7eb7f2b6d509a6486b3661c6dfd370", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/2a3b82f317e431fc142d21f3303891a4e64c96eb", + "reference": "2a3b82f317e431fc142d21f3303891a4e64c96eb", "shasum": "" }, "require": { "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.10.31" + "phpstan/phpstan": "^1.10.35" }, "conflict": { "rector/rector-doctrine": "*", @@ -2340,7 +2423,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.18.4" + "source": "https://github.com/rectorphp/rector/tree/0.18.5" }, "funding": [ { @@ -2348,7 +2431,7 @@ "type": "github" } ], - "time": "2023-09-25T17:07:54+00:00" + "time": "2023-10-05T11:25:40+00:00" }, { "name": "sebastian/cli-parser", @@ -4017,89 +4100,6 @@ ], "time": "2023-01-26T09:26:14+00:00" }, - { - "name": "symfony/polyfill-php80", - "version": "v1.28.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-01-26T09:26:14+00:00" - }, { "name": "symfony/service-contracts", "version": "v2.5.2", diff --git a/rector.php b/rector.php index b285d6cf..095be69f 100644 --- a/rector.php +++ b/rector.php @@ -15,8 +15,6 @@ // register a single rule $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); $rectorConfig->rule(Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class); - $rectorConfig->rule(Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class); - $rectorConfig->rule(Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector::class); $rectorConfig->importNames(); // define sets of rules diff --git a/src/phpDocumentor/Reflection/Php/Factory/Define.php b/src/phpDocumentor/Reflection/Php/Factory/Define.php index dca55fbd..29e3dedc 100644 --- a/src/phpDocumentor/Reflection/Php/Factory/Define.php +++ b/src/phpDocumentor/Reflection/Php/Factory/Define.php @@ -31,7 +31,6 @@ use function assert; use function sprintf; -use function strpos; /** * Strategy to convert `define` expressions to ConstantElement @@ -145,7 +144,7 @@ private function fqsenFromExpression(Expr $nameString, ContextStack $context): ? private function fqsenFromString(string $nameString): Fqsen { - if (strpos($nameString, '\\') === false) { + if (str_starts_with($nameString, '\\') === false) { return new Fqsen(sprintf('\\%s', $nameString)); } diff --git a/tests/integration/ProjectCreationTest.php b/tests/integration/ProjectCreationTest.php index d97656fb..fe545d35 100644 --- a/tests/integration/ProjectCreationTest.php +++ b/tests/integration/ProjectCreationTest.php @@ -206,7 +206,7 @@ public function testWithGlobalConstants() : void $this->assertArrayHasKey('\\Luigi\\OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants()); $this->assertArrayHasKey('\\Luigi\\MAX_OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants()); $this->assertArrayHasKey('\\OUTSIDE_OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants()); - $this->assertArrayHasKey('\\Luigi_OUTSIDE_OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants()); + $this->assertArrayHasKey('\\LuigiFoo\\_OUTSIDE_OVEN_TEMPERATURE', $project->getFiles()[$fileName]->getConstants()); } public function testInterfaceExtends() : void diff --git a/tests/integration/data/Luigi/constants.php b/tests/integration/data/Luigi/constants.php index 5d7574b9..820fa1bf 100644 --- a/tests/integration/data/Luigi/constants.php +++ b/tests/integration/data/Luigi/constants.php @@ -5,7 +5,7 @@ const OVEN_TEMPERATURE = 9001; define('\\Luigi\\MAX_OVEN_TEMPERATURE', 9002); define('OUTSIDE_OVEN_TEMPERATURE', 9002); -define(__NAMESPACE__ . '_OUTSIDE_OVEN_TEMPERATURE', 9002); +define(__NAMESPACE__ . 'Foo\\_OUTSIDE_OVEN_TEMPERATURE', 9002); $v = 1; define($v . '_OUTSIDE_OVEN_TEMPERATURE', 9002);