-
-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
f99fbbd
[php 8.3] Add json_validate rule
bfd6894
[php 8.3] Add json_validate rule
ebb70d1
[php 8.3] Add json_validate rule
634fb9d
[php 8.3] Add json_validate rule
c640e56
[php 8.3] Add json_validate rule
d73f7bb
[php 8.3] Add json_validate rule
57ff8c0
[php 8.3] Add json_validate rule
4d2be54
[php 8.3] Add json_validate rule
5763420
[php 8.3] Add json_validate rule
70794c6
[php 8.3] Add json_validate rule
e62a32c
[php 8.3] Add json_validate rule
996ff1a
[php 8.3] Add json_validate rule
ebc2672
[php 8.3] Add json_validate rule
cd85f76
[php 8.3] Add json_validate rule
6c975d8
[php 8.3] Add json_validate rule
e23d2c7
[php 8.3] Add json_validate rule
3377025
[php 8.3] Add json_validate rule
be1813a
[php 8.3] Add json_validate rule
cfceaab
[php 8.3] Add json_validate rule
73f0f22
[php 8.3] Add json_validate rule
097388d
[php 8.3] Add json_validate rule
4a94748
[php 8.3] Add json_validate rule
3f78b41
[php 8.3] Add json_validate rule
70d193c
[php 8.3] Add json_validate rule
162a30e
[php 8.3] Add json_validate rule
337c8c2
[php 8.3] Add json_validate rule
e241278
[php 8.3] Add json_validate rule
8a47321
[php 8.3] Add json_validate rule
e9b2512
[php 8.3] Add json_validate rule
a26229b
[php 8.3] Add json_validate rule
0bef253
[php 8.3] Add json_validate rule
3b8c9b2
[8.4][DeprecatedAnnotationToDeprecatedAttributeRector] Remove invalid…
DanielEScherzer e8d6723
[automated] Apply Coding Standard (#7203)
TomasVotruba bf3716b
[Php85] Add ChrArgModuloRector (#7190)
arshidkv12 0424066
Remove removed "Rector\Symfony\Set\FOSRestSetList/JMSSetList/Sensiol…
samsonasik 5dcdd8f
[php 8.3] Add json_validate rule
1259088
[php 8.3] Add json_validate rule
e4412d6
Merge branch 'main' into json_validate
arshidkv12 2ef3815
[php 8.3] Add json_validate rule
c5a036e
[php 8.3] Add json_validate rule
216124c
[php 8.3] Add json_validate rule
04e2ac3
[php 8.3] Add json_validate rule
bfc6cc1
[php 8.3] Add json_validate rule
f9ad159
[php 8.3] Add json_validate rule
77c8a6e
[php 8.3] Add json_validate rule
22de000
[php 8.3] Add json_validate rule
d55c5c4
[php 8.3] Add json_validate rule
6df1782
Merge branch 'rectorphp:main' into json_validate
arshidkv12 5340f45
[php 8.3] Add json_validate rule
a6f77c0
[php 8.3] Add json_validate rule
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
13 changes: 13 additions & 0 deletions
13
...ty/Rector/Class_/InlineConstructorDefaultToPropertyRector/Fixture/skip_complex_assign.php
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,13 @@ | ||
| <?php | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this |
||
|
|
||
| namespace Rector\Tests\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector\Fixture; | ||
|
|
||
| final class SkipComplexAssign | ||
| { | ||
| private $name; | ||
|
|
||
| public function __construct($name) | ||
| { | ||
| $this->name = $name; | ||
| } | ||
| } | ||
17 changes: 17 additions & 0 deletions
17
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/elseif.php.inc
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,17 @@ | ||
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if ($flag) { | ||
| echo "skip"; | ||
| } elseif (json_decode($config, true) !== null && json_last_error() === JSON_ERROR_NONE) { | ||
| echo "valid config"; | ||
| } | ||
| ----- | ||
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if ($flag) { | ||
| echo "skip"; | ||
| } elseif (json_validate($config, true)) { | ||
| echo "valid config"; | ||
| } |
13 changes: 13 additions & 0 deletions
13
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/inline_string.php.inc
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,13 @@ | ||
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode('{"a":1}', true) !== null && json_last_error() === JSON_ERROR_NONE) { | ||
| echo "inline"; | ||
| } | ||
| ----- | ||
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_validate('{"a":1}', true)) { | ||
| echo "inline"; | ||
| } |
17 changes: 17 additions & 0 deletions
17
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/json_flag.php.inc
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,17 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode($json, true, 3) !== null && json_last_error() === JSON_ERROR_NONE){ | ||
| echo 1; | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_validate($json, true, 3)){ | ||
| echo 1; | ||
| } | ||
| ?> |
17 changes: 17 additions & 0 deletions
17
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/json_validate.php.inc
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,17 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE){ | ||
| echo 1; | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_validate($json, true)){ | ||
| echo 1; | ||
| } | ||
| ?> |
17 changes: 17 additions & 0 deletions
17
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/json_validate_base.php.inc
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,17 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode($json, true, 512) !== null && json_last_error() === JSON_ERROR_NONE){ | ||
| echo 1; | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_validate($json, true, 512)){ | ||
| echo 1; | ||
| } | ||
| ?> |
15 changes: 15 additions & 0 deletions
15
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/json_validate_named.php.inc
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,15 @@ | ||
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode(associative: true, json: $json) !== null && json_last_error() === JSON_ERROR_NONE){ | ||
| echo 1; | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_validate(associative: true, json: $json)){ | ||
| echo 1; | ||
| } | ||
| ?> |
15 changes: 15 additions & 0 deletions
15
...tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/json_validate_named_base.php.inc
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,15 @@ | ||
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode(json: $json, associative: true) !== null && json_last_error() === JSON_ERROR_NONE){ | ||
| echo 1; | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_validate(json: $json, associative: true)){ | ||
| echo 1; | ||
| } | ||
| ?> |
17 changes: 17 additions & 0 deletions
17
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/json_validate_yoda.php.inc
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,17 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (null !== json_decode($json) && JSON_ERROR_NONE === json_last_error()){ | ||
| echo 2; | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_validate($json)){ | ||
| echo 2; | ||
| } | ||
| ?> |
17 changes: 17 additions & 0 deletions
17
...-tests/Php83/Rector/BooleanAnd/JsonValidateRector/Fixture/json_validate_yoda_base.php.inc
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,17 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (null !== json_decode($json) && json_last_error() === JSON_ERROR_NONE){ | ||
| echo 1; | ||
| } | ||
| ?> | ||
| ----- | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_validate($json)){ | ||
| echo 1; | ||
| } | ||
| ?> |
8 changes: 8 additions & 0 deletions
8
...ector/BooleanAnd/JsonValidateRector/Fixture/skip_json_validate_invalid_depth.php copy.inc
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,8 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode($json, true, -2) !== null && json_last_error() === JSON_ERROR_NONE){ | ||
| echo 1; | ||
| } | ||
| ?> |
8 changes: 8 additions & 0 deletions
8
...hp83/Rector/BooleanAnd/JsonValidateRector/Fixture/skip_json_validate_invalid_flag.php.inc
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,8 @@ | ||
| <?php | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture; | ||
|
|
||
| if (json_decode(json: $json, associative: true, depth:512, flags: 1) !== null && json_last_error() === JSON_ERROR_NONE){ | ||
| echo 1; | ||
| } | ||
| ?> |
28 changes: 28 additions & 0 deletions
28
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/JsonValidateRectorTest.php
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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector; | ||
|
|
||
| use Iterator; | ||
| use PHPUnit\Framework\Attributes\DataProvider; | ||
| use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
|
||
| final class JsonValidateRectorTest extends AbstractRectorTestCase | ||
| { | ||
| #[DataProvider('provideData')] | ||
| public function test(string $filePath): void | ||
| { | ||
| $this->doTestFile($filePath); | ||
| } | ||
|
|
||
| public static function provideData(): Iterator | ||
| { | ||
| return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
| } | ||
|
|
||
| public function provideConfigFilePath(): string | ||
| { | ||
| return __DIR__ . '/config/configured_rule.php'; | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
rules-tests/Php83/Rector/BooleanAnd/JsonValidateRector/config/configured_rule.php
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,13 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| use Rector\Config\RectorConfig; | ||
| use Rector\Php83\Rector\BooleanAnd\JsonValidateRector; | ||
| use Rector\ValueObject\PhpVersion; | ||
|
|
||
| return static function (RectorConfig $rectorConfig): void { | ||
| $rectorConfig->phpVersion(PhpVersion::PHP_83); | ||
|
|
||
| $rectorConfig->rule(JsonValidateRector::class); | ||
| }; |
Oops, something went wrong.
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.
why? please create separate PR for unrelated change