Navigation Menu

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

Implement @phpstan-allow-private-mutation #1610

Merged
merged 1 commit into from Sep 27, 2022
Merged

Implement @phpstan-allow-private-mutation #1610

merged 1 commit into from Sep 27, 2022

Conversation

zonuexe
Copy link
Contributor

@zonuexe zonuexe commented Aug 11, 2022

resolve phpstan/phpstan#7778, refs #1609

@zonuexe zonuexe changed the title Feature/psalm readonly allow private mutation Implement @phpstan-allow-private-mutation Aug 11, 2022
@zonuexe
Copy link
Contributor Author

zonuexe commented Aug 11, 2022

ReadOnlyByPhpDocPropertyAssignRuleTest alone will pass with e2d9db8 patch, but you probably need to rethink how ResolvedPhpDocBlock::$phpDocNode is initialized.

// skip $result->phpDocNodeResolver
if (isset($this->phpDocNodeResolver)) {
$result->phpDocNodeResolver = $this->phpDocNodeResolver;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error: Property PHPStan\PhpDoc\ResolvedPhpDocBlock::$phpDocNode (PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode) in isset() is not nullable.
Error: Property PHPStan\PhpDoc\ResolvedPhpDocBlock::$phpDocNodeResolver (PHPStan\PhpDoc\PhpDocNodeResolver) in isset() is not nullable.
 ------ ------------------------------------------------------------------ 
  Line   src/PhpDoc/ResolvedPhpDocBlock.php                                
 ------ ------------------------------------------------------------------ 
  225    Property PHPStan\PhpDoc\ResolvedPhpDocBlock::$phpDocNode          
         (PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode) in isset() is not    
         nullable.                                                         
  [24](https://github.com/phpstan/phpstan-src/actions/runs/3044344145/jobs/4904629542#step:11:25)3    Property PHPStan\PhpDoc\ResolvedPhpDocBlock::$phpDocNodeResolver  
         (PHPStan\PhpDoc\PhpDocNodeResolver) in isset() is not nullable.   
 ------ ------------------------------------------------------------------

https://github.com/phpstan/phpstan-src/actions/runs/3044344145/jobs/4904629542#step:11:9

@zonuexe
Copy link
Contributor Author

zonuexe commented Sep 13, 2022

@ondrejmirtes Could you please review this PR?

@@ -192,7 +198,9 @@ public function merge(array $parents, array $parentPhpDocBlocks): self
// skip $result->nameScope
$result->templateTypeMap = $this->templateTypeMap;
$result->templateTags = $this->templateTags;
// skip $result->phpDocNodeResolver
if (isset($this->phpDocNodeResolver)) {
$result->phpDocNodeResolver = $this->phpDocNodeResolver;
Copy link
Member

Choose a reason for hiding this comment

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

Hi, you¨re adding a simple boolean value which there are already many present. These changes to phpDocNode and phpDocNodeResolver are not required to make this work, and cause these build failures.

If the PR doesn't work without these changes, please observe how different boolean values are handled here, it shouldn't be hard to make them work.

@zonuexe
Copy link
Contributor Author

zonuexe commented Sep 25, 2022

Sorry, I accidentally submitted a re-review. Ignore it for once.

@ondrejmirtes
Copy link
Member

I've updated the PR with the correct fix.

@ondrejmirtes ondrejmirtes merged commit ea87e95 into phpstan:1.8.x Sep 27, 2022
@ondrejmirtes
Copy link
Member

Thank you.

@zonuexe zonuexe deleted the feature/psalm-readonly-allow-private-mutation branch January 12, 2023 11:10
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