-
Notifications
You must be signed in to change notification settings - Fork 660
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
Not possible to extend ArrayObject
- conflict of ArrayObject/ArrayAccess?
#10533
Labels
easy problems
Issues that can be fixed without background knowledge of Psalm
enhancement
good first issue
internal stubs/callmap
Comments
I found these snippets: https://psalm.dev/r/a03704b816<?php
/**
* Class ControllerDescriptionArray.
*
* @extends \ArrayObject<int, stdClass|null>
*/
class ControllerDescriptionArray extends \ArrayObject {
public function offsetSet(mixed $key, mixed $value): void {
if ($value instanceof stdClass === false) {
throw new \InvalidArgumentException('Value must be a class');
}
parent::offsetSet($key, $value);
}
}
|
Same here. |
The error is valid and should be fixed in PHP. Meanwhile, we should probably annotate |
weirdan
added
enhancement
easy problems
Issues that can be fixed without background knowledge of Psalm
internal stubs/callmap
good first issue
labels
Mar 7, 2024
Psalm does not complain if you name the argument |
I found these snippets: https://psalm.dev/r/ad9554f91a<?php
/**
* Class ControllerDescriptionArray.
*
* @extends \ArrayObject<int, stdClass|null>
*/
class ControllerDescriptionArray extends \ArrayObject {
public function offsetSet(mixed $offset, mixed $value): void {
if ($value instanceof stdClass === false) {
throw new \InvalidArgumentException('Value must be a class');
}
parent::offsetSet((int)$offset, $value);
}
}
|
weirdan
added a commit
to weirdan/psalm
that referenced
this issue
Mar 9, 2024
weirdan
added a commit
to weirdan/psalm
that referenced
this issue
Mar 9, 2024
weirdan
added a commit
to weirdan/psalm
that referenced
this issue
Mar 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
easy problems
Issues that can be fixed without background knowledge of Psalm
enhancement
good first issue
internal stubs/callmap
Example:
https://psalm.dev/r/a03704b816
And the real code:
output (psalm 5.18.0):
Note: According to https://www.php.net/manual/en/arrayobject.offsetset.php, the ArrayObject::offsetSet() method signature is:
According to https://www.php.net/manual/en/arrayaccess.offsetset.php, the ArrayAccess::offsetSet() method signature is:
The text was updated successfully, but these errors were encountered: