Skip to content
Closed
Show file tree
Hide file tree
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
Aug 30, 2025
bfd6894
[php 8.3] Add json_validate rule
Aug 30, 2025
ebb70d1
[php 8.3] Add json_validate rule
Aug 30, 2025
634fb9d
[php 8.3] Add json_validate rule
Aug 30, 2025
c640e56
[php 8.3] Add json_validate rule
Aug 30, 2025
d73f7bb
[php 8.3] Add json_validate rule
Aug 30, 2025
57ff8c0
[php 8.3] Add json_validate rule
Aug 30, 2025
4d2be54
[php 8.3] Add json_validate rule
Aug 30, 2025
5763420
[php 8.3] Add json_validate rule
Aug 30, 2025
70794c6
[php 8.3] Add json_validate rule
Aug 30, 2025
e62a32c
[php 8.3] Add json_validate rule
Aug 30, 2025
996ff1a
[php 8.3] Add json_validate rule
Aug 30, 2025
ebc2672
[php 8.3] Add json_validate rule
Aug 30, 2025
cd85f76
[php 8.3] Add json_validate rule
Aug 30, 2025
6c975d8
[php 8.3] Add json_validate rule
Aug 30, 2025
e23d2c7
[php 8.3] Add json_validate rule
Aug 30, 2025
3377025
[php 8.3] Add json_validate rule
Aug 30, 2025
be1813a
[php 8.3] Add json_validate rule
Aug 30, 2025
cfceaab
[php 8.3] Add json_validate rule
Aug 30, 2025
73f0f22
[php 8.3] Add json_validate rule
Aug 30, 2025
097388d
[php 8.3] Add json_validate rule
Aug 30, 2025
4a94748
[php 8.3] Add json_validate rule
Aug 30, 2025
3f78b41
[php 8.3] Add json_validate rule
Aug 30, 2025
70d193c
[php 8.3] Add json_validate rule
Aug 30, 2025
162a30e
[php 8.3] Add json_validate rule
Sep 1, 2025
337c8c2
[php 8.3] Add json_validate rule
Sep 1, 2025
e241278
[php 8.3] Add json_validate rule
Sep 1, 2025
8a47321
[php 8.3] Add json_validate rule
Sep 1, 2025
e9b2512
[php 8.3] Add json_validate rule
Sep 1, 2025
a26229b
[php 8.3] Add json_validate rule
Sep 1, 2025
0bef253
[php 8.3] Add json_validate rule
Sep 1, 2025
3b8c9b2
[8.4][DeprecatedAnnotationToDeprecatedAttributeRector] Remove invalid…
DanielEScherzer Aug 30, 2025
e8d6723
[automated] Apply Coding Standard (#7203)
TomasVotruba Aug 31, 2025
bf3716b
[Php85] Add ChrArgModuloRector (#7190)
arshidkv12 Aug 31, 2025
0424066
Remove removed "Rector\Symfony\Set\FOSRestSetList/JMSSetList/Sensiol…
samsonasik Sep 1, 2025
5dcdd8f
[php 8.3] Add json_validate rule
Sep 1, 2025
1259088
[php 8.3] Add json_validate rule
Sep 1, 2025
e4412d6
Merge branch 'main' into json_validate
arshidkv12 Sep 1, 2025
2ef3815
[php 8.3] Add json_validate rule
Sep 2, 2025
c5a036e
[php 8.3] Add json_validate rule
Sep 2, 2025
216124c
[php 8.3] Add json_validate rule
Sep 2, 2025
04e2ac3
[php 8.3] Add json_validate rule
Sep 3, 2025
bfc6cc1
[php 8.3] Add json_validate rule
Sep 3, 2025
f9ad159
[php 8.3] Add json_validate rule
Sep 3, 2025
77c8a6e
[php 8.3] Add json_validate rule
Sep 3, 2025
22de000
[php 8.3] Add json_validate rule
Sep 3, 2025
d55c5c4
[php 8.3] Add json_validate rule
Sep 3, 2025
6df1782
Merge branch 'rectorphp:main' into json_validate
arshidkv12 Sep 3, 2025
5340f45
[php 8.3] Add json_validate rule
Sep 3, 2025
a6f77c0
[php 8.3] Add json_validate rule
Sep 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/set/php83.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php83\Rector\BooleanAnd\JsonValidateRector;
use Rector\Php83\Rector\Class_\ReadOnlyAnonymousClassRector;
use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
Expand All @@ -18,5 +19,6 @@
RemoveGetClassGetParentClassNoArgsRector::class,
ReadOnlyAnonymousClassRector::class,
DynamicClassConstFetchRector::class,
JsonValidateRector::class,
]);
};
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
colors="true"
executionOrder="defects"
defaultTestSuite="main"
stopOnError="true"
Copy link
Member

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

displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
Copy link
Member

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


namespace Rector\Tests\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector\Fixture;

final class SkipComplexAssign
{
private $name;

public function __construct($name)
{
$this->name = $name;
}
}
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";
}
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";
}
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;
}
?>
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;
}
?>
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;
}
?>
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;
}
?>
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;
}
?>
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;
}
?>
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;
}
?>
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;
}
?>
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;
}
?>
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';
}
}
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);
};
Loading
Loading