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
[Php80] Add MixedTypeRector #2701
Conversation
d9deb24
to
e2b8275
Compare
01b6586
to
875095f
Compare
All checks have passed 🎉 @TomasVotruba it is ready for review. For summary:
For Return Type, I think that require different PR as that will need various handling, eg: actually return |
it seems when parent method has |
@TomasVotruba so, I think the use case like this should be skipped: class VendorParam
{
/**
* @param int $param
*/
public function run($param)
{}
}
class UseParam extends VendorParam
{
public function run($param)
{}
} Next, when parent method There are other use case like typed already that should be skipped as well: class A
{
public function run(int $a)
{}
}
class B extends A
{
public function run($a)
{}
} as same type in child should be preferred, so there should be different rule or phpstan that handle that |
implemented with add |
Agreed. I think only the doc-typed public function run($value)
{
}
-/**
- * @param mixed $value
- */
-public function run($value)
+public function run(mixed $value)
{
} |
The issue with only check interface SomeInterface
{
/** @param mixed $data */
public function save($data);
}
class Memory extends SomeInterface
{
public function save($data) {}
} That will only change interface, and that will cause error something like: ------------------------------------------------------------------------
packages/Caching/ValueObject/Storage/MemoryCacheStorage.php:37
------------------------------------------------------------------------
- '#Method Rector\\Caching\\ValueObject\\Storage\\MemoryCacheStorage\:\:save\(\) has parameter \$data with no type specified#' see https://github.com/rectorphp/rector-src/runs/7473011787?check_suite_focus=true#step:5:16 , that's why I created |
Ok, let's only make typed with use doc @param mixed |
I think these cases should be skipped, as imlicit mixed doc can be overriden by explicit type in of childs: Then it could crash: |
@TomasVotruba It seems we need to ensure it only apply change when:
that will also ensure no manual add |
That makes sense 👍 |
for ClassMethod, I think the mixed type can be applied for final class. |
or not, as final class can have parent |
implemented check has child or parent method 🎉 |
All checks have passed 🎉 @TomasVotruba I think it is ready. |
rebased. |
Thanks 👍 |
Fixes rectorphp/rector#7301