Skip to content

Fix missing detection of dead code in expressions #4090

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

Open
wants to merge 16 commits into
base: 2.1.x
Choose a base branch
from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 11, 2025

@staabm
Copy link
Contributor Author

staabm commented Jul 11, 2025

hmm I wonder whether I should add this $isAlwaysTerminating = $isAlwaysTerminating || $result->isAlwaysTerminating(); handling everywhere, where we have

			$hasYield = $hasYield || $result->hasYield();
			$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
			$impurePoints = array_merge($impurePoints, $result->getImpurePoints());

etc...?

edit: I added it in all places where I could think of a example which I was able to test

@staabm
Copy link
Contributor Author

staabm commented Jul 12, 2025

I think the new behaviour makes sense but the errors are unfortunate

https://github.com/laravel/framework/blob/43993ed92af54aa8620d8e779a7dcd658f44364c/types/Support/Helpers.php#L44-L60

------ ------------------------------------------------------- 
  Line   Support/Helpers.php                                    
 ------ ------------------------------------------------------- 
  47     Unreachable statement - code above always terminates.  
         🪪  deadCode.unreachable                               
  66     Unreachable statement - code above always terminates.  
         🪪  deadCode.unreachable                               
 ------ ------------------------------------------------------- 

@staabm staabm marked this pull request as ready for review July 12, 2025 06:26
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

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.

never return not detected never return type should lead to error when used
2 participants