Rector: phpdoc duplication with PropertyTypeDeclarationRector

Created on 17 Jun 2020  路  5Comments  路  Source: rectorphp/rector

Bug Report

Rector seems to duplicate phpdoc in front of a similar one with PropertyTypeDeclarationRector

Minimal PHP Code Causing Issue

https://getrector.org/demo/f15d5eca-ead5-4385-a2cf-f9743f547280

Expected Behaviour

Nothing changing in the given example

bug

All 5 comments

Updated Demo link in PHP config: https://getrector.org/demo/cb8a0637-0f3f-49ff-a486-6937c6c79aa2#result

The problem is SAFE_TYPES. With false value it works

If it's only related to safe_types, I think we can close this.

I don't think you have the necessary tools to handle this on rector alone.

There are two other issues that I ended up closing for this reason:
https://github.com/rectorphp/rector/issues/3544
https://github.com/rectorphp/rector/issues/3545

If I understand the safe_types implementation on rector, you strip the current file of documentation before analysing the code so it contains only native types. However, the moment when you have to fetch a type outside of the current file, the types are fetched in the cache which is populated with phpdoc types...

IMO, it's not a bug worth fixing if the implementation of safe_types is not achievable anyway

Thanks for adresing this. With current implementation, I feel this causes more harm than brings value.
As we depend on PHPStan in ~90 % cases of type resolving, this cannot be resolved for /vendor, thus causing random bugs/useless.

I think it might be better to simply remove safe_types feature, as it doesn't bring any value at the moment. What do you think?

I think so too. A partial implementation for a safety feature supposed to be absolute is the same as no implementation at all.

Let's see how phpstan evolve, it may become relevant once again in the future

All-rigth, thank you for your feedback and patience with this. I'm going to revert it now to prevent any more confusion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pavarnos picture pavarnos  路  4Comments

carusogabriel picture carusogabriel  路  5Comments

dehrk picture dehrk  路  4Comments

benr77 picture benr77  路  4Comments

jakzal picture jakzal  路  4Comments