Skip to content

Conversation

@canvural
Copy link
Contributor

Adds support for FILTER_THROW_ON_FAILURE for filter_var. There are still stuff I need to figure out:

  • How to better test the throw type extension?
  • Should we add the @throws tag to function in phpstorm-stubs repo? Or anywhere in PHPStan. Couldn't figure out how to conditionally add it only for PHP 8.5 in phpstorm-stubs repo.
  • Combining FILTER_THROW_ON_FAILURE and FILTER_NULL_ON_FAILURE is not allowed. Should we have a new rule for that?

If anyone can help me with those questions, that'd be helpful!

@canvural canvural marked this pull request as ready for review October 30, 2025 08:52
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes
Copy link
Member

How to better test the throw type extension?

If the current test fails when the src/ changes are reverted then I'm fine with it 😊 Another approach would be to add a test to the "catch unthrown exception" rule.

Should we add the @throws tag to function in phpstorm-stubs repo? Or anywhere in PHPStan. Couldn't figure out how to conditionally add it only for PHP 8.5 in phpstorm-stubs repo.

Thanks to the throw type extension, PHPStan doesn't need the PHPDoc. It might be a good idea to add it to phpstorm-stubs if you care about PhpStorm users separately 😊

Combining FILTER_THROW_ON_FAILURE and FILTER_NULL_ON_FAILURE is not allowed. Should we have a new rule for that?

You can in a new PR if you'd want.

Thank you!

@ondrejmirtes ondrejmirtes merged commit 193d801 into phpstan:2.1.x Oct 30, 2025
540 of 554 checks passed
@canvural canvural deleted the filter-var-php85 branch October 30, 2025 10:19
@VincentLanglet
Copy link
Contributor

I updated #4418 with this new flag.

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.

4 participants