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
Extending ArrayObject with private properties produces false positives #7983
Comments
I found these snippets: https://psalm.dev/r/8c3b56d382<?php
/** @extends ArrayObject<string, mixed> */
class Foo extends \ArrayObject {
private string $name = '';
}
|
For some reason |
Where does it come from? I found this: psalm/dictionaries/PropertyMap.php Line 32 in 3a85f49
which accordingly to comment is "stolen" from phan/phan/src/Phan/Language/Internal/PropertyMap.php. Sadly neither tells where it originates from. It appears to be wrong non-the-less. |
It seems to be generated from php.net somehow: https://github.com/phan/phan/blob/93c1c287d646d08249b4f5539bfe147550b163d7/src/Phan/Language/Internal/PropertyMap.php#L56 but it seems wrong to me too. @TysonAndre Do you remember the reason for this? It seems that a lot of iterators seems to have a name property but I don't think it's true. Maybe old documentation artifacts? |
Traced it down to: https://svn.php.net/repository/phpdoc/en/trunk/reference/spl/arrayobject.xml It has (from line 69 on): <!-- }}} -->
|
| <!-- {{{ If the property is documented below (xml:id=arrayobject.props) use this
| <classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
| <fieldsynopsis>
| <modifier>public</modifier>
| <type>string</type>
| <varname linkend="arrayobject.props.name">name</varname>
| </fieldsynopsis>
| }}} --> This is commented XML code, which is simply not handled by the bash one liner embedded in the code. |
wow congrats, this is a pretty old bug found in both tools (possibly in phpstan too?)! I think there's a lot of name properties we could drop in there |
New location is here: https://github.com/php/doc-en/blob/master/reference/spl/arrayobject.xml#L101 |
Are you up for a PR to fix this? :) |
Working on it. |
While working on this, I am a little confused as some classes are denoted with PS: I wrote a small XML parser script (using |
Can you give an example?
Absolutely! My goal is to remove extensions from the callmap over time, but it will definitely still be useful for built in types, and with a bit of work it could provide a very useful automatic comparison between the PHP documentation and reflected extension types. |
the Yeah, please do for the parser |
PR submitted as #8000 (nice number 😄). |
this was fixed :) |
When defining a class that extends
ArrayObject
, psalm seems a little confused, as it detects private properties to have a different access level than the very same property in the very same class.It even reports some type variance for the private property - despite the fact that
ArrayObject
does not declare any properties.I fail to see how to tackle this, as I do not know how I could pin point the culprit.
https://psalm.dev/r/8c3b56d382
The text was updated successfully, but these errors were encountered: