Skip to content

Conversation

spaze
Copy link
Owner

@spaze spaze commented Feb 22, 2025

The API is used instead of code added in #296 and is available starting with PHPStan 2.1.3 so I'll need to decide when to merge this and when or how to remove support for earlier versions.

@spaze spaze self-assigned this Feb 22, 2025
@spaze spaze force-pushed the spaze/new-api-get-attributes branch from 1006365 to 62c1df9 Compare February 24, 2025 23:46
@spaze spaze force-pushed the spaze/new-api-get-attributes branch from 62c1df9 to 891410b Compare March 4, 2025 02:17
@spaze spaze force-pushed the spaze/new-api-get-attributes branch 3 times, most recently from 9524b18 to 4ece18a Compare April 11, 2025 00:25
@spaze spaze force-pushed the spaze/new-api-get-attributes branch 3 times, most recently from 8e2df34 to f59ba27 Compare May 15, 2025 21:34
@spaze spaze requested a review from Copilot July 13, 2025 00:40
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates attribute handling to PHPStan’s native getAttributes() API (available in PHPStan 2.1.3+), removes legacy BetterReflection usage, and upgrades related dependencies.

  • Switch Reflector and BetterReflection adapters to PHPStan’s ReflectionProvider and AttributeReflection
  • Replace PhpParser\Node\UseUse with PhpParser\Node\UseItem for php-parser 5.0+
  • Update tests and bump phpstan/phpstan to ^2.1.3 and nikic/php-parser to ^5.0

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Usages/NamespaceUsagesAllowInClassWithAttributesTest.php Pass Node\Name instead of string to setCurrentFunctionName()
src/Usages/NamespaceUsages.php Replace UseUse with UseItem
src/Identifier/Identifier.php Swap BetterReflection Reflector for PHPStan ReflectionProvider
src/HelperRules/SetCurrentFunctionNameHelperRule.php Change setter to accept PhpParser\Node\Name
src/Allowed/GetAttributesWhenInSignature.php Use ReflectionProvider and update return types
src/Allowed/Allowed.php Remove BetterReflection, use ReflectionProvider and AttributeReflection
composer.json Require phpstan/phpstan:^2.1.3 and nikic/php-parser:^5.0
Comments suppressed due to low confidence (1)

src/Allowed/Allowed.php:253

  • Here too, getFunction expects a string but node->namespacedName is a Name object. Use ->toString() (e.g., getFunction($node->namespacedName->toString(), $scope)) to avoid type mismatch.
	}

@spaze spaze force-pushed the spaze/new-api-get-attributes branch from c56a63a to 3f2e4cf Compare August 25, 2025 21:27
spaze added 2 commits August 25, 2025 23:47
The API is available starting with PHPStan 2.1.3 https://github.com/phpstan/phpstan/releases/tag/2.1.3 so I'll need to decide when to merge this and when or how to remove support for earlier versions.

Also require nikic/php-parser 5.0+ because first PHPStan 2.x requires and uses it and second, Function_::namespacedName is not available in earlier versions.
@spaze spaze force-pushed the spaze/new-api-get-attributes branch from 3f2e4cf to 12d8b4b Compare August 25, 2025 21:47
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.

1 participant