-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Fix OutputInterface
options int-mask for PHPStan
#48384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
MultiplexingOutput
implements theOutputInterface
and defined0
as 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_NORMAL
as default value:Or simply using
Output::write()
with specific options:Using PHPStan's
int-mask-of
is the solution for this, and allows by nature the0
value.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
?