-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Convert iterable into an internal alias for Traversable|array #7309
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
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5391d70
Convert iterable into an internal alias for Traversable|array
Girgias ca2d21b
BC support for Reflection
Girgias 842c34f
Fix variance
Girgias 905510b
Use unused type bit for flagging iterable
Girgias b00a2a6
Fix slightly union types Reflection test
Girgias fd55485
Point to iterable for incompatible type in intersection
Girgias e427ef8
Fix iterable type for internal functions
Girgias 3635821
Start of a working stub generation
Girgias 3a9326a
Possibly generic handling of types?
Girgias 280cbf0
Ammend test3
Girgias 1ff4c99
Use iterable instead of array|Traversable when usage of single type
Girgias fd14604
Handle iterable in complex union types
Girgias fcecc29
Fix opcache test
Girgias 8b548a2
Address review and drop BC shim for unions
Girgias 569ca2c
Remove shim for iterable BC
Girgias 39b2258
Make invalid types in intersection more robust
Girgias 307b663
Fix opcache test
Girgias 37b7141
Check for legacy iterable arg_info during function registration
Girgias f29b2c7
Warn also if return type is iterable
Girgias 8b479f0
Do not test statup in effect
Girgias cc0291c
Do not warn but enable legacy cnbversion test
Girgias bbdb793
Reflection iterable BC for named types
Girgias be44175
Nit + whitespaces
Girgias e0bf71b
Address review comments
Girgias 78129bd
Whitespace revert + code move revert
Girgias ae53b04
Do not memcpy when not needed
Girgias d4056a9
Do not use UNION bit for iterable as it is not a type list
Girgias 9adcadc
last whitespaces reverts
Girgias 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--TEST-- | ||
Test "or null"/"or be null" in type-checking errors for userland functions with iterable | ||
--FILE-- | ||
<?php | ||
|
||
// This should test every branch in zend_execute.c's `zend_verify_arg_type`, `zend_verify_return_type` and `zend_verify_missing_return_type` functions which produces an "or null"/"or be null" part in its error message | ||
|
||
function iterableF(?iterable $param) {} | ||
try { | ||
iterableF(1); | ||
} catch (\TypeError $e) { | ||
echo $e, PHP_EOL; | ||
} | ||
|
||
function returnIterable(): ?iterable { | ||
return 1; | ||
} | ||
|
||
try { | ||
returnIterable(); | ||
} catch (\TypeError $e) { | ||
echo $e, PHP_EOL; | ||
} | ||
|
||
function returnMissingIterable(): ?iterable { | ||
} | ||
|
||
try { | ||
returnMissingIterable(); | ||
} catch (\TypeError $e) { | ||
echo $e, PHP_EOL; | ||
} | ||
?> | ||
--EXPECTF-- | ||
TypeError: iterableF(): Argument #1 ($param) must be of type Traversable|array|null, int given, called in %s on line %d and defined in %s:%d | ||
Stack trace: | ||
#0 %s(%d): iterableF(1) | ||
#1 {main} | ||
TypeError: returnIterable(): Return value must be of type Traversable|array|null, int returned in %s:%d | ||
Stack trace: | ||
#0 %s(%d): returnIterable() | ||
#1 {main} | ||
TypeError: returnMissingIterable(): Return value must be of type Traversable|array|null, none returned in %s:%d | ||
Stack trace: | ||
#0 %s(%d): returnMissingIterable() | ||
#1 {main} |
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
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.
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 could warn only in
ZEND_DEBUG
.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 can't as this is an extension loading warning, so if zend_test is loaded it will emit this warning on every single test