-
Notifications
You must be signed in to change notification settings - Fork 585
allow $isOffsetAccessible->maybe() for isUndefinedExpressionAllowed and isSpecified expression
#1312
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
allow $isOffsetAccessible->maybe() for isUndefinedExpressionAllowed and isSpecified expression
#1312
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
64a4f9c
allow `!$isOffsetAccessible->yes()` for isUndefinedExpressionAllowed …
rajyan 30a0aa2
prohibit `$isOffsetAccessible->no()` because these codes are useless …
rajyan 7770a18
allow StrictMixedType as a special case
rajyan 837a13e
Revert "allow StrictMixedType as a special case"
rajyan aeb00d9
fix test, because access on $isOffsetAccessible->maybe() inside isset…
rajyan 8e40eb4
add regression test for https://github.com/phpstan/phpstan/discussion…
rajyan 51aa010
fix test without breaking the intention
rajyan e52071d
keep existing test
rajyan 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace Bug7229; | ||
|
|
||
| class Config | ||
| { | ||
| // HINTS: a config comes from a config file which always will be an array. | ||
| // E.g: return require 'config.php'; // => array<int|string, mixed> | ||
| // where mixed is rather the short write for scalar|array<mixed>|null which | ||
| // can be nested in N-depth (merging several configs) | ||
|
|
||
| /** | ||
| * Returns the value from the given array. | ||
| * | ||
| * @param array<int|string, mixed>|mixed $config The array to search in | ||
| * @param array<int|string, string> $parts Parts to look for inside the array | ||
| * | ||
| * @return array<int|string, mixed>|mixed Found value or null if not available | ||
| */ | ||
| protected function _getValueFromArray( $config, $parts ) | ||
| { | ||
| // $config type is mixed or array !? | ||
|
|
||
| if ( ( $key = array_shift( $parts ) ) !== null && isset( $config[$key] ) ) { | ||
|
|
||
| // $config type NOT mixed | ||
|
|
||
| if ( count( $parts ) > 0 ) { | ||
| return $this->_getValueFromArray( $config[$key], $parts ); | ||
| } | ||
|
|
||
| return $config[$key]; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } |
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.
Leftover Debug output?
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.
No, I just wanted to change this line to some kind of function call that doesn’t cause
isUndefinedExpressionAllowed === true(that means something exceptisset, unset, empty)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.
Please add new code instead of changing existing tests :) Thanks.