Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Improve support for anonymous classes#28218
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| if ('' ===$message || OutputInterface::VERBOSITY_VERBOSE <=$output->getVerbosity()) { | ||
| $title =sprintf(' [%s%s]',\get_class($e),0 !== ($code =$e->getCode()) ?' ('.$code.')' :''); | ||
| $class =\get_class($e); | ||
| $class ='c' ===$class[0] &&0 ===strpos($class,"class@anonymous\0") ?get_parent_class($class).'@anonymous' :$class; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm curious about\0, I know it represents a null byte, but it's the first time I see it in PHP code.
Does it improve perf or something like that? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You cannot print a null char usingnull as this would result in an empty string 😃
nicolas-grekasAug 25, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
That's desired, see#28218 (comment) (or maybe you mean something else... :))
nicolas-grekas commentedAug 17, 2018 via email
Nothing like that. It's just part of the generated class name for anonymousclasses. |
Kocal commentedAug 17, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Oh okay, thanks 👍 |
da351cd to6380b7dCompare| { | ||
| if (false !==strpos($message,"class@anonymous\0")) { | ||
| $message =preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/',function ($m) { | ||
| return\class_exists($m[0],false) ?get_parent_class($m[0]).'@anonymous' :$m[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
technically this can occur for anon. clases without a parent class.. do we care? Same forsetClass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
yes we do, and this is handled: the result will be just@anonymous, as the VarDumper component already does.
| if (($this->loggedErrors &$type) ||$exceptioninstanceof FatalThrowableError) { | ||
| if (false !==strpos($message =$exception->getMessage(),"class@anonymous\0")) { | ||
| ($message =newFlattenException())->setMessage($message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
naming the temporary variable$message here looks weird, as it does not contain the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed by makingFlattenException fluent.
This PR was merged into the 4.2-dev branch.Discussion----------Improve support for anonymous classes| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -Before:After:Same in other places, e.g. Console failures.Commits-------e41ced2 Improve support for anonymous classes
| { | ||
| $this->statusCode =$code; | ||
| return$this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Do we really need fluent interface here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We don'tneed it. It still makes it easier to use the class.
Uh oh!
There was an error while loading.Please reload this page.
Before:

After:

Same in other places, e.g. Console failures.