Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Fix exceptions (PDOException) error code type#33713
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
fabpot left a comment
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.
If the code can be a string, maybe we can change the type hint and allow a string everywhere? Casting to a string means that strings will always be converted to 0, right? Not sure if this is a problem though.
src/Symfony/Component/Messenger/Tests/Exception/HandlerFailedExceptionTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
ed-fruty commentedSep 25, 2019
We can't allow php -aphp>$e = new Exception('message','string');PHP Warning: Uncaught Error: Wrong parametersforException([string $message [, long $code [, Throwable $previous = NULL]]])in php shell code:1Stack trace:#0 php shell code(1): Exception->__construct('message', 'string')#1 {main} thrownin php shell code on line 1 PHP does not allow it. |
fabpot commentedSep 26, 2019
Thank you@ed-fruty. |
f3a9850 to9efa025CompareThis PR was squashed before being merged into the 4.3 branch (closes#33713).Discussion----------Fix exceptions (PDOException) error code type| Q | A| ------------- | ---| Branch? | 4.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#33704| License | MITFrom the [php.net docs](https://www.php.net/manual/en/exception.getcode.php) `Exception::getCode()` description:> Returns the exception code as integer in Exception but possibly as other type in Exception descendants (for example as **string** in PDOException).So if can be string, we convert it to the int in the `HandlerFailedException` but it still string in `nestedExceptiions`.Commits-------9efa025 Fix exceptions (PDOException) error code type
From thephp.net docs
Exception::getCode()description:So if can be string, we convert it to the int in the
HandlerFailedExceptionbut it still string innestedExceptiions.