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

[DeadCode] Remove null as never used param type in RemoveUselessParamTagRector, RemveUselessReturnTagRector #5348

Merged
merged 3 commits into from
Dec 10, 2023

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Dec 10, 2023

No description provided.

@TomasVotruba TomasVotruba changed the title tv remove null [DeadCode] Remove null as never used param type in RemoveUselessParamTagRector Dec 10, 2023
@TomasVotruba TomasVotruba enabled auto-merge (squash) December 10, 2023 12:45
@TomasVotruba TomasVotruba changed the title [DeadCode] Remove null as never used param type in RemoveUselessParamTagRector [DeadCode] Remove null as never used param type in RemoveUselessParamTagRector, RemveUselessReturnTagRector Dec 10, 2023
@TomasVotruba TomasVotruba merged commit e400e37 into main Dec 10, 2023
40 of 41 checks passed
@TomasVotruba TomasVotruba deleted the tv-remove-null branch December 10, 2023 12:50

class RemoveNull
{
function foo()
Copy link
Member

Choose a reason for hiding this comment

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

It seems cause no return tag specified phpstan notice, see https://phpstan.org/r/3c7579fb-dd25-4b55-94a3-637f15380990

Using @return null handle it, see https://phpstan.org/r/55a5277d-553c-4f7e-a9d7-840c9fd206f7

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly, that's false positive that makes error hidden.

Copy link
Member

Choose a reason for hiding this comment

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

I will create separate PR, it currenlty remove @return null with description as it invalid check


final class RemoveNull
{
public $name = null;
Copy link
Member

Choose a reason for hiding this comment

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

This also make phpstan notice no type specified.

I think instead of remove null docblock, there should be a rule to resolve the type, then it can be properly removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. That's responsibility of another rules.


class RemoveNull
{
public function foo($a = null)
Copy link
Member

Choose a reason for hiding this comment

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

same here, it cause no param type specified phpstan notice, on big project, it cause a lot of notice

@samsonasik
Copy link
Member

I think removing null is only make sense when it has return and param native type, I will create separate PR.

On @var, it always valid if no native type already.

@TomasVotruba
Copy link
Member Author

The type declaration doesn't play role. PHPStan complaining is expective behavior, as previously the error was ignored as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants