Skip to content

ext/standard: change highlight_string()/print_r stub return type from string|bool to string|true #14959

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

Merged
merged 2 commits into from
Jul 15, 2024

Conversation

Ayesh
Copy link
Member

@Ayesh Ayesh commented Jul 15, 2024

highlight_string either returns string if the $return parameter is true, or always returns true. We can now reflect this in the stubs.

@Ayesh Ayesh marked this pull request as ready for review July 15, 2024 10:16
@Ayesh Ayesh requested a review from kocsismate as a code owner July 15, 2024 10:16
@staabm
Copy link
Contributor

staabm commented Jul 15, 2024

I think these functions use the same kind of construction and might therefore have the same bug:
print_r, var_export, highlight_string, highlight_file, show_source

@Ayesh
Copy link
Member Author

Ayesh commented Jul 15, 2024

  • highlight_file (and its alias show_source) seem to return false if the file is not found.
  • var_export has return type ?string. I think it's correctly returning null for var_export(null).

I think you are right about print_r, I will update the PR to include it.

@Ayesh
Copy link
Member Author

Ayesh commented Jul 15, 2024

Thank you @staabm, print_r now also returns string|true.

@Ayesh Ayesh changed the title ext/standard: change highlight_string() return type from string|bool to string|false ext/standard: change highlight_string()/print_r stub return type from string|bool to string|false Jul 15, 2024
@Ayesh Ayesh changed the title ext/standard: change highlight_string()/print_r stub return type from string|bool to string|false ext/standard: change highlight_string()/print_r stub return type from string|bool to string|true Jul 15, 2024
@nielsdos
Copy link
Member

When changing the stub files you need to rerun ./build/gen_stub.php to update the arginfo files, if that's not updated automatically by doing a make.

@Ayesh Ayesh force-pushed the highlight-string-always-return-true branch from 1d3e315 to 5138ff5 Compare July 15, 2024 11:21
@Ayesh Ayesh requested a review from bukka as a code owner July 15, 2024 11:21
@Ayesh Ayesh force-pushed the highlight-string-always-return-true branch from 5138ff5 to 9d3246d Compare July 15, 2024 11:23
@Ayesh
Copy link
Member Author

Ayesh commented Jul 15, 2024

Thank you, I indeed had forgotten to build arginfo. Fixed now.

@nielsdos
Copy link
Member

Right, In this case you also need to pass --generate-optimizer-info to the gen_stub.php command

@Ayesh Ayesh force-pushed the highlight-string-always-return-true branch from 9d3246d to 5ee0f35 Compare July 15, 2024 12:09
@Ayesh Ayesh requested review from dstogov and iluuu1994 as code owners July 15, 2024 12:09
@Ayesh
Copy link
Member Author

Ayesh commented Jul 15, 2024

TIL 🙏. Force-pushed with --generate-optimizer-info.

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

@nielsdos nielsdos merged commit 673b4e8 into php:master Jul 15, 2024
11 checks passed
@Ayesh Ayesh deleted the highlight-string-always-return-true branch July 16, 2024 08:54
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.

4 participants