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

Improve ExtractorInterface phpdoc#40604

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
Nyholm merged 1 commit intosymfony:5.xfromVincentLanglet:extractorPhpDoc
Apr 1, 2021

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLangletVincentLanglet commentedMar 28, 2021
edited
Loading

QA
Branch?5.x
Bug fix?no
New feature?no
Deprecations?no
TicketsFix #...
LicenseMIT
Doc PRsymfony/symfony-docs#...

I think this phpdoc can be improved

@carsonbotcarsonbot added this to the4.4 milestoneMar 28, 2021
@Nyholm
Copy link
Member

Thank you for these PRs.

We are happy to improve minor things like this, but only if they are broken. What I can see, there is no bug this PR is fixing.

@VincentLanglet
Copy link
ContributorAuthor

We are happy to improve minor things like this, but only if they are broken. What I can see, there is no bug this PR is fixing.

Hi@Nyholm . I'm not sure to understand, do you want that I do this PR on another branch or does these PR are not welcomed ?

User of static analysis like phpstan/psalm can encounter an issue.
For instance, SonataAdmin is implementing the interface and has the following method:
https://github.com/sonata-project/SonataAdminBundle/blob/b737b64feea99be925af9b970bc42dca26d7587f/src/Translator/Extractor/AdminExtractor.php#L79-L84

If this kind of situation, psalm is returning an error

MoreSpecificImplementedParamType - src/Translator/Extractor/AdminExtractor.php:84:29 - Argument 1 of Sonata\AdminBundle\Translator\Extractor\AdminExtractor::extract has the more specific type 'array<array-key, string>|string', expecting 'array<array-key, mixed>|string' as defined by Symfony\Component\Translation\Extractor\ExtractorInterface::extract

For this reason, some stubs are created to override/be more precise about the phpdoc of symfony (seehttps://github.com/psalm/psalm-plugin-symfony/tree/master/src/Stubs).

Instead of creating a new stub in the psalm plugin symfony, I thought the phpdoc improvement would be accepted by symfony.

@Nyholm
Copy link
Member

Im saying that we are happy to fix bugs. This is not a bug. This is a change to please a third party tool.
(If you do think it is a bug, please provide a unit test that shows the issue being fixed.)

Note that we do run psalm on all PRs to make sure we don't introduce more of these issues. We are also fixing issues found by psalm (see#40603).

But again, it has to be real issues that affects the code. Changing fromarray tostring[] would just make psalm happy.

OskarStark reacted with thumbs up emoji

@Nyholm
Copy link
Member

I looked at the psalm errors for 4.4 and I did find a few that actually matters.#40610

OskarStark reacted with thumbs up emoji

@VincentLanglet
Copy link
ContributorAuthor

Im saying that we are happy to fix bugs. This is not a bug. This is a change to please a third party tool.
(If you do think it is a bug, please provide a unit test that shows the issue being fixed.)

Note that we do run psalm on all PRs to make sure we don't introduce more of these issues. We are also fixing issues found by psalm (see#40603).

But again, it has to be real issues that affects the code. Changing fromarray tostring[] would just make psalm happy.

Sure, it's not abug. But still an improvement. I still don't get why you're talking like these PR would be forbidden.
I already did some, which was welcomed#39170
And I found multiple others PR which was just changing the PhpDoc.

For the method,

    /**     * Extracts translation messages from files, a file or a directory to the catalogue.     */    public function extract($resource, MessageCatalogue $catalogue);

You could believe that an array ofSplFileObject could be handled.

So changing the param typehint fromarray tostring[] can be considered as a documentation improvement.
It's not just about making psalm happy, it also helps the developer to correctly use this method when reading the phpdoc.

Copy link
Member

@derrabusderrabus left a comment

Choose a reason for hiding this comment

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

The change is correct and it improves the documentation of the interface. It would be in favor of merging this PR.

@Nyholm
Copy link
Member

#39170 added missing documentation. This is changing a valid type to a slightly better valid type.

I undertand that this may seam arbitrary. But I stand to the fact that this PR is not helping anybody. I don't want to allow this kind of PRs because that opens the door for more PRs like it. Instead I want to focus the effort in making changes that benefit the users in a more obvious way.

I vote 👎 for this PR. Since you clearly disagree, I'll leave this open for a second opinion.

@derrabus
Copy link
Member

This is changing a valid type to a slightly better valid type.

So, it's an improvement that helps@VincentLanglet at least and does not hurt anyone. What is your alternative? Patch this on 5.x because it's not a bugfix? Leave an imprecise type declaration from 2015 as it is for eternity?

While introducing a stricter static code analysis to my Symfony projects, I keep finding issues like this one more and more myself. I understand that you don't see value in such changes, but they actually do help.

@chalasr
Copy link
Member

👍 as a minor improvement on 5.x (no bug here)

@VincentLanglet
Copy link
ContributorAuthor

@derrabus Should I change the target branch ?

@Nyholm
Copy link
Member

Should I change the target branch ?

Yes please. It seams like there are a few more people that disagree with me. I'll be happy yo merge this in 5.x as a minor improvement.

derrabus reacted with thumbs up emojiderrabus reacted with heart emoji

@derrabus
Copy link
Member

I'll be happy yo merge this in 5.x as a minor improvement.

Thank you!

@Nyholm
Copy link
Member

I suggest adding the change form#40601 in this PR too.

@VincentLanglet
Copy link
ContributorAuthor

Done

Nyholm reacted with thumbs up emoji

@derrabusderrabus modified the milestones:4.4,5.xMar 31, 2021
@Nyholm
Copy link
Member

Could you please rebase your PR on 5.x so the tests are green? It looks like you forked it a long long time ago.

@VincentLanglet
Copy link
ContributorAuthor

Could you please rebase your PR on 5.x so the tests are green? It looks like you forked it a long long time ago.

I just pulled 5.x and rebased, but tests are still failing...

@Nyholm
Copy link
Member

Cool. Thank you.

This test failure is fine. It is not related to this PR.

(Before we were testing on PHP 7.1 which was dropped a long time ago)

@NyholmNyholm merged commit095f382 intosymfony:5.xApr 1, 2021
@VincentLangletVincentLanglet deleted the extractorPhpDoc branchJuly 15, 2021 17:17
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@derrabusderrabusderrabus approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuh

@ycerutoycerutoAwaiting requested review from yceruto

+1 more reviewer

@dmaicherdmaicherdmaicher approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

6 participants

@VincentLanglet@Nyholm@derrabus@chalasr@dmaicher@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp