diff --git a/CHANGELOG.md b/CHANGELOG.md index d5ee494..f10ff78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # Changelog -## 0.3.0 / 1.0.0 - WIP +## 0.3.0 -2024-08-06 -- Support for PHP 8.2, PHP 8.1 and PHP 8.0 +- Support for PHP 8.3, PHP 8.2, PHP 8.1 and PHP 8.0 +- Upgrade Libraries and dependencies ## 0.2.0 - 2021-07-01 ### Add @@ -13,7 +14,7 @@ Special characters are: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ## 0.1.9 - 2021-06-29 ### Add -- Add Randomize::chars() for creating string (it is a kind of shortcut for Sequence class); +- Add Randomize::chars() for creating a string (it is a kind of shortcut for Sequence class); ## 0.1.8 - 2021-03-27 diff --git a/composer.json b/composer.json index dd74815..fb0cf0c 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,12 @@ } ], "require": { - "php": "^8.0|^8.1|^8.2" + "php": "^8.0|^8.1|^8.2|^8.3" }, "require-dev": { "phpstan/phpstan": "^1.9", "phpunit/phpunit": "^8.0|^9.3", + "rector/rector": "^1", "squizlabs/php_codesniffer": "^3.7" }, "autoload": { @@ -49,7 +50,6 @@ "format": "vendor/bin/phpcs --standard=PSR12 src", "formatfix": "vendor/bin/phpcbf --standard=PSR12 src", "phpstan": "vendor/bin/phpstan" - }, "config": { "sort-packages": true diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..6f90f87 --- /dev/null +++ b/rector.php @@ -0,0 +1,24 @@ +withPaths([ + __DIR__.'/examples', + __DIR__.'/src', + __DIR__.'/tests', + ]) + // uncomment to reach your current PHP version + ->withPhpSets( + php80: true, + ) + ->withPreparedSets( + //deadCode: true, + //codeQuality: true, + //earlyReturn: true, + //typeDeclarations: true, + //privatization: true, + // naming: true + ); diff --git a/src/Models/Char.php b/src/Models/Char.php index a084989..5000a49 100644 --- a/src/Models/Char.php +++ b/src/Models/Char.php @@ -288,6 +288,7 @@ public function cleanAsciiCodes(array $array): void /** * @return $this + * @phpstan-ignore method.unused */ private function transformLower(): self { @@ -300,6 +301,7 @@ private function transformLower(): self } /** * @return $this + * @phpstan-ignore method.unused */ private function transformUpper(): self { @@ -330,7 +332,7 @@ public function generate(): string $this->addPreset($this->presetAlphaLower); } foreach ($this->transformersStack as $transformerCode) { - call_user_func(array($this , $this->transformers[$transformerCode])); + call_user_func([$this, $this->transformers[$transformerCode]]); } $rand_index = random_int(0, sizeof($this->ascii_codes) - 1); diff --git a/src/Models/DateTime.php b/src/Models/DateTime.php index 1fcf9d8..94f6229 100644 --- a/src/Models/DateTime.php +++ b/src/Models/DateTime.php @@ -106,6 +106,6 @@ public function range(string $min, string $max) */ public function generate() { - return gmdate($this->format, rand($this->min, $this->max)); + return gmdate($this->format, random_int($this->min, $this->max)); } } diff --git a/src/Models/Integer.php b/src/Models/Integer.php index f00fd7c..41fe730 100644 --- a/src/Models/Integer.php +++ b/src/Models/Integer.php @@ -7,24 +7,13 @@ class Integer public const DEFAULT_MIN = 0; public const DEFAULT_MAX = 100; - /** - * @var int - */ - private $min; - /** - * @var int - */ - private $max; - /** * Integer constructor. * @param int $min * @param int $max */ - public function __construct(int $min = self::DEFAULT_MIN, int $max = self::DEFAULT_MAX) + public function __construct(private int $min = self::DEFAULT_MIN, private int $max = self::DEFAULT_MAX) { - $this->min = $min; - $this->max = $max; } diff --git a/src/Models/LatLong.php b/src/Models/LatLong.php index 50f5dba..115b3af 100644 --- a/src/Models/LatLong.php +++ b/src/Models/LatLong.php @@ -67,7 +67,7 @@ public function generate() $result = []; switch ($this->format) { case "array": - $result = array($latitude, $longitude); + $result = [$latitude, $longitude]; break; case "object": $result = new \stdClass(); diff --git a/src/Models/Sample.php b/src/Models/Sample.php index cf4b8ff..5dd7ef1 100644 --- a/src/Models/Sample.php +++ b/src/Models/Sample.php @@ -11,10 +11,6 @@ */ class Sample { - /** - * @var array|mixed - */ - private $array; /** * @var int */ @@ -38,9 +34,8 @@ class Sample * * @param int[]|string[]|\stdClass[] $array */ - public function __construct($array = []) + public function __construct(private $array = []) { - $this->array = $array; } /** @@ -120,7 +115,7 @@ public function extractKeys() if (is_array($a)) { shuffle($a); } - } catch (\Exception | \Error $e) { + } catch (\Exception | \Error) { return null; } @@ -187,6 +182,8 @@ public function extract() } } if ($this->implode) { + // @TODO implode only for scalar type items + /** @phpstan-ignore-next-line */ return implode(";", $results); } else { return $results; diff --git a/src/Randomize.php b/src/Randomize.php index 6388ee1..811a63d 100644 --- a/src/Randomize.php +++ b/src/Randomize.php @@ -69,11 +69,10 @@ public static function chars($count = 10) * Return the model registered in $models property * * @param string $name - * @param mixed $arguments * @return mixed * @throws ModelNotFoundException */ - public static function __callStatic(string $name, $arguments) + public static function __callStatic(string $name, mixed $arguments) { if (in_array($name, array_keys(self::$models))) { /*