-
Notifications
You must be signed in to change notification settings - Fork 7.8k
random: Add missing php.h
include to php_random.h
#10764
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
Conversation
`PHPAPI` is defined in `php.h`. It appears that without the explicit include, recent versions of Visual Studio Code’s intellisense (rightfully) no longer detect `PHPAPI`. This will then lead to a misparsing of the file, because `PHPAPI` is assumed to be the return type and the actual return type is assumed to be the function name, thus expecting a semicolon after the actual return type. This in turn colors the entire header in red due to the detected syntax error(s), making development very hard / impossible. This did not cause issues outside of the IDE use case, because apparently all users of `php_random.h` include `php.h` before including `php_random.h`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, unfortunately we have this issue for a bunch of headers. Doing this for master should be enough.
This is not a case of “some includes are missing, but it's safe, because one header includes them” implicitly. In this case the includes were missing entirely, which I consider to be an actual bug. Especially if it makes the file unusable in a reasonably popular editor / IDE, it should be fixed for a branch that will live roughly three more years. |
Well, if we consider this a bug it should be merged into PHP-8.1 🙂
To be fair, as mentioned there are tons of headers like this. I don't think it would be a good idea to try to fix all of those in the stable branches. Anyway, for this case I don't see a problem with merging this into an older branch. |
ext/random is new in PHP 8.2, so PHP 8.2 is the earliest branch this applies to. This is also part of the reason I applied this to PHP 8.2. Once real world usage of 8.2 ramps up, I expect at least some bug reports and investigating those will be much easier for me without the IDE glowing in red. (I know you already acknowledged this to be OK in 8.2, just wanted to give the additional background information for posterity) |
I missed that part 🙂 |
* PHP-8.2: random: Add missing `php.h` include to php_random.h (#10764)
PHPAPI
is defined inphp.h
. It appears that without the explicit include, recent versions of Visual Studio Code’s intellisense (rightfully) no longer detectPHPAPI
. This will then lead to a misparsing of the file, becausePHPAPI
is assumed to be the return type and the actual return type is assumed to be the function name, thus expecting a semicolon after the actual return type. This in turn colors the entire header in red due to the detected syntax error(s), making development very hard / impossible.This did not cause issues outside of the IDE use case, because apparently all users of
php_random.h
includephp.h
before includingphp_random.h
.