Skip to content
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

XMLReader::$nodeType missing properties #8629

Closed
verfriemelt-dot-org opened this issue Jan 2, 2023 · 7 comments
Closed

XMLReader::$nodeType missing properties #8629

verfriemelt-dot-org opened this issue Jan 2, 2023 · 7 comments
Labels

Comments

@verfriemelt-dot-org
Copy link
Contributor

verfriemelt-dot-org commented Jan 2, 2023

Bug report

> var_dump(phpversion(), (new XMLReader)->nodeType);
string(5) "8.2.0"
int(0)

the same applies for at least localName

as seen here this will produces an error with phpstan and php8.2 but not with previous versions.
the phpstorm stub contains the property:

/**
 * The XMLReader extension is an XML Pull parser. The reader acts as a
 * [...]
 * @property-read int $nodeType The node type for the node
 * [...]
 */
class XMLReader

Code snippet that reproduces the problem

https://phpstan.org/r/7b94ed04-7dfb-4add-a191-79ff6d64f940

Expected output

Did PHPStan help you today? Did it make you happy in any way?

yeah, always makes me happy :)

@supun-io
Copy link

supun-io commented Jan 2, 2023

Same issue here after upgrading to PHP 8.2.

@ondrejmirtes
Copy link
Member

This should be fixed in jetbrains/phpstorm-stubs. For some reason these properties are there only as @property in PHPDoc: https://github.com/JetBrains/phpstorm-stubs/blob/38df6dc93adb121b2ea9002eef8598a79648dcad/xmlreader/xmlreader.php#L14-L27

But in reality they're real properties: https://github.com/php/php-src/blob/master/ext/xmlreader/php_xmlreader.stub.php

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Mar 10, 2023
They all run under Php7.4 in Github. 7.4 is EOL. We still have to run unit tests in 7.4, but I think it's time to move the tools. Note that we cannot currently run Phpstan in 8.2 because of phpstan/phpstan#8629.
oleibman added a commit to PHPOffice/PhpSpreadsheet that referenced this issue Mar 14, 2023
* WIP Run phpcs, php-cs-fixer, phpstan, coverage, versions as Php8.1

They all run under Php7.4 in Github. 7.4 is EOL. We still have to run unit tests in 7.4, but I think it's time to move the tools. Note that we cannot currently run Phpstan in 8.2 because of phpstan/phpstan#8629.

* Update main.yml

Try running coverage as 8.0 rather than 8.1.

* Update main.yml

Revert Coverage to Php 7.4.

* Composer Cache Directory

Command set-output is deprecated. Upgrading to using Environment files as suggested by Github messages.

* Coverage and Php8

Try to follow advice in scrutinizer-ci/ocular#54

* Keep Trying

See https://github.com/phpowermove/docblock/pull/12/files
@ghost
Copy link

ghost commented Aug 22, 2023

Hello everyone,

I wanted to mention that this error is not triggered only on nodeType, but also with other XMLReader properties, here is what I get:

Access to an undefined property XMLReader::$hasAttributes.                           
Access to an undefined property XMLReader::$isEmptyElement.                          
Access to an undefined property XMLReader::$name.                                    
Access to an undefined property XMLReader::$nodeType.                                
Access to an undefined property XMLReader::$value.                                   

The above are all valid properties as per:
https://www.php.net/manual/en/class.xmlreader.php

Thank you.

@DanRaiss
Copy link

DanRaiss commented Oct 18, 2023

Facing the same issue here.

Note: Using configuration file /var/www/xxxx/phpstan.neon.
69/69 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


Line XXXX/XXXX/XXXX/Price.php


33 No error to ignore is reported on line 33.
45 Access to an undefined property XMLReader::$name.
💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
45 Access to an undefined property XMLReader::$nodeType.
💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
54 Access to an undefined property XMLReader::$nodeType.
💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
55 Access to an undefined property XMLReader::$name.
💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
98 Access to an undefined property XMLReader::$name.
💡 Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property


After an hour, trying to find solution, i decided to add file in excludePaths in phpstan.neon

@mhsdesign
Copy link

as a workaround - that works on ci for both php 8.0 and 8.2 - i used

/** @var object|\XMLReader $reader the stubs for XMLReader are wrong https://github.com/phpstan/phpstan/issues/8629 */

as @phpstan-ignore-next-line would complain on 8.0 that there is nothing to ignore ^^

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@2d364d7

mhsdesign added a commit to neos/flow-development-collection that referenced this issue Jan 24, 2024
neos-bot pushed a commit to neos/flow that referenced this issue Jan 25, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants