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

Remove MixedAssignment #8776

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

muglug
Copy link
Collaborator

@muglug muglug commented Nov 26, 2022

MixedAssignment is largely unnecessary now that we report where mixed data comes from.

This PR removes the issue MixedAssignment and its corresponding class Psalm\Issue\MixedAssignment.

If this PR passes, @psalm-suppress MixedAssignment annotations will now generate an UnusedPsalmSuppress issue if the findUnusedPsalmSuppress option is true or --find-unused-psalm-suppress is passed as a command-line flag.

This would be a breaking change for a major version. If it's too late for Psalm 5, then I'll modify this PR to instead just deprecate the class and associated methods (while keeping the UnusedPsalmSuppress issue since it will only affect a small number of people who track unused suppressions).

@muglug muglug added the release:removed The PR will be included in 'Removed' section of the release notes label Nov 26, 2022
@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/fa55323580
<?php

function takesAnInt(mixed $i): void {
    echo $i;
}
Psalm output (using commit c3cc906):

INFO: MixedArgument - 4:10 - Argument 1 of echo cannot be mixed, expecting string

@@ -320,13 +320,13 @@
<xs:element name="MixedArrayAssignment" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MixedArrayOffset" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MixedArrayTypeCoercion" type="IssueHandlerType" minOccurs="0" />
<xs:element name="MixedAssignment" type="IssueHandlerType" minOccurs="0" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should remain here, but be marked as deprecated. See https://github.com/orklah/psalm/blob/24ae96b373cb44186c58360543dcf0987436df0c/config.xsd#L20-L25 for example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As discussed, it doesn't seem like anyone references it in psalm.xml

Copy link
Collaborator

Choose a reason for hiding this comment

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

Github search shows 97 entries, including some popular repos like doctrine/collections: https://github.com/search?q=path%3Apsalm.xml+language%3AXML+MixedAssignment&type=code

src/Psalm/Issue/MixedAssignment.php Show resolved Hide resolved
src/Psalm/IssueBuffer.php Show resolved Hide resolved
tests/CallableTest.php Outdated Show resolved Hide resolved
tests/CloneTest.php Outdated Show resolved Hide resolved
tests/ErrorBaselineTest.php Outdated Show resolved Hide resolved
@weirdan
Copy link
Collaborator

weirdan commented Nov 27, 2022

Overall I'm not sure whether you wanted to remove the issue or deprecate it. This PR seems to do a little of both, but none completely.

@muglug
Copy link
Collaborator Author

muglug commented Nov 27, 2022

I want to remove the issue, but not break psalm.xml or @psalm-suppress ... uses of it.

@weirdan
Copy link
Collaborator

weirdan commented Nov 27, 2022

I'm a little worried about tests that may start passing even with the broken code because they previously relied on MixedAssignment to detect problematic code. I've already found one by accident (fixed in #8781), but there's no telling how many more there are.

@weirdan
Copy link
Collaborator

weirdan commented Nov 27, 2022

I want to remove the issue, but not break psalm.xml or @psalm-suppress ... uses of it.

I don't mind keeping the issue class, XSD entry and docs for 5.x release cycle, as long as we stop emitting this issue. Could actually use it as a testing ground for #8775

@muglug muglug changed the title Deprecate MixedAssignment Remove MixedAssignment Nov 27, 2022
@muglug muglug added the release:internal The PR will be included in 'Internal changes' section of the release notes label Nov 27, 2022
@muglug muglug marked this pull request as ready for review November 27, 2022 16:38
boesing added a commit to boesing/laminas-cache-storage-adapter-redis that referenced this pull request Dec 16, 2022
Allow `MixedAssignment` issue (by suppressing it). This issue will probably removed in future versions of psalm anyways and it mostly makes no real sense or is not avoidable. For further information, see: vimeo/psalm#8776

Allow `RedundantCastGivenDocblockType` as at least the redis extension does not always provide proper typs. The `RedisException` as well as the `RedisClusterException` does not always provide an integer `code` and thus we have to cast it to ensure that this will always be an integer. Once the extension implemented native type-hints, a `RedundantCast` will be emitted and we are good to remove the cast when requiring the extension version which implemented native type-hints.

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:internal The PR will be included in 'Internal changes' section of the release notes release:removed The PR will be included in 'Removed' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants