Skip to content

Check for duplicate names in gen_stub.php #6035

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

Closed
wants to merge 1 commit into from

Conversation

TysonAndre
Copy link
Contributor

@TysonAndre TysonAndre commented Aug 23, 2020

With named arguments in php 8.0, it's important that php's modules
or PECL extensions using gen_stub.php don't generate functions
with duplicate names.

Warn if a parameter name is repeated,
even if the last occurrence is a variadic parameter.
Previously, this would not be an error when compiling php-src

Related to php/php-tasks#16 and https://github.com/php/php-src/pull/6015/files

Tested by

  • Running touch **/*.stub.php; make **/*_arginfo.h
  • Verifying that an exception was thrown when renaming a parameter to have the same name as a previous parameter

With named arguments in php 8.0, it's important that php's modules
or PECL extensions using gen_stub.php don't generate functions
with duplicate names.

Warn if a parameter name is repeated,
even if the last occurrence is a variadic parameter
@nikic
Copy link
Member

nikic commented Aug 24, 2020

I've fixed this on the PHP side in 9395e01. Do we still want to check this in stubs as well?

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

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

Guess it doesn't hurt.

It would be nice to refactor the error handling to catch exceptions for a particular declaration and then rethrow with a func_name(): prefix, so that these are handled consistently.

@kocsismate
Copy link
Member

@nikic I think displaying the error as early as possible is a good thing. :)

@php-pulls php-pulls closed this in e056e2d Aug 24, 2020
@TysonAndre
Copy link
Contributor Author

I think displaying the error as early as possible is a good thing. :)

Also, people may miss that if ran gen_stub.php in 8.0 and tested locally with <= 7.4 before publishing a PECL release

It would be nice to refactor the error handling to catch exceptions for a particular declaration and then rethrow with a func_name(): prefix, so that these are handled consistently.

Also,

  • It would be useful to show the parameter name for missing parameter types warnings for a function
  • It would be useful to show all errors for all functions before exiting with a failure status code.

@TysonAndre TysonAndre deleted the duplicate-stub-name-check branch November 25, 2021 21:34
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.

3 participants