Skip to content

Commit

Permalink
Merge pull request #80 from Hi-Folks/feat/update-packages
Browse files Browse the repository at this point in the history
Upgrading libraries
  • Loading branch information
roberto-butti committed Aug 6, 2024
2 parents 5b54cd2 + b81f787 commit 3d4b978
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 29 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->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
);
4 changes: 3 additions & 1 deletion src/Models/Char.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public function cleanAsciiCodes(array $array): void

/**
* @return $this
* @phpstan-ignore method.unused
*/
private function transformLower(): self
{
Expand All @@ -300,6 +301,7 @@ private function transformLower(): self
}
/**
* @return $this
* @phpstan-ignore method.unused
*/
private function transformUpper(): self
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Models/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
13 changes: 1 addition & 12 deletions src/Models/Integer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
2 changes: 1 addition & 1 deletion src/Models/LatLong.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 4 additions & 7 deletions src/Models/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
*/
class Sample
{
/**
* @var array|mixed
*/
private $array;
/**
* @var int
*/
Expand All @@ -38,9 +34,8 @@ class Sample
*
* @param int[]|string[]|\stdClass[] $array
*/
public function __construct($array = [])
public function __construct(private $array = [])
{
$this->array = $array;
}

/**
Expand Down Expand Up @@ -120,7 +115,7 @@ public function extractKeys()
if (is_array($a)) {
shuffle($a);
}
} catch (\Exception | \Error $e) {
} catch (\Exception | \Error) {
return null;
}

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/Randomize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
/*
Expand Down

0 comments on commit 3d4b978

Please sign in to comment.