-
Notifications
You must be signed in to change notification settings - Fork 8k
Improve TypeError messages for non-numeric/empty strings in coercions; Closes #20632 #20639
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
Open
rizwan3d
wants to merge
15
commits into
php:master
Choose a base branch
from
rizwan3d:feature-numaric-string-errors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,222
−1,156
Open
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
422b0c8
Improve TypeError messages for non-numeric/empty strings in coercions
rizwan3d 277f1c6
Update: Unit Test to #20632
rizwan3d 37e97db
Update: Unit Test to php#20632
rizwan3d e7e12e3
Update: Unit Test to php#20632
rizwan3d e0175a9
Update: Unit Test to php#20632
rizwan3d 1a0c4dd
Update: Unit Test to php#20632
rizwan3d 7883185
Update Zend/zend_API.c
rizwan3d dd23d6a
Update: Unit Test to php#20632
rizwan3d f586c76
Update: Unit Test to php#20632
rizwan3d e8dadd5
Update: Unit Test to php#20632
rizwan3d 7ec7d03
Fix 'namaric' typo in zend_zval_numeric_string_value_name() and updat…
rizwan3d 1b9aaac
Use ZVAL_DEREF() in zend_zval_numeric_string_value_name()
rizwan3d 9152f3b
Use is_numeric_string_ex() to avoid mislabelling numeric strings as n…
rizwan3d 9f8a5ca
Use is_numeric_string_ex() to avoid mislabelling numeric strings as n…
rizwan3d f18f611
Update: Unit Test to php#20632
rizwan3d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --TEST-- | ||
| Error message for non-numaric strings in arithmetic contexts | ||
| --FILE-- | ||
| <?php | ||
| declare(strict_types=0); | ||
|
|
||
| function foo(int $a) { echo $a; } | ||
|
|
||
| function msg(TypeError $e){ | ||
| $split = explode(', called in', $e->getMessage(), 2); | ||
| return $split[0]; | ||
| } | ||
|
|
||
| var_dump(1 + "1"); | ||
| try { var_dump(1 + "hello"); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } | ||
| try { var_dump(1 + ""); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } | ||
| try { var_dump("hello" + 1); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } | ||
| try { var_dump("" + 1); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } | ||
|
|
||
| foo("1"); | ||
| echo "\n"; | ||
| try { foo("hello"); } catch (TypeError $e) { echo msg($e), "\n"; } | ||
| try { foo(""); } catch (TypeError $e) { echo msg($e), "\n"; } | ||
| ?> | ||
| ===DONE=== | ||
| --EXPECT-- | ||
| int(2) | ||
| Unsupported operand types: int + non-numeric string | ||
| Unsupported operand types: int + empty string | ||
| Unsupported operand types: non-numeric string + int | ||
| Unsupported operand types: empty string + int | ||
| 1 | ||
| foo(): Argument #1 ($a) must be of type int, non-numeric string given | ||
| foo(): Argument #1 ($a) must be of type int, empty string given | ||
| ===DONE=== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.