-
-
Notifications
You must be signed in to change notification settings - Fork 431
[php 8.3] Add json_validate rule #7200
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
Conversation
vendor/bin/phpstan analyse --ansi ✔
Note: Using configuration file /Users/arshid/Downloads/rector-src/phpstan.neon.
In Resolver.php line 482:
Service 'rules.0' (type of Symplify\PHPStanRules\Rules\NoDynamicNameRule): Service of type Symplify\PHPStanRules\TypeAnalyzer\CallableTypeAnalyzer required by
$callableTypeAnalyzer in NoDynamicNameRule::__construct() not found. Did you add it to configuration file? |
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/config/configured_rule.php
Outdated
Show resolved
Hide resolved
|
Changed the value from 80 to 83 |
| @@ -0,0 +1,15 @@ | |||
| <?php | |||
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.
use lower character on fixture if possible for fixture filnames:
-Json_validate.php.inc
+json_validate.php.incThere 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.
it seems still use upper case fixfture file name, please use lower case
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.
Changed :)
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.
github diff seems still show old name, is this file not removed?
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
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE){ |
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.
this fixture content seems equal with other fixture, seems copy paste content.
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 changed it.
| [ | ||
| new CodeSample( | ||
| <<<'CODE_SAMPLE' | ||
| if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE) { |
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.
json_decode() allow pass depth and flag argument, and from index 1 to 3, they are optional so isset on function arguments per index target is needed.
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode(json: $json, true) !== null && json_last_error() === JSON_ERROR_NONE){ |
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 this goes to be check, add flipped named argument position fixture as well.
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.
Let me check.
Co-authored-by: TomasVotruba <924196+TomasVotruba@users.noreply.github.com>
* Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers * Wrap chr() argument with % 256 to avoid deprecated out-of-range integers --------- Co-authored-by: Arshid <arshid@Arshids-MacBook-Air.local>
…absSetList" usage (rectorphp#7204) * Remove removed "Rector\Symfony\Set\FOSRestSetList" usage * SetList more removal
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_last_error() === JSON_ERROR_NONE && json_decode(associative: true, json: $json) !== null){ |
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.
Checking for a previous json_* calls error should not transform the code.
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.
Ok
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 changed 1259088
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.
The depth and flag value need to check, if not match, just skip as that means possibly different purpose, see polyfill code
| public const DYNAMIC_CLASS_CONST_FETCH = PhpVersion::PHP_83; | ||
|
|
||
| /** | ||
| * @var int |
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.
add @see to wiki for it.
@see https://wiki.php.net/rfc/json_validate
Let me check it. |
|
Ref for downgrade rule that ready as well: |
| { | ||
| foreach ($positions as $position) { | ||
| $arg = $args[$position] ?? ''; | ||
| if ($arg instanceof Arg && $arg->name instanceof Identifier && $arg->name->toString() === 'flags') { |
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.
Actually, you can get arg by name or position via getArg($name, $position)
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.
Thank you
| colors="true" | ||
| executionOrder="defects" | ||
| defaultTestSuite="main" | ||
| stopOnError="true" |
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.
why? please create separate PR for unrelated change
| @@ -0,0 +1,13 @@ | |||
| <?php | |||
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.
this .php fixture file seems commited during cut in the middle run unit test, please revert
| return PhpVersionFeature::DEPRECATE_OUTSIDE_INTERVEL_VAL_IN_CHR_FUNCTION; | ||
| } | ||
| } | ||
| } |
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.
unrelated change, please revert
| 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.
unrelated change, please revert
|
#7213 Apologies for the mistake, corrected now |
rectorphp/rector#9150