Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that trait is analysed #226

Closed
wants to merge 1 commit into from

Conversation

ondrejmirtes
Copy link
Contributor

No description provided.

@ondrejmirtes
Copy link
Contributor Author

This is a response to: phpstan/phpstan#10268

To me it seemed you were everything correctly, so I checked it out. PHPStan needs to find the classes you're using in tests, which usually isn't a problem because they're simply in analysed paths, but the reflection in tests needs some extra help discovering them. I usually do that by adding tests directory into classmap in autoload-dev.

Now the output is:

vendor/bin/phpunit tests/Usages/AttributeUsagesTest.php --filter testTraits
PHPUnit 10.5.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.12
Configuration: /Users/ondrej/Development/spaze-phpstan-disallowed-calls/phpunit.xml

string(21) "PHPStan\Node\FileNode"
string(28) "PhpParser\Node\Stmt\Declare_"
string(34) "PhpParser\Node\Stmt\DeclareDeclare"
string(29) "PhpParser\Node\Scalar\LNumber"
string(30) "PhpParser\Node\Stmt\Namespace_"
string(26) "PhpParser\Node\Stmt\Trait_"
string(26) "PhpParser\Node\Stmt\Class_"
string(24) "PHPStan\Node\InClassNode"
string(28) "PhpParser\Node\Stmt\TraitUse"
string(24) "PHPStan\Node\InTraitNode"
string(30) "PhpParser\Node\Stmt\ClassConst"
string(24) "PhpParser\Node\Attribute"
string(29) "PhpParser\Node\AttributeGroup"
string(21) "PhpParser\Node\Const_"
string(30) "PhpParser\Node\Expr\ConstFetch"
string(28) "PhpParser\Node\Stmt\Property"
string(24) "PhpParser\Node\Attribute"
string(29) "PhpParser\Node\AttributeGroup"
string(36) "PhpParser\Node\Stmt\PropertyProperty"
string(30) "PHPStan\Node\ClassPropertyNode"
string(31) "PhpParser\Node\Stmt\ClassMethod"
string(24) "PhpParser\Node\Attribute"
string(29) "PhpParser\Node\AttributeGroup"
string(24) "PhpParser\Node\Attribute"
string(29) "PhpParser\Node\AttributeGroup"
string(20) "PhpParser\Node\Param"
string(25) "PhpParser\Node\Identifier"
string(25) "PhpParser\Node\Identifier"
string(30) "PHPStan\Node\InClassMethodNode"
string(29) "PHPStan\Node\ExecutionEndNode"
string(39) "PHPStan\Node\MethodReturnStatementsNode"
string(32) "PHPStan\Node\ClassPropertiesNode"
string(29) "PHPStan\Node\ClassMethodsNode"
string(31) "PHPStan\Node\ClassConstantsNode"

@spaze
Copy link
Owner

spaze commented Dec 9, 2023

Oh shoot, wow, I was thiiis close :-) Thanks a lot!

I feel very bad now, because I actually load the files that are required for tests here

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/libs/AttributeClass.php';
require __DIR__ . '/libs/AttributeEntity.php';
require __DIR__ . '/libs/Bar.php';

and even have a test that checks that all files from the lib dir are loaded in bootstrap.php
$this->assertEmpty($notRequired, 'Require these files in bootstrap.php: ' . implode(', ', $notRequired));

but it's been proved useless now 😅 The classmap seems better.

Thanks again 🍻

@spaze spaze self-assigned this Dec 9, 2023
spaze added a commit that referenced this pull request Dec 9, 2023
I couldn't tell where to put this file and that file and it makes no sense to have two locations to always decide one.

Includes @ondrejmirtes' solution for phpstan/phpstan#10268 cherry-picked from #226, thanks!
@spaze
Copy link
Owner

spaze commented Dec 9, 2023

I've added the composer.json change to #227 and the rest is in #225.

@spaze spaze closed this Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants