Skip to content

Allow valid built-in constants in function parameters - #6579

Open
midhunmonachan wants to merge 1 commit into
phpstan:2.3.xfrom
midhunmonachan:fix-invalid-constant-builtins
Open

midhunmonachan wants to merge 1 commit into
phpstan:2.3.xfrom
midhunmonachan:fix-invalid-constant-builtins

Conversation

@midhunmonachan

@midhunmonachan midhunmonachan commented Sep 24, 2026 •

Copy link
Copy Markdown

The fallback check for built-in constants used the parameter type alone. This made valid numeric constants such as PHP_INT_SIZE fail when passed to str_pad() because the function also has a flag parameter of type int.

The check now reports a constant only when it is listed for one of the function parameters that accepts constants. The regression test keeps the error for a misplaced STR_PAD_LEFT flag.

Closes phpstan/phpstan#15308

Checks:

  • Full test suite: 22,321 tests, 98,042 assertions, 76 skipped
  • bin/phpstan -v
  • PHPStan coding standard
  • Parallel lint on changed files

The current 2.3.x base also has pre-existing CI failures: the Turbo Extension Version Check after commit 17972fe, and PHPStan on Windows with PHP 8.1 reaching its configured 599M memory limit in shipmonk/dead-code-detector. This PR does not touch turbo-ext or that analysis path.

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.

False positive argument.invalidConstant: any built-in constant rejected for str_pad() $length

1 participant