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

[PHPStanStaticTypeMapper] Allow Closure type on ClosureTypeMapper based on PHP versions #4785

Merged
merged 10 commits into from
Aug 14, 2023

Conversation

samsonasik
Copy link
Member

No description provided.

Comment on lines -1 to -23
<?php

namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\Fixture;

final class SkipPropertyAssign
{
private $command;

public function __construct(\Closure $command)
{
$this->command = $command;
}

public function getCommand()
{
if (!$this->command instanceof \Closure) {
return $this->command;
}

$this->command = ($this->command)();

return $this->command;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasVotruba I removed this test fixture, because for whatever type assigned in __construct(), if it replaced in different method, it will always be new type, which I think very rare use case, eg on symfony:

https://github.com/symfony/symfony/blob/c82d8c99090346aaf938346a5342625e6eafc02e/src/Symfony/Component/Console/Command/LazyCommand.php#L194

The ClassPropertyAssignToConstructorPromotionRector don't cover that, as other type when re-assign with other type in other method will have different type as well.

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@TomasVotruba
Copy link
Member

Thanks, let's merge this 👍

@TomasVotruba TomasVotruba merged commit b0105f2 into main Aug 14, 2023
@TomasVotruba TomasVotruba deleted the enable-return-closure branch August 14, 2023 06:36
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.

3 participants