Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] FixOutputInterface 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
chalasr merged 1 commit intosymfony:6.2fromogizanagi:output-phpstan
Nov 30, 2022

Conversation

ogizanagi
Copy link
Contributor

@ogizanagiogizanagi commentedNov 29, 2022
edited
Loading

QA
Branch?6.2
Bug fix?yes
New feature?no
Deprecations?no
TicketsN/A
LicenseMIT
Doc PRN/A

When upgrading an application to 6.2, I encountered this issue with PHPStan:

 ------ -------------------------------------------------------------------------------------------------------  Line   Pilot/Runner/Output/MultiplexingOutput.php ------ -------------------------------------------------------------------------------------------------------  79     Default value of the parameter#3 $options (0) of method         App\Pilot\Runner\Output\MultiplexingOutput::write() is incompatible withtype 1|2|4|16|32|64|128|256. ------ -------------------------------------------------------------------------------------------------------

TheMultiplexingOutput implements theOutputInterface and defined0 as the default value for$options:

publicfunction write(string|iterable$messages,bool$newline =false,int$options =0):void

as defined by the interface:

publicfunctionwrite(string|iterable$messages,bool$newline =false,int$options =0);

When trying to useself::OUTPUT_NORMAL | self::VERBOSITY_NORMAL as default value:

 ------ -------------------------------------------------------------------------------------------------------  Line   Pilot/Runner/Output/MultiplexingOutput.php ------ -------------------------------------------------------------------------------------------------------  79     Default value of the parameter#3 $options (33) of method         App\Pilot\Runner\Output\MultiplexingOutput::write() is incompatible withtype 1|2|4|16|32|64|128|256. ------ -------------------------------------------------------------------------------------------------------

Or simply usingOutput::write() with specific options:

 ------ -------------------------------------------------------------------------------------------------------  Line   Pilot/Runner/Output/MultiplexingOutput.php ------ -------------------------------------------------------------------------------------------------------  81     Parameter#3 $options of method Symfony\Component\Console\Output\Output::write() expects         1|2|4|16|32|64|128|256, 33 given. ------ -------------------------------------------------------------------------------------------------------

Using PHPStan'sint-mask-of is the solution for this, and allows by nature the0 value.
It was even usedat some point, but reverted to useself::VERBOSITY_*|self::OUTPUT_*. However, it does not behave as expected for masks.

So, either we useint-mask-of, or we revert toint?

* @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),
Copy link
Member

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 eitherint-mask-of<self::*> orint.

ogizanagi reacted with confused emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

While it works for both Psalm/PhpStan, it seems to break the docblock parsing of PhpStorm:

SCR-20221129-ojk

Let's simply revert these changes to <6.2.

Copy link
Member

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)

Copy link
ContributorAuthor

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 ; theint 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.

Copy link
Member

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 toint in such case.

@OskarStarkOskarStark changed the title[Console] Fix OutputInterface options int-mask for PHPStan[Console] FixOutputInterface options int-mask for PHPStanNov 30, 2022
@chalasr
Copy link
Member

Thank you@ogizanagi.

@chalasrchalasr merged commit258fb73 intosymfony:6.2Nov 30, 2022
@ogizanagiogizanagi deleted the output-phpstan branchNovember 30, 2022 12:53
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@stofstofstof left review comments

@wouterjwouterjwouterj approved these changes

@ro0NLro0NLro0NL left review comments

@chalasrchalasrchalasr approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
6.2
Development

Successfully merging this pull request may close these issues.

6 participants
@ogizanagi@chalasr@stof@wouterj@ro0NL@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp