-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp81] Downgrade hash algorithm
- Loading branch information
1 parent
850b492
commit be3b498
Showing
13 changed files
with
448 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
28 changes: 28 additions & 0 deletions
28
...1/Rector/FuncCall/DowngradeHashAlgorithmXxHash/DowngradeHashAlgorithmXxHashRectorTest.php
This file contains 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\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class DowngradeHashAlgorithmXxHashRectorTest 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'; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...p81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_configured_value.php.inc
This file contains 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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('xxh3', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('sha1', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
...ngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_constant.php.inc
This file contains 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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash(MHASH_XXH128, 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('md5', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
...hp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_named_arguments.php.inc
This file contains 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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash(algo: 'xxh128', data: 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash(algo: 'md5', data: 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
...FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_named_arguments_false_order.php.inc
This file contains 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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash(data: 'some-data-to-hash', algo: 'xxh128'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash(data: 'some-data-to-hash', algo: 'md5'); | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
...owngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_xxh128.php.inc
This file contains 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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('xxh128', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('md5', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
...DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_xxh32.php.inc
This file contains 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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('xxh32', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('md5', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> |
27 changes: 27 additions & 0 deletions
27
...DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_xxh64.php.inc
This file contains 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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('xxh64', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class Fixture | ||
{ | ||
public function run() | ||
{ | ||
return hash('md5', 'some-data-to-hash'); | ||
} | ||
} | ||
|
||
?> |
11 changes: 11 additions & 0 deletions
11
...p81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/skip_different_func_call.php.inc
This file contains 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,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class SkipDifferentFuncCall | ||
{ | ||
public function run(string $data) | ||
{ | ||
return strlen($data); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...1/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/skip_has_allowed_algorithm.php.inc
This file contains 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,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture; | ||
|
||
class SkipHasAllowedAlgorithm | ||
{ | ||
public function run() | ||
{ | ||
return hash('sha1', 'some-data-to-hash'); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ts/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/config/configured_rule.php
This file contains 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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHashRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->ruleWithConfiguration(DowngradeHashAlgorithmXxHashRector::class, [ | ||
'xxh3' => 'sha1', | ||
]); | ||
}; |
Oops, something went wrong.