Skip to content

Commit 634fb9d

Browse files
ArshidArshid
authored andcommitted
[php 8.3] Add json_validate rule
1 parent ebb70d1 commit 634fb9d

8 files changed

Lines changed: 15 additions & 16 deletions

File tree

config/set/php83.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6+
use Rector\Php83\Rector\BooleanAnd\JsonValidateRector;
67
use Rector\Php83\Rector\Class_\ReadOnlyAnonymousClassRector;
78
use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;
89
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
@@ -18,5 +19,6 @@
1819
RemoveGetClassGetParentClassNoArgsRector::class,
1920
ReadOnlyAnonymousClassRector::class,
2021
DynamicClassConstFetchRector::class,
22+
JsonValidateRector::class
2123
]);
2224
};

rules-tests/Php83/Rector/BooleanAnd/JsonValidate/Fixture/Json_validate.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
2-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate\Fixture;
2+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture;
33

44
if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE){
55
echo 1;
66
}
77
?>
88
-----
99
<?php
10-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate\Fixture;
10+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture;
1111

1212
if (json_validate($json)){
1313
echo 1;

rules-tests/Php83/Rector/BooleanAnd/JsonValidate/Fixture/Json_validate_named.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
2-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate\Fixture;
2+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture;
33

44
if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE){
55
echo 1;
66
}
77
?>
88
-----
99
<?php
10-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate\Fixture;
10+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture;
1111

1212
if (json_validate($json)){
1313
echo 1;

rules-tests/Php83/Rector/BooleanAnd/JsonValidate/Fixture/elseif.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate\Fixture;
2+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture;
33

44
if ($flag) {
55
echo "skip";
@@ -8,7 +8,7 @@ if ($flag) {
88
}
99
-----
1010
<?php
11-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate\Fixture;
11+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture;
1212

1313
if ($flag) {
1414
echo "skip";

rules-tests/Php83/Rector/BooleanAnd/JsonValidate/Fixture/inline_string.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
2-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate\Fixture;
2+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture;
33

44
if (json_decode('{"a":1}', true) !== null && json_last_error() === JSON_ERROR_NONE) {
55
echo "inline";
66
}
77
-----
88
<?php
9-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate\Fixture;
9+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector\Fixture;
1010

1111
if (json_validate('{"a":1}')) {
1212
echo "inline";

rules-tests/Php83/Rector/BooleanAnd/JsonValidate/JsonValidateTest.php renamed to rules-tests/Php83/Rector/BooleanAnd/JsonValidate/JsonValidateRectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidate;
5+
namespace Rector\Tests\Php83\Rector\BooleanAnd\JsonValidateRector;
66

77
use Iterator;
88
use PHPUnit\Framework\Attributes\DataProvider;
99
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
1010

11-
final class JsonValidateTest extends AbstractRectorTestCase
11+
final class JsonValidateRectorTest extends AbstractRectorTestCase
1212
{
1313
#[DataProvider('provideData')]
1414
public function test(string $filePath): void

rules-tests/Php83/Rector/BooleanAnd/JsonValidate/config/configured_rule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Php83\Rector\BooleanAnd\JsonValidate;
6+
use Rector\Php83\Rector\BooleanAnd\JsonValidateRector;
77
use Rector\ValueObject\PhpVersion;
88

99
return static function (RectorConfig $rectorConfig): void {
1010
$rectorConfig->phpVersion(PhpVersion::PHP_80);
1111

12-
$rectorConfig->rule(JsonValidate::class);
12+
$rectorConfig->rule(JsonValidateRector::class);
1313
};

rules/Php83/Rector/BooleanAnd/JsonValidate.php renamed to rules/Php83/Rector/BooleanAnd/JsonValidateRector.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222
/**
2323
* @see \Rector\Tests\Php80\Rector\BooleanAnd\JsonValidate\JsonValidateTest
2424
*/
25-
final class JsonValidate extends AbstractRector implements MinPhpVersionInterface, RelatedPolyfillInterface
25+
final class JsonValidateRector extends AbstractRector implements MinPhpVersionInterface, RelatedPolyfillInterface
2626
{
27-
public function __construct()
28-
{
29-
}
3027

3128
public function provideMinPhpVersion(): int
3229
{

0 commit comments

Comments
 (0)