-
Notifications
You must be signed in to change notification settings - Fork 569
Fix #12253: assign.readOnlyProperty #5061
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
Changes from 1 commit
9ec0cbd
7f6add5
6d4a2d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| <?php // lint >= 8.4 | ||
|
|
||
| declare(strict_types = 1); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add another test with the same problem, but 1
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're out of extra usage · resets 5pm (UTC)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add another test with the same problem, but 1 additionalConstructors configured
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I've addressed staabm's review by adding a |
||
|
|
||
| namespace Bug12253; | ||
|
|
||
| use stdClass; | ||
|
|
||
| class Payload | ||
| { | ||
| /** @var array<array<string, mixed>> */ | ||
| private(set) readonly array $validation; | ||
|
|
||
| /** @var array<string, string> */ | ||
| private array $ids = []; | ||
|
|
||
| public function __construct(private readonly stdClass $payload) | ||
| { | ||
| $this->parseValidation(); | ||
| } | ||
|
|
||
| private function parseValidation(): void | ||
| { | ||
| $validations = []; | ||
|
|
||
| foreach ($this->payload->validation as $key => $validation) { | ||
| $validations[] = [ | ||
| 'id' => $key, | ||
| 'field_id' => $this->ids[$validation->field_id], | ||
| 'rule' => $validation->rule, | ||
| 'value' => $this->validationValue($validation->value), | ||
| 'message' => $validation->message, | ||
| ]; | ||
| } | ||
|
|
||
| $this->validation = $validations; | ||
| } | ||
|
|
||
| private function validationValue(mixed $value): mixed | ||
| { | ||
| if (is_null($value)) { | ||
| return null; | ||
| } | ||
|
|
||
| return $this->ids[$value] ?? $value; | ||
| } | ||
| } | ||
|
|
||
| class PayloadWithoutAsymmetricVisibility | ||
| { | ||
| /** @var array<array<string, mixed>> */ | ||
| private readonly array $validation; | ||
|
|
||
| /** @var array<string, string> */ | ||
| private array $ids = []; | ||
|
|
||
| public function __construct(private readonly stdClass $payload) | ||
| { | ||
| $this->parseValidation(); | ||
| } | ||
|
|
||
| private function parseValidation(): void | ||
| { | ||
| $validations = []; | ||
|
|
||
| foreach ($this->payload->validation as $key => $validation) { | ||
| $validations[] = [ | ||
| 'id' => $key, | ||
| 'field_id' => $this->ids[$validation->field_id], | ||
| 'rule' => $validation->rule, | ||
| 'value' => $this->validationValue($validation->value), | ||
| 'message' => $validation->message, | ||
| ]; | ||
| } | ||
|
|
||
| $this->validation = $validations; | ||
| } | ||
|
|
||
| private function validationValue(mixed $value): mixed | ||
| { | ||
| if (is_null($value)) { | ||
| return null; | ||
| } | ||
|
|
||
| return $this->ids[$value] ?? $value; | ||
| } | ||
| } | ||
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.
when seeing such comparison it reminds me that we have a NEON config
additionalConstructors. is this somehow related/should be taken into account?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.
All background tasks confirmed successful. The fix is committed and pushed.