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

random: Add missing php.h include to php_random.h #10764

Merged
merged 1 commit into from Mar 6, 2023

Conversation

TimWolla
Copy link
Member

@TimWolla TimWolla commented Mar 3, 2023

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.

`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`.
Copy link
Member

@iluuu1994 iluuu1994 left a 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.

@TimWolla
Copy link
Member Author

TimWolla commented Mar 3, 2023

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.

@iluuu1994
Copy link
Member

Well, if we consider this a bug it should be merged into PHP-8.1 🙂

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.

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.

@TimWolla
Copy link
Member Author

TimWolla commented Mar 3, 2023

Well, if we consider this a bug it should be merged into PHP-8.1

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)

@iluuu1994
Copy link
Member

ext/random is new in PHP 8.2, so PHP 8.2 is the earliest branch this applies to.

I missed that part 🙂

@TimWolla TimWolla merged commit 5087931 into php:PHP-8.2 Mar 6, 2023
TimWolla added a commit that referenced this pull request Mar 6, 2023
* PHP-8.2:
  random: Add missing `php.h` include to php_random.h (#10764)
@TimWolla TimWolla deleted the random-header-include branch March 6, 2023 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants