-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Improved readonly errors
#22609
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
Open
NickSdot
wants to merge
3
commits into
php:master
Choose a base branch
from
NickSdot:improve-readonly-errors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Improved readonly errors
#22609
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --TEST-- | ||
| Readonly property satisfies get-only abstract property | ||
| --FILE-- | ||
| <?php | ||
| abstract class A { | ||
| public abstract int $prop { get; } | ||
| } | ||
| class C extends A { | ||
| public readonly int $prop; | ||
| public function __construct(int $prop) { | ||
| $this->prop = $prop; | ||
| } | ||
| } | ||
| $c = new C(42); | ||
| var_dump($c->prop); | ||
| ?> | ||
| --EXPECT-- | ||
| int(42) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
| --TEST-- | ||
| readonly property does not satisfy get/set abstract property | ||
| Readonly property cannot implement set hook of get/set abstract property | ||
| --FILE-- | ||
| <?php | ||
| abstract class P { | ||
| abstract class A { | ||
| protected abstract int $prop { get; set; } | ||
| } | ||
| class C extends P { | ||
| public function __construct(protected readonly int $prop) {} | ||
| class C extends A { | ||
| protected readonly int $prop; | ||
| public function __construct(int $prop) { | ||
| $this->prop = $prop; | ||
| } | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Class C contains 1 abstract method and must therefore be declared abstract or implement the remaining method (P::$prop::set) in %s on line %d | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by class A::$prop in %s on line %d |
13 changes: 13 additions & 0 deletions
13
Zend/tests/property_hooks/abstract_get_set_readonly_promoted.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --TEST-- | ||
| Readonly promoted property cannot implement set hook of get/set abstract property | ||
| --FILE-- | ||
| <?php | ||
| abstract class A { | ||
| protected abstract int $prop { get; set; } | ||
| } | ||
| class C extends A { | ||
| public function __construct(protected readonly int $prop) {} | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by class A::$prop in %s on line %d |
16 changes: 16 additions & 0 deletions
16
Zend/tests/property_hooks/abstract_get_set_readonly_public.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --TEST-- | ||
| Readonly property cannot implement set hook of public get/set abstract property | ||
| --FILE-- | ||
| <?php | ||
| abstract class A { | ||
| public abstract int $prop { get; set; } | ||
| } | ||
| class C extends A { | ||
| public readonly int $prop; | ||
| public function __construct(int $prop) { | ||
| $this->prop = $prop; | ||
| } | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by class A::$prop in %s on line %d |
13 changes: 13 additions & 0 deletions
13
Zend/tests/property_hooks/abstract_get_set_readonly_public_promoted.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --TEST-- | ||
| Readonly promoted property cannot implement set hook of public get/set abstract property | ||
| --FILE-- | ||
| <?php | ||
| abstract class A { | ||
| public abstract int $prop { get; set; } | ||
| } | ||
| class C extends A { | ||
| public function __construct(public readonly int $prop) {} | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by class A::$prop in %s on line %d |
16 changes: 16 additions & 0 deletions
16
Zend/tests/property_hooks/abstract_get_set_readonly_public_set.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --TEST-- | ||
| Readonly public(set) property cannot implement set hook of public get/set abstract property | ||
| --FILE-- | ||
| <?php | ||
| abstract class A { | ||
| public abstract int $prop { get; set; } | ||
| } | ||
| class C extends A { | ||
| public public(set) readonly int $prop; | ||
| public function __construct(int $prop) { | ||
| $this->prop = $prop; | ||
| } | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by class A::$prop in %s on line %d |
13 changes: 13 additions & 0 deletions
13
Zend/tests/property_hooks/abstract_get_set_readonly_public_set_promoted.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --TEST-- | ||
| Readonly promoted public(set) property cannot implement set hook of public get/set abstract property | ||
| --FILE-- | ||
| <?php | ||
| abstract class A { | ||
| public abstract int $prop { get; set; } | ||
| } | ||
| class C extends A { | ||
| public function __construct(public public(set) readonly int $prop) {} | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by class A::$prop in %s on line %d |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ty_hooks/interface_get_only_readonly.phpt → ...ty_hooks/interface_readonly_get_only.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --TEST-- | ||
| Readonly property cannot implement set hook of get/set interface property | ||
| --FILE-- | ||
| <?php | ||
| interface I { | ||
| public int $prop { get; set; } | ||
| } | ||
| class C implements I { | ||
| public readonly int $prop; | ||
| public function __construct(int $prop) { | ||
| $this->prop = $prop; | ||
| } | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by interface I::$prop in %s on line %d |
13 changes: 13 additions & 0 deletions
13
Zend/tests/property_hooks/interface_readonly_get_set_promoted.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --TEST-- | ||
| Readonly promoted property cannot implement set hook of get/set interface property | ||
| --FILE-- | ||
| <?php | ||
| interface I { | ||
| public int $prop { get; set; } | ||
| } | ||
| class C implements I { | ||
| public function __construct(public readonly int $prop) {} | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by interface I::$prop in %s on line %d |
16 changes: 16 additions & 0 deletions
16
Zend/tests/property_hooks/interface_readonly_get_set_public_set.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --TEST-- | ||
| Readonly public(set) property cannot implement set hook of get/set interface property | ||
| --FILE-- | ||
| <?php | ||
| interface I { | ||
| public int $prop { get; set; } | ||
| } | ||
| class C implements I { | ||
| public public(set) readonly int $prop; | ||
| public function __construct(int $prop) { | ||
| $this->prop = $prop; | ||
| } | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by interface I::$prop in %s on line %d |
13 changes: 13 additions & 0 deletions
13
Zend/tests/property_hooks/interface_readonly_get_set_public_set_promoted.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --TEST-- | ||
| Readonly promoted public(set) property cannot implement set hook of get/set interface property | ||
| --FILE-- | ||
| <?php | ||
| interface I { | ||
| public int $prop { get; set; } | ||
| } | ||
| class C implements I { | ||
| public function __construct(public public(set) readonly int $prop) {} | ||
| } | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Readonly property C::$prop cannot implement set hook required by interface I::$prop in %s on line %d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.