[php 8.3] Add json_validate rule#7200
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.
use lower character on fixture if possible for fixture filnames:
-Json_validate.php.inc
+json_validate.php.incThere was a problem hiding this comment.
it seems still use upper case fixfture file name, please use lower case
There was a problem hiding this comment.
github diff seems still show old name, is this file not removed?
| <?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.
this fixture content seems equal with other fixture, seems copy paste content.
| [ | ||
| new CodeSample( | ||
| <<<'CODE_SAMPLE' | ||
| if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE) { |
There was a problem hiding this comment.
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.
if this goes to be check, add flipped named argument position fixture as well.
…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.
Checking for a previous json_* calls error should not transform the code.
| public const DYNAMIC_CLASS_CONST_FETCH = PhpVersion::PHP_83; | ||
|
|
||
| /** | ||
| * @var int |
There was a problem hiding this comment.
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.
Actually, you can get arg by name or position via getArg($name, $position)
| colors="true" | ||
| executionOrder="defects" | ||
| defaultTestSuite="main" | ||
| stopOnError="true" |
There was a problem hiding this comment.
why? please create separate PR for unrelated change
| @@ -0,0 +1,13 @@ | |||
| <?php | |||
There was a problem hiding this comment.
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; | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
unrelated change, please revert
| return $this; | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
unrelated change, please revert
|
#7213 Apologies for the mistake, corrected now |
|
This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work. |
rectorphp/rector#9150