Skip to content

More class const improvements.#7666

Merged
weirdan merged 1 commit intovimeo:masterfrom
AndrolGenhald:more-class-const-improvements
Feb 16, 2022
Merged

More class const improvements.#7666
weirdan merged 1 commit intovimeo:masterfrom
AndrolGenhald:more-class-const-improvements

Conversation

@AndrolGenhald
Copy link
Copy Markdown
Collaborator

@AndrolGenhald AndrolGenhald commented Feb 13, 2022

Add InvalidClassConstType issue as alternative to LessSpecificClassConstType when type isn't contravariant.
Handle final class consts (#6395).
Use double quotes for types in class const issues.

Fixes #7668

Add InvalidClassConstType issue as alternative to LessSpecificClassConstType when type isn't contravariant.
Handle final class consts (vimeo#6395).
Use double quotes for types in class const issues.
@weirdan
Copy link
Copy Markdown
Collaborator

weirdan commented Feb 14, 2022

Can you add a test highlighting Psalm behaviour in regards to non-final interface constant inheritance? They were forbidden in PHP 5.0-8.0, and are allowed in PHP 8.1+: https://3v4l.org/PYZFB

@AndrolGenhald
Copy link
Copy Markdown
Collaborator Author

Can you add a test highlighting Psalm behaviour in regards to non-final interface constant inheritance? They were forbidden in PHP 5.0-8.0, and are allowed in PHP 8.1+: https://3v4l.org/PYZFB

Way ahead of you, that was added in #7154.

@psalm-github-bot
Copy link
Copy Markdown

I found these snippets:

https://psalm.dev/r/684e1851bf
<?php

interface A {
     const B = 1;
}

interface C extends A {
     const B = 2;
}
Psalm output (using commit 5aa06ae):

ERROR: OverriddenInterfaceConstant - 8:12 - C::B cannot override constant from A

INFO: LessSpecificClassConstantType - 8:12 - The type '2' for C::B is more general than the type '1' inherited from A::B

@weirdan weirdan linked an issue Feb 14, 2022 that may be closed by this pull request
@weirdan weirdan added this to the PHP 8.1 milestone Feb 14, 2022
@weirdan weirdan added the release:feature The PR will be included in 'Features' section of the release notes label Feb 14, 2022
@weirdan weirdan requested a review from orklah February 14, 2022 00:40
@weirdan weirdan merged commit e47752a into vimeo:master Feb 16, 2022
@weirdan
Copy link
Copy Markdown
Collaborator

weirdan commented Feb 16, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:feature The PR will be included in 'Features' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for final constants

2 participants