Skip to content

Update gen_stub to support #if around classes #8736

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 1 commit into from
Jun 13, 2022

Conversation

adoy
Copy link
Member

@adoy adoy commented Jun 8, 2022

I have a case where I only want to create a class on some conditions

#if LIBCURL_VERSION_NUM >= 0x073E00 /* Available since 7.62.0 */
/**
 * @strict-properties
 * @not-serializable
 */
final class CurlUrl
{
}
#endif

This change will add the appropriate conditions around the zend_function_entry and zend_class_entry

@kocsismate
Copy link
Member

Can you please check if your changes work with sensitive parameters? The generateAttributeInitialization() function generates the zend_mark_function_parameter_as_sensitive() invocations which add the attribute to a parameter

@adoy
Copy link
Member Author

adoy commented Jun 9, 2022

@kocsismate Thanks for this comment. I moved the attribute initialisation of methods inside the class registration, so that now the register_x_symbols function only contains zend_mark_function_parameter_as_sensitive for functions and will not take all the class entries in parameters. Does it make sense to you ?

Also I noticed after regenerating the files that sometime we do use four spaces and sometime tab as indent. I did not change that yet and will do the change in a commit after this change to make this consistant.

@TimWolla
Copy link
Member

TimWolla commented Jun 9, 2022

I moved the attribute initialisation of methods inside the class registration, so that now the register_x_symbols function only contains zend_mark_function_parameter_as_sensitive for functions and will not take all the class entries in parameters. Does it make sense to you ?

As the author of #8352 this certainly makes sense to me, as it makes the API much more comfortable to use (provided that it still works correctly 😃).

@adoy
Copy link
Member Author

adoy commented Jun 10, 2022

@kocsismate FYI this is the future commit for which i'm going to need this feature Curl URL Api

@cmb69
Copy link
Member

cmb69 commented Jun 12, 2022

@kocsismate FYI this is the future commit for which i'm going to need this feature Curl URL Api

FWIW, that would implement https://bugs.php.net/77991.

@TimWolla
Copy link
Member

provided that it still works correctly

#8352 is now merged. There's a test in ext/pdo that checks that the attribute works properly for class methods, so if that one passes it should be good.

@adoy
Copy link
Member Author

adoy commented Jun 13, 2022

I rebased on master and everything seems to work except for indentation. But since it's a separate issue I created an other PR #8765

@adoy adoy force-pushed the add-gen-stub-cond-class branch from bf6e7ed to b8896f4 Compare June 13, 2022 13:05
@adoy adoy force-pushed the add-gen-stub-cond-class branch from b8896f4 to 0dcf681 Compare June 13, 2022 13:13
@adoy
Copy link
Member Author

adoy commented Jun 13, 2022

@kocsismate I rebased on master and regenerated all the files. Everything seems to work well. What do you think about this change ?

@adoy adoy added the Stubs label Jun 13, 2022
@kocsismate
Copy link
Member

rebased on master and regenerated all the files. Everything seems to work well. What do you think about this change ?

There is still issue with the optimizer func info. Please run gen_stub.php --generate-optimizer-info

Copy link
Member

@kocsismate kocsismate left a comment

Choose a reason for hiding this comment

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

Thank you for your work!

@adoy adoy force-pushed the add-gen-stub-cond-class branch from 0dcf681 to 1bcd8d3 Compare June 13, 2022 20:36
@adoy adoy merged commit 1bcd8d3 into php:master Jun 13, 2022
@adoy
Copy link
Member Author

adoy commented Jun 13, 2022

@kocsismate Yep I didn't fixed it on this branch but it's due to the fact that the branch was only rebased on the commit without generation on master. I rebased it and merged it ! Thanks for your review

@adoy adoy deleted the add-gen-stub-cond-class branch June 13, 2022 23:00
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