Skip to content

Fix PHP 8.6 deprecation in hoa/consistency - #6405

Merged
ondrejmirtes merged 1 commit into
phpstan:2.2.xfrom
SanderMuller:hoa-86-define
Sep 9, 2026
Merged

Fix PHP 8.6 deprecation in hoa/consistency#6405
ondrejmirtes merged 1 commit into
phpstan:2.2.xfrom
SanderMuller:hoa-86-define

Conversation

@SanderMuller

Copy link
Copy Markdown
Contributor

Running PHPStan on PHP 8.6 prints 24 deprecations before it does anything:

Deprecated: define(): Argument #3 ($case_insensitive) is ignored and treated as false since
declaration of case-insensitive constants is no longer supported, passing the argument
explicitly is unnecessary in vendor/hoa/consistency/Prelude.php on line 52

All 24 come from that one line. Prelude.php is in composer's autoload.files, so it runs on every
vendor/autoload.php include, and hoa/consistency arrives through hoa/compiler in require.

$define = function ($constantName, $constantValue, $case = false) {
    if (!defined($constantName)) {
        return define($constantName, $constantValue, $case);
    }

Dropping the third argument changes nothing. All 27 $define() call sites pass two arguments, so $case
is always false. I parsed them with a brace-aware scan rather than a grep, because one call spans three
lines.

Measured on 8.6.0beta2, through a real composer install so the patch goes through
cweagans/composer-patches:

deprecations on autoload
8.6 before 24
8.6 after 0
8.5, either way 0

Same three-file shape as d36a97f and 44deb6b, the two 8.5 deprecation fixes. The constants come out
identical afterwards: SUCCEED, FAILED, WITH_COMPOSER, DS and PS all keep their values.

This is one piece of PHP 8.6 support, and it stands on its own. It is the Hoa problem you expected in
point 3.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ondrejmirtes
ondrejmirtes merged commit a6144e2 into phpstan:2.2.x Sep 9, 2026
482 of 488 checks passed
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you!

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.

2 participants