php-scoper
php-scoper copied to clipboard
PHP 8.0 "attribute" use statement incorrectly prefixed or breaks prefixing entirely
Bug report
Question | Answer |
---|---|
PHP-Scoper version | 0.15.0 |
PHP version | all |
Platform with version | all |
Prefixing of PHP 8.0+ attributes is not behaving consistently.
When using a single line attribute, which is imported using a use
statement, the class in the use statement is being prefixed.
However, when using the fully qualified classname in the inline attribute call ~or using a multiline attribute notation~ the build files are created with expected prefixes (the incorrect prefix is not being added).
Correction on the assumption that multiline attributes were giving the desired results. Whenever an attribute is defined over multiple lines, the "source" file is being placed in the build directory without any errors or warnings, but also without any prefixes.
I've added a "neutral" use SomethingElse;
to the source files to validate that prefixing happens, though this statement is not being prefixed in the multiline-*.php
files in the build results.
Steps to reproduce:
- Clone the main branch of the php-scoper-attributes-prefixed-poc repository
- Run
composer install
- Run
php ./vendor/humbug/php-scoper/bin/php-scoper add-prefix
- Inspect the files in the
build
directory and seeuse TestPrefix\ReturnTypeWillChange;
instead of theuse ReturnTypeWillChange;
statement in theinline-with-use.php
file