[Console] Fix OutputInterface options int-mask for PHPStan#48384
[Console] Fix OutputInterface options int-mask for PHPStan#48384chalasr merged 1 commit intosymfony:6.2from
OutputInterface options int-mask for PHPStan#48384Conversation
5d6da40 to
e3c655e
Compare
e3c655e to
aa063bd
Compare
| * @param self::VERBOSITY_*|self::OUTPUT_* $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), | ||
| * 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL | ||
| * @param bool $newline Whether to add a newline | ||
| * @param int-mask-of<self::VERBOSITY_*,self::OUTPUT_*> $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), |
There was a problem hiding this comment.
Psalm doesn't work correctly when combining globs together here. Let's go for either int-mask-of<self::*> or int.
There was a problem hiding this comment.
As I'm not a PhpStorm user myself, does this also create issues when using this method in PhpStorm? (e.g. issues with completion or adding false-positive inspection errors)
There was a problem hiding this comment.
Not to my knowledge nor experience actually ; the int typehint is still in use for the quick documentation, autocomplete or inspections, but I don't know if it can cause quirks with some plugins.
There was a problem hiding this comment.
the EAP version of PHPStorm has full support for parsing constant wildcards (the stable release supports the case with a name prefix but not the full wildcard on the class IIRC). But indeed, it will fallback to int in such case.
aa063bd to
304a17a
Compare
OutputInterface options int-mask for PHPStan
|
Thank you @ogizanagi. |

When upgrading an application to 6.2, I encountered this issue with PHPStan:
The
MultiplexingOutputimplements theOutputInterfaceand defined0as the default value for$options:as defined by the interface:
symfony/src/Symfony/Component/Console/Output/OutputInterface.php
Line 40 in 69f46f2
When trying to use
self::OUTPUT_NORMAL | self::VERBOSITY_NORMALas default value:Or simply using
Output::write()with specific options:Using PHPStan's
int-mask-ofis the solution for this, and allows by nature the0value.It was even used at some point, but reverted to use
self::VERBOSITY_*|self::OUTPUT_*. However, it does not behave as expected for masks.So, either we use
int-mask-of, or we revert toint?