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

modernize ErrorException example code #2782

Merged
merged 8 commits into from
Sep 25, 2023
Merged

Conversation

divinity76
Copy link
Contributor

@divinity76 divinity76 commented Sep 22, 2023

IMO the old example should have been

set_error_handler(__NAMESPACE__ . "\\exception_error_handler");

so it would work in any namespace, because the old example just worked in the global namespace, and crashed-at-runtime if used in any other namespace, but as of PHP8.1.0 we have an even better way to do it: set_error_handler(exception_error_handler(...));

IMO the old example should have been 

set_error_handler(__NAMESPACE__ . "\\exception_error_handler");

so it would work in any namespace, instead of just working in the global namespace, and crash-at-runtime if used in any other namespace, 
but as of PHP8.1.0 we have an even better way to do it: set_error_handler(exception_error_handler(...));
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

I'm not sure I actually like the variable name changes but that's somewhat whatever

language/predefined/errorexception.xml Outdated Show resolved Hide resolved
language/predefined/errorexception.xml Outdated Show resolved Hide resolved
@divinity76
Copy link
Contributor Author

divinity76 commented Sep 23, 2023

I'm not sure I actually like the variable name changes but that's somewhat whatever

That was actually fixing a consistency issue - other parts of the documentation uses the variable names I switched to here. (Am on phone right now so cba finding out where in the docs, but shouldn't be hard to find)

Edit: I think it's the set_error_handler documentation.

@Girgias
Copy link
Member

Girgias commented Sep 25, 2023

I'm not sure I actually like the variable name changes but that's somewhat whatever

That was actually fixing a consistency issue - other parts of the documentation uses the variable names I switched to here. (Am on phone right now so cba finding out where in the docs, but shouldn't be hard to find)

Edit: I think it's the set_error_handler documentation.

Right, consistency is best.

@Girgias Girgias merged commit e6376e0 into php:master Sep 25, 2023
@Girgias
Copy link
Member

Girgias commented Sep 25, 2023

Thank you!

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