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

Index reserved keywords for better user experience #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fredden
Copy link

@fredden fredden commented Aug 21, 2023

URLs like https://www.php.net/strpos or https://php.net/implode render the expected documentation page.
Some URLs are specifically configured to redirect to the expected documentation page, like https://php.net/_GET or https://www.php.net/foreach.

However URLs for language features such as yield (https://php.net/yield) and endif (https://php.net/endif) redirect to a function search page which claims that the feature does not exist.

This pull request adds some logic to read the list of reserved keywords from the relevant page of documentation and updates the index to include these results. This means that all the URLs in this description should work as expected.

Note that if php/web-php#804 gets merged before this, we can probably re-assess if this is necessary. There are some comments in the code about refactoring this to read from phd directly or to have phd generate a search database itself.

Copy link
Member

@derickr derickr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still relevant?


if ($f === 'reserved.keywords.php') {
// Yes, this is fragile.
$handle = fopen($file, 'r');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no error handling here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What sort of handling would you like to see here? Would it be enough to move this into the above if statement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least not try to run any code if you can't open the file. Right now ,that would error on line 173 with the fgets.

@fredden
Copy link
Author

fredden commented Jul 31, 2024

Is this still relevant?

Possibly. What's the plan for keeping the list introduced in php/web-php#804 up-to-date? This change adds functionality with very little burden of maintenance as far as I can tell.


if ($f === 'reserved.keywords.php') {
// Yes, this is fragile.
$handle = fopen($file, 'r');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least not try to run any code if you can't open the file. Right now ,that would error on line 173 with the fgets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants