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

Add testsand implementation for property types changing from docblock-only to native type #340

Merged
merged 3 commits into from
Nov 27, 2021

Conversation

tomasnorre
Copy link
Contributor

As see yesterday, native property types aren't supported currently.
https://twitter.com/tomasnorre/status/1464301968264994816

I have now added tests that proves this. I'm still trying to get my head around how to implement the change, I'm not really strong at AST, even though I have written some Rector rules.

Any pointers on how to approach this would be helpful, thanks.

@tomasnorre
Copy link
Contributor Author

I'm not sure about the implementation, but would love some feedback on it.

@Ocramius Ocramius added this to the 6.0.0 milestone Nov 27, 2021
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@tomasnorre tomasnorre marked this pull request as ready for review November 27, 2021 21:52
@Ocramius Ocramius self-assigned this Nov 27, 2021
@Ocramius Ocramius changed the title Add tests for native property type Add testsand implementation for property types changing from docblock-only to native type Nov 27, 2021
@Ocramius Ocramius merged commit e747565 into Roave:6.0.x Nov 27, 2021
@Ocramius
Copy link
Member

Thanks @tomasnorre!

@tomasnorre tomasnorre deleted the feature/support-native-property-type branch November 28, 2021 07:49
@tomasnorre
Copy link
Contributor Author

I don't know if this is a new PR, but I saw this, this morning, after using the 6.0.x-dev version in my CI.

AOE\Crawler\Controller\CrawlerController#$queueRepository changed from \AOE\Crawler\Domain\Repository\QueueRepository to AOE\Crawler\Domain\Repository\QueueRepository

The diff is the leading slash. Is stripping the leading slash before compare a valid fix?
As I'm using use statements and have short names, there will not be leading slashes in the native types.

The rest of the cases I had is fixes with the current version of 6.0.x

@Ocramius
Copy link
Member

Ocramius commented Nov 28, 2021

Would always start from a test case, then figure it out from there.

@tomasnorre
Copy link
Contributor Author

I'll create a new PR with a Test that fails. Probably not today, though.

Ocramius added a commit that referenced this pull request Dec 5, 2021
…Reflection@1f7a13b

This also handles the upcoming BC break of Roave/BetterReflection#900

Some big changes:

 * `PropertyDocumentedTypeChanged` no longer exists: we use only `PropertyTypeChanged` for now. This
   is a step backwards, but it is needed to prevent issues around docblocks being too advanced for
   this library to parse them, for now.
    * see CuyZ/Valinor#6
    * see https://github.com/phpstan/phpstan-src/tree/447cd102d946a2d9883ac82793195275f54296a9/src/Type
    * see https://github.com/vimeo/psalm/tree/f1d47cc662500589e200a978e3af85488a5236cf/src/Psalm/Type
    * see https://github.com/phpDocumentor/ReflectionDocBlock/blob/622548b623e81ca6d78b721c5e029f4ce664f170/src/DocBlock/Tags/Param.php#L35
    * see https://github.com/phpstan/phpdoc-parser/blob/d639142cf83e91a07b4862217a6f8aa65ee10d08/tests/PHPStan/Parser/TypeParserTest.php#L64
    * /cc @tomasnorre this sadly effectively reverts #340 - it
      is too much effort to dive into further advanced types :-(
 * `PropertyTypeChanged` only expects the property to be both covariant and contravariant: if not,
   then a BC break was introduced (this re-uses some internal variance checks, simplifying code
   substantially)
 * usage of `ReflectionFunctionAbstract` is no longer present in the library: always using an union
   of `ReflectionMethod|ReflectionFunction` instead (as in `roave/better-reflection:^5`)
 * `FunctionName` is now `@internal`, since it's only used for internal rendering purposes
@Ocramius
Copy link
Member

Ocramius commented Dec 5, 2021

Important, before you consider adding more work to this: f8c25b3

I had to butcher your previous work to move forward :-(

uzibhalepu added a commit to uzibhalepu/BackwardCompatibilityCheck that referenced this pull request Aug 6, 2024
…Reflection@1f7a13b

This also handles the upcoming BC break of Roave/BetterReflection#900

Some big changes:

 * `PropertyDocumentedTypeChanged` no longer exists: we use only `PropertyTypeChanged` for now. This
   is a step backwards, but it is needed to prevent issues around docblocks being too advanced for
   this library to parse them, for now.
    * see CuyZ/Valinor#6
    * see https://github.com/phpstan/phpstan-src/tree/447cd102d946a2d9883ac82793195275f54296a9/src/Type
    * see https://github.com/vimeo/psalm/tree/f1d47cc662500589e200a978e3af85488a5236cf/src/Psalm/Type
    * see https://github.com/phpDocumentor/ReflectionDocBlock/blob/622548b623e81ca6d78b721c5e029f4ce664f170/src/DocBlock/Tags/Param.php#L35
    * see https://github.com/phpstan/phpdoc-parser/blob/d639142cf83e91a07b4862217a6f8aa65ee10d08/tests/PHPStan/Parser/TypeParserTest.php#L64
    * /cc @tomasnorre this sadly effectively reverts Roave/BackwardCompatibilityCheck#340 - it
      is too much effort to dive into further advanced types :-(
 * `PropertyTypeChanged` only expects the property to be both covariant and contravariant: if not,
   then a BC break was introduced (this re-uses some internal variance checks, simplifying code
   substantially)
 * usage of `ReflectionFunctionAbstract` is no longer present in the library: always using an union
   of `ReflectionMethod|ReflectionFunction` instead (as in `roave/better-reflection:^5`)
 * `FunctionName` is now `@internal`, since it's only used for internal rendering purposes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants