Skip to content

Cast SymfonyOutput::isDecorated() to bool - #7048

Open
Gabrieljr42 wants to merge 4 commits into
phpstan:2.3.xfrom
Gabrieljr42:fix/isdecorated-turbo-15696
Open

Gabrieljr42 wants to merge 4 commits into
phpstan:2.3.xfrom
Gabrieljr42:fix/isdecorated-turbo-15696

Conversation

@Gabrieljr42

Copy link
Copy Markdown
Contributor

Closes phpstan/phpstan#15696

Symfony 5.4 declares Output::isDecorated() with no native return type. StreamOutput::hasColorSupport() returns the int from preg_match. SymfonyOutput::isDecorated() lives in a file with strict_types and a bool return, so that int throws TypeError.

Inside the phpstan phar, Turbo's trustTypesUnder drops argument and return checks for the whole archive, including vendor/. The int then reaches a user formatter that still requires bool. A cast in this wrapper is user code, and that pass does not remove it.

isVerbose, isVeryVerbose, and isDebug already return bool from Symfony. This change does not touch them, and it does not touch turbo-ext/.

Tests

tests/PHPStan/Command/Symfony/SymfonyOutputTest.php feeds the wrapper 1, 0, true, and false through a NullOutput subclass whose isDecorated(): mixed returns the raw value. The double does not call parent::__construct(), because NullOutput defines no constructor of its own.

Before the cast, PHPUnit 11.5.57 on PHP 8.3.33 reported TypeError for 1 and for 0 (Return value must be of type bool, int returned at SymfonyOutput.php:59). The two bool cases passed (2 assertions).

After the cast, the same class was OK: 4 tests, 4 assertions. parallel-lint reported no syntax error on the two files.

The phar repro from the issue was not run here. The turbo extension is not loaded, and PHPUnit does not enter trustOwnTypesIfSuitable. make tests, make phpstan, and make cs were not run.

@staabm

staabm commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Thank you for the PR.

I did not merge yet because I am thinking about whether there is a more general fix we can/should take..

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.

isDecorated() returns 1 instead of true with Turbo

2 participants