-
Notifications
You must be signed in to change notification settings - Fork 153
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
Psalm #778
Psalm #778
Conversation
This will probably greatly benefit from #777. |
So there's an issue in that slevomat/coding-standard 5.0.4 requires php 7.1 & there's a sniff used that isn't in the latest version that supports php 7.0. Rather than tinkering with the travis config, I'd recommend dropping php 7.0, given that it's been EOL for 8 months. |
If that's the case, then we need to revert part of #773. I wonder why the Travis build has not failed, though. As for the minimum PHP version, we plan to require PHP >= 7.1 for Emogrifier 5.0 (i.e., for the next-after-next breaking release). As we have announced that PHP >= 7.0 will suffice for Emogrifier 4.0.0, I'd like to not break that promise. (We could release 4.0.0 quite soon so we can drop PHP 7.0, though.) |
it's also worth noting that 7.1 goes EOL as of next year. |
I have created #779 to resolve the problem with PHP 7.0. |
I'll rebase once that's merged, although possibly not this evening. |
Thanks, that's perfectly fine. There is no hurry. By the way, I'd prefer to have relatively low-impact PRs, e.g., one for adding psalm to the CI chain (without any code changes) and for adding a baseline, then others for fixing issues found by psalm, another for adding psalm-specific annotations, one for sorting the dependencies etc. |
split ef33fbf into 3 on the rebase? |
Yes, thanks, that would be great. |
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.
I've added a few comments/suggestions/observations. @SignpostMarv, thanks for contributing, looks like a fair bit of work 🤩
This commit updates the changelog in reference to the previous commits implementing psalm checking & resolving issues. regarding: MyIntervals#537, MyIntervals#778
This is why I generally commit all psalm bug fixes en-masse. |
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.
Looks generally excellent. I am close to being happy for this to be meged to master
, but not quite.
There are some changes relating to methods being static
vs non-static I'm not totally happy with, because thier counterparts in PHPUnit are static
.
There are also a few other tiny improvements that could be made (really minor issues). But I'd be happy for them to be addressed in a separate PR, so that we can get this one merged.
And I think the config files should be in the config
directory. I'd be totally happy with this being addressed by a separate future PR – handling changes like this now in this PR I'm sure would be an unnecessary pain 😉
@oliverklee, what do you think?
composer.json
Outdated
@@ -74,6 +76,7 @@ | |||
"ci:php:sniff": "phpcs config src tests", | |||
"ci:php:fixer": "php-cs-fixer --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots --diff-format=udiff config/ src/ tests/", | |||
"ci:php:md": "phpmd src text config/phpmd.xml", | |||
"ci:php:psalm": "psalm --show-info=false", |
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.
Could we add this to Travis? If so, let's do it as a separate PR (and get this one merged sooner rather than later).
EDIT: see #736
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.
Had overlooked this, was running composer run ci
locally.
There's also vimeo/psalm#1192 to take into account, the fix for which wasn't yet introduced in 3.2 (which you're stuck using because of various dependencies).
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.
OK. Let's do this as a separate PR. I've added #790 so that it is captured and this conversation can be resolved.
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.
Oh, I see you've pushed a commit to this PR adding the step to Travis, but it's currently failing due to some remaining issues. I suggest also addressing the remaining issues as that (or another) separate PR - this one is beginning to become hard to follow and keep track of via the GitHub UI.
tests/Support/Traits/AssertCss.php
Outdated
int $expectedCount, | ||
string $needle, | ||
string $haystack | ||
) { | ||
self::assertSame( | ||
$this->assertSame( |
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.
assertSame
is a static
method and should be called staticly. Is there an issue with Psalm that we need a workaround for here?
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.
that'd be NonStaticSelfCall
7d7a528#diff-db03589574d7c5d074966c97658929d9
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.
Looks like an issue with Psalm then. assertSame
is definitely a static
method in PHPUnit.
I've added #792 to capture this. For now, can we revert changes relating to calls via self::
vs $this
(and also any changes making methods static
vs non-static
), so that we can get this PR merged, and then move on to address the remaining issues separately?
@SignpostMarv Thanks for this huge effort! I'd like to keep "separate things in separate PRs", i.e., one separate PR for adding psalm to the build and adding the baseline, and then one (or more) separate PRs for fixing things found by psalm and adding psalm-specific annotations. Optimally, those separate PRs will start with one commit each. |
(Smaller PRs will also make the reviews easier and help get the parts merged a lot faster.) |
@oliverklee @JakeQZ When I split this into multiple PRs, should the
At present this would result in 30~ PRs. |
Sorry, my comment was a bit ambiguous. I meant "Define well-cut packages for each PR, and if necessary, squash several commits for the same package together before creating the PR for that package." |
In principle, yes. (Although I do not agree with that particular change. I'll add a comment to that commit in a second.) |
This commit updates the changelog in reference to the previous commits implementing psalm checking & resolving issues. regarding: MyIntervals#537, MyIntervals#778
regarding: MyIntervals#778
/** @psalm-var array{0:string, 1:string, 2:string, 3:string} */ | ||
$matches = $matches; | ||
|
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.
Can this instead be @psalm-param
for the function/closure?
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.
see commit message for f6ea5a1
Can I suggest by specific Psalm check rather than by file? i.e. Enable one-by-one the checks in If there are some @SignpostMarv, @oliverklee, does that make sense? |
issues error by default. |
PR by file would mean continuous blocks would be removed from ./psalm.baseline.xml, generally having a single block to merge- making rebasing and merging more straightforward. PR by type can introduce issues of other types, possibly introducing issues a PR was already made for; there's a couple of those in this PR. |
So we could enable one issue, and fix the errors for that specific issue, and have that as a single PR? Rinse and repeat? Those that cause errors we cannot address right now (e.g. |
prepping an explanation on #795 in response to query there. |
OK, thanks. Just been reading https://erik.booij.me/a-year-with-psalm/ |
following on from that explanation, what one could do is:
what I've been doing is:
|
Thanks for that. I'm beginning to get a grasp on how it works 🙂
I'm just wanting to be sure we're taking the best approach to make all our lives easier, both in terms of being able to keep track of what changes are being made to the code base and why, and to minimize the effort actually required to get to a good baseline. |
Really, any way that breaks down the changes into small mangeable chunks would be good :) @SignpostMarv, we very much appreciate the effort you've been putting in here, it's been amazing. |
This commit updates the changelog in reference to the previous commits implementing psalm checking & resolving issues. regarding: MyIntervals#537, MyIntervals#778
This commit resolves the yoda conditions introduced in previous [BUGFIX] commits. regarding: MyIntervals#794, MyIntervals#778 (comment)
This commit updates the changelog in reference to the previous commits implementing psalm checking & resolving issues. regarding: MyIntervals#537, MyIntervals#778
This commit resolves the yoda conditions introduced in previous [BUGFIX] commits. regarding: MyIntervals#794, MyIntervals#778 (comment)
This commit updates the changelog in reference to the previous commits implementing psalm checking & resolving issues. regarding: MyIntervals#537, MyIntervals#778
This commit resolves the yoda conditions introduced in previous [BUGFIX] commits. regarding: MyIntervals#794, MyIntervals#778 (comment)
This commit resolves the yoda conditions introduced in previous [BUGFIX] commits. regarding: * MyIntervals#794 * MyIntervals#778 (comment) * MyIntervals#805 (review)
… updating baseline. This commit resolves one of the PossiblyNullPropertyAssignmentValue issues identified in src/HtmlProcessor/AbstractHtmlProcessor.php at the expense of identifying various further Null issues regarding: #537 (Note: the following commit messages from the PR are included for completeness, but may overlap with others due to merges/rebases.) * [BUGFIX] partially satisfy psalm, updating baseline This commit resolves the PossiblyNullReference issues introduced by a previous [BUGFIX] in src/HtmlProcessor/AbstractHtmlProcessor.php by refactoring `$this->domDocument->` to `$this->getDomDocument()->` This necessarily alters the body of the previously identified NullableReturnStatement issue. regarding: #537 * [BUGFIX] partially satisfy psalm, updating baseline This commit resolves 1 InvalidNullableReturnType and 1 NullableReturnStatement issue identified in src/HtmlProcessor/AbstractHtmlProcessor.php by throwing an exception if `AbstractHtmlProcessor::$domDocument` has not been set. regarding: #537 * [BUGFIX] satisfy php-cs-fixer This commit resolves the yoda conditions introduced in previous [BUGFIX] commits. regarding: * #794 * #778 (comment) * #805 (review) * [TASK] Add exception code based on UNIX timestamp regarding: #805 (comment) * [CLEANUP] Adjust indentation This commit adjusts the indentation separate from the addition of parenthesis in a previous commit, on the basis of making indentation & line break changes separate from functional changes. regarding: #805 (comment)
* [BUGFIX] resolve PossiblyNull psalm issues via phpunit instanceof assertion, re: #537 This commit resolves the PossiblyNull issue identified in tests/Unit/CssInlinerTest.php by adding an additional assertion that would force the test to fail if the `DOMNodeList::item()` resolved to a non-element result (i.e. null or other DOMNode type) regarding: #537 * [CLEANUP] removing superfluous line breaks regarding: #778 (comment) * [BUGFIX] Partially satisfy psalm, update baseline This commit resolves a set of InvalidOperand issues by using the psalm-specific docblock tags `@psalm-return`, `@psalm-var`, and `@psalm-param` regarding: #801 (review)
This commit updates the changelog in reference to the previous commits implementing psalm checking & resolving issues. regarding: MyIntervals#537, MyIntervals#778
This commit resolves the yoda conditions introduced in previous [BUGFIX] commits. regarding: MyIntervals#794, MyIntervals#778 (comment)
No description provided.