Skip to content
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

Update laminas-coding-standard to v2 #202

Merged
merged 16 commits into from
Aug 4, 2022

Conversation

Slamdunk
Copy link
Contributor

@Slamdunk Slamdunk commented Aug 2, 2022

No description provided.

@Slamdunk Slamdunk added this to the 2.17.0 milestone Aug 2, 2022
@Slamdunk
Copy link
Contributor Author

Slamdunk commented Aug 2, 2022

PHP Fatal error:  Uncaught TypeError: Argument 5 passed to SlevomatCodingStandard\Helpers\Annotation\ParameterAnnotation::__construct() must be an instance of PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode or null, instance of PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode given, called in /github/workspace/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php on line 357 and defined in /github/workspace/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/Annotation/ParameterAnnotation.php:31

😭

@Ocramius
Copy link
Member

Ocramius commented Aug 2, 2022

Yup, you can force phpstan/phpdoc-parser: <1.6 to make it run, meanwhile (do it locally, run a composer update, then remove the clause and use composer update nothing)

@Slamdunk
Copy link
Contributor Author

Slamdunk commented Aug 2, 2022

Wouldn't CI fail nevertheless, if I don't commit the phpdoc-parser: <1.6 requirement?

@Ocramius
Copy link
Member

Ocramius commented Aug 2, 2022

Only in the next lockfile update PR

@Slamdunk Slamdunk force-pushed the laminas-coding-standard_2.3 branch from 9ab6d41 to 7ed01b6 Compare August 2, 2022 08:46
@Slamdunk
Copy link
Contributor Author

Slamdunk commented Aug 2, 2022

As I expected, build can't get green if I don't commit "phpstan/phpdoc-parser": "~1.5.0":
https://github.com/laminas/laminas-mail/runs/7627796218?check_suite_focus=true#step:3:416

I can commit it though, can't I?

@Ocramius
Copy link
Member

Ocramius commented Aug 2, 2022

The idea is to commit a composer.lock with an older phpstan/phpdoc-parser, by leaving composer.json intact.
CS checks run on locked dependencies only.

@Slamdunk
Copy link
Contributor Author

Slamdunk commented Aug 2, 2022

Oh, now I get it.

But I don't see a laminas guide on how to produce the composer.lock consistently: is a composer update on lowest supported PHP binary enough?

@Ocramius
Copy link
Member

Ocramius commented Aug 2, 2022

There's no guide for that, afaik: I proposed an approach in #202 (comment)

  1. add the dependency restriction to composer.json
  2. run composer update
  3. remove the dependency restriction from composer.json
  4. run composer update nothing

this gives you a composer.lock in the state you need it.

Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
@Slamdunk Slamdunk force-pushed the laminas-coding-standard_2.3 branch from 7ed01b6 to ff5d13e Compare August 2, 2022 09:00
@Slamdunk
Copy link
Contributor Author

Slamdunk commented Aug 2, 2022

Thank you, I was missing the last step.

Now, down to the PR: LCSv2 introduces declare(strict_types=1); everywhere, should this change be considered a BC Break?

@Ocramius
Copy link
Member

Ocramius commented Aug 2, 2022

It really depends - declare(strict_types=1) is safe to perform in some cases, while in others, it can lead to massive breakages.

I wouldn't say that the laminas/laminas-mail code is very "safe", at least when looking at its large psalm baseline:

<RedundantCondition occurrences="1">
<code>assertNotNull</code>
</RedundantCondition>
</file>
</files>

I think we need to disable that rule here. See how it's done in laminas/laminas-eventmanager:

https://github.com/laminas/laminas-eventmanager/blob/6c056ab3b4b464daa308fd9ca3e7416ca40cf200/phpcs.xml#L23-L25

…perators rules, we are not ready

Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
… kick in

Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Copy link
Contributor Author

@Slamdunk Slamdunk left a comment

Choose a reason for hiding this comment

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

I've carefully fixed all the PHPCS issues.

I've also fixed most of the notable PSalm issues; the rest that I've baselined are just too tedious to be done manually now in PHPDocs.

Similarly to what I've done for laminas-form:v3.0.0 I'll be happy to clear all PSalm baseline once we can ship native types though.

src/Exception/ExceptionInterface.php Show resolved Hide resolved
src/Header/AbstractAddressList.php Outdated Show resolved Hide resolved
src/Header/Subject.php Show resolved Hide resolved
src/Protocol/Imap.php Show resolved Hide resolved
@@ -25,7 +25,7 @@ class SmtpPluginManager extends AbstractPluginManager
/**
* Service aliases
*
* @var array
* @var array<array-key, class-string>
Copy link
Member

Choose a reason for hiding this comment

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

The template parameter on AbstractPluginManager<InstanceType> should probably be filled:

https://github.com/laminas/laminas-servicemanager/blob/6cee2f3125e074c0960c13a9ffc1ed93127b860e/src/AbstractPluginManager.php#L35

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've looked at laminas/laminas-validator#129 and commit d20feb2 is the result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error: src/Protocol/SmtpPluginManager.php:26:23: InvalidTypeImport: Type alias FactoriesConfigurationType imported from Laminas\ServiceManager\ConfigInterface

Because I've checked commit validity against latest deps, but PSalm in CI runs on lowest which misses all the latest types-related releases.

Should I revert this, or keep and baseline it?

Copy link
Member

Choose a reason for hiding this comment

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

but PSalm in CI runs on lowest which misses all the latest types-related releases.

It should run with locked dependencies.

This seems to occur because we're still on PHP 7.3, and the latest type improvements are on PHP 7.4.

Let's touch this in a follow-up that drops PHP 7.4 👍

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see that you did add the templated types. In order for that to work, we need to drop PHP 7.3, and then a composer update should bring us on par with the servicemanager improvements, as well as make the build green again 👍

src/Storage/Folder/FolderInterface.php Show resolved Hide resolved
src/Storage/Part.php Outdated Show resolved Hide resolved
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
…format param

Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM.

What's still missing:

  • drop PHP 7.4
  • re-generate baseline with the new dependency upgrades (it should get rid of the templated types issues)

@Slamdunk
Copy link
Contributor Author

Slamdunk commented Aug 4, 2022

What's still missing

Since you approved this PR, I guess I can merge this as-is (with failing build) and then open a follow up to drop PHP < 8.0.

Merging red builds isn't good, but neither is discussing such big changes in the same PR.
At least that's what I'd do in my repos.

Confirm please, just so that I can learn your preferred way of managing such situations.

@Ocramius
Copy link
Member

Ocramius commented Aug 4, 2022

No, please make it green first, be it through adjusted baseline or else, but let's not merge on red, as that just blocks other work, and will also lead to raised PRs by Renovate bot overnight :|

Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
@Slamdunk Slamdunk merged commit 50d0bf5 into laminas:2.17.x Aug 4, 2022
@Slamdunk Slamdunk deleted the laminas-coding-standard_2.3 branch August 4, 2022 13:46
artemii-karkusha pushed a commit to artemii-karkusha/laminas-mail that referenced this pull request May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants