-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
Undefined Index notice on numeric strings #1843
Comments
As a extremely hacky alternative, /**
* @return mixed
*/
public function getValue()
{
$handler = set_error_handler(function(){ throw new \ErrorException(); }, E_NOTICE);
try {
$val = $this->reflection->getValue();
} catch (\ErrorException $e) {
$val = (string) $this->reflection->getValue();
}
set_error_handler($handler);
return $val;
} src/Reflection/ClassconstantReflection.php ~38 I'm on 7.2.10 and thought they had this issue fixed... |
Nevermind, I didn't notice it since it showed success. Ran with |
Why did you close this? What’s the bug?
On Fri, 25 Jan 2019 at 18:59, Gamecharmer ***@***.***> wrote:
Closed #1843 <#1843>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1843 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuNTd1DUb0HpU6MT-qeQot4qc59Ajks5vG0XkgaJpZM4aTRRl>
.
--
Ondřej Mirtes
|
@ondrejmirtes It seems to be a bug in PHP's reflection class. Even though you can set numeric string keys in an array, the reflection is still returning them as integers, which then throws undefined index notices during analysis. |
That’s a feature of PHP arrays. Please reopen.
On Fri, 25 Jan 2019 at 19:01, Gamecharmer ***@***.***> wrote:
@ondrejmirtes <https://github.com/ondrejmirtes> It seems to be a bug in
PHP's reflection class. Even though you can set numeric string keys in an
array, the reflection is still returning them as integers, which then
throws undefined index notices during analysis.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1843 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuDRsG3NLkL3d0qYI9VQcekz8S5xWks5vG0Z8gaJpZM4aTRRl>
.
--
Ondřej Mirtes
|
Hey, I just noticed that this is still open from over 2 years ago. Running the tests now via the /r link above shows everything working, so it's probably safe to assume this was fixed. Closing out unless you want it back open. |
Closes phpstan/phpstan#2231 Closes phpstan/phpstan#3558 Closes phpstan/phpstan#4671 Closes phpstan/phpstan#3351 Closes phpstan/phpstan#4648 Closes phpstan/phpstan#4213 Closes phpstan/phpstan#3523 Closes phpstan/phpstan#3120 Closes phpstan/phpstan#1652 Closes phpstan/phpstan#1843
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. |
Current version of PHPStan: 0.11.1
I'm receiving the following notice multiple times during operation. It looks like the reflection is casting a numeric string to an integer then failing to test against string array keys.
Code snippet that reproduces the problem
https://phpstan.org/r/53d70e4d-dce3-4d55-bad5-6a5d707f77b1
The analyzer is working as intended, but due to the notices being thrown is breaking CI. The use case is that a 3rd party API is switching from integers to strings for their IDs.
I believe this issue is related. If so, and this is unsolvable, is there any way to disable this type of check all together?
Expected output
Analysis is correct, PHP Notice for an Undefined index is being thrown though.
The text was updated successfully, but these errors were encountered: