Skip to content

Commit

Permalink
Use PHPUnitPHAR as prefix instead of PHPUnit as we may want to prefix…
Browse files Browse the repository at this point in the history
… some symbols where their name begins with PHPUnit\ in the future
  • Loading branch information
sebastianbergmann committed Apr 4, 2024
1 parent 01b6e09 commit 4d829e0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ jobs:
run: ant phar-snapshot

- name: Check whether PHAR is scoped
run: grep -q PHPUnit\\\\DeepCopy\\\\Exception\\\\CloneException build/artifacts/phpunit-snapshot.phar || (echo "phpunit-snapshot.phar is not scoped." && false)
run: grep -q PHPUnitPHAR\\\\DeepCopy\\\\Exception\\\\CloneException build/artifacts/phpunit-snapshot.phar || (echo "phpunit-snapshot.phar is not scoped." && false)

- name: Upload PHAR
uses: actions/upload-artifact@v4
Expand Down
6 changes: 3 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@
<arg path="${basedir}/build/tmp/phar" />
</exec>

<replace file="${basedir}/build/tmp/phar-scoped/phpunit/Util/PHP/Template/PhptTestCase.tpl" token="SebastianBergmann\CodeCoverage\CodeCoverage" value="PHPUnit\SebastianBergmann\CodeCoverage\CodeCoverage"/>
<replace file="${basedir}/build/tmp/phar-scoped/phpunit/Util/PHP/Template/TestCaseClass.tpl" token="SebastianBergmann\CodeCoverage\CodeCoverage" value="PHPUnit\SebastianBergmann\CodeCoverage\CodeCoverage"/>
<replace file="${basedir}/build/tmp/phar-scoped/phpunit/Util/PHP/Template/TestCaseMethod.tpl" token="SebastianBergmann\CodeCoverage\CodeCoverage" value="PHPUnit\SebastianBergmann\CodeCoverage\CodeCoverage"/>
<replace file="${basedir}/build/tmp/phar-scoped/phpunit/Util/PHP/Template/PhptTestCase.tpl" token="SebastianBergmann\CodeCoverage\CodeCoverage" value="PHPUnitPHAR\SebastianBergmann\CodeCoverage\CodeCoverage"/>
<replace file="${basedir}/build/tmp/phar-scoped/phpunit/Util/PHP/Template/TestCaseClass.tpl" token="SebastianBergmann\CodeCoverage\CodeCoverage" value="PHPUnitPHAR\SebastianBergmann\CodeCoverage\CodeCoverage"/>
<replace file="${basedir}/build/tmp/phar-scoped/phpunit/Util/PHP/Template/TestCaseMethod.tpl" token="SebastianBergmann\CodeCoverage\CodeCoverage" value="PHPUnitPHAR\SebastianBergmann\CodeCoverage\CodeCoverage"/>

<copy file="${basedir}/.phpstorm.meta.php" tofile="${basedir}/build/tmp/phar-scoped/.phpstorm.meta.php"/>

Expand Down
2 changes: 1 addition & 1 deletion build/config/php-scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

return [
'prefix' => 'PHPUnit',
'prefix' => 'PHPUnitPHAR',

'exclude-namespaces' => [
'PHPUnit',
Expand Down

3 comments on commit 4d829e0

@staabm
Copy link
Contributor

@staabm staabm commented on 4d829e0 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, since we now have a unique prefix for prefixed classes vs. public api PHPStan can detect mistakenly used class-references to classes within the phpunit phar with phpstan/phpstan-src#3002

@sebastianbergmann
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@staabm Can you explain why PHPStan cares about the prefix for PHP-Scoper that is used in the build process for PHPUnit's PHAR?

@staabm
Copy link
Contributor

@staabm staabm commented on 4d829e0 Apr 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to detect e.g. accidental/wrong use statements which sometimes are added via IDE Autocomplete

initial feature request was phpstan/phpstan#10587 (comment)

Please sign in to comment.