-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
PHP_VERSION_ID incorrect value #2186
Comments
|
Thanks, you're right, that was symfony. Strangely it was loading the PHP<8 and the PHP>=8 file. if (\PHP_VERSION_ID >= 80000) {
return require __DIR__.'/bootstrap80.php';
} Why does it show 50306 if i have configured php 8 ? |
It's statically defined in stubs. You shouldn't rely on constant values showed in tooltips. |
it makes sense. But do you think it's a good idea to change it to the configured value so the symfony functions for PHP of a lower version are ignored ? So like in this following code, if i'm on php8, the signature of the function is the one with int $a if (\PHP_VERSION_ID < 80000) {
function helloWorldTestVersion(string $a) {
}
}
else {
function helloWorldTestVersion(int $a) {
}
}
helloWorldTestVersion('a'); currently intelephense show both of them |
That's irrelevant. Even you use if (false) {
function helloWorldTestVersion(string $a) {
}
}
else {
function helloWorldTestVersion(int $a) {
}
} Both signatures are still provided by intelephense. |
what should symfony or intelephense do to prevent us to see the function definitions we don't want to see then ? what is your opinion to change the way intelphense handle method definitions to ignore them if they are never executed (like in your example) ? |
The idea is good, but I think this feature is difficult to implement. |
Dead code detection: #1718 I think this is a bad idea to have different function signature in different php versions (unless you're dealing with resource/object migration). Better is to keep version logic inside a function: function helloWorldTestVersion(string $a) {
if (\PHP_VERSION_ID < 80000) {
} else {
}
} If you need to make some polyfills, place them into separate file e.g. There are some existing polyfills, which should remove this whole problem: https://packagist.org/explore/?query=symfony%2Fpolyfill-php |
Closing as out of scope. It is not feasible to provide the level of analysis needed to solve this edge case. |
@bmewburn and just for the constant PHP_VERSION_ID, could the extension just use the version defined in settings ? |
@momala454 I think this again falls into the edge case category that is very low priority. However, I did remember just now that there is an existing way to better control what versions of a function is indexed by intelephense. You can add annotations above the definition like so: /**
* @removed 8.1.0
*/
function myFunction(string $string) { }
/**
* @since 8.1.0
*/
function myFunction(object $object) { } |
Describe the bug
the plugin doesn't verify that parameter types of mb_strtolower are correct. Maybe there are more functions with the same problem.
To Reproduce
Expected behavior
an error should be displayed on each of those lines, but it is shown only on strtolower and mysqli_connect.
Btw, no tooltip is shown on "die"
Screenshots
![image](https://user-images.githubusercontent.com/83005/159928168-1e79f52e-3ea0-42d3-bff4-26844001988d.png)
Platform and version
windows
1.8.2
The text was updated successfully, but these errors were encountered: