Skip to content

Commit 3d4b978

Browse files
Merge pull request #80 from Hi-Folks/feat/update-packages
Upgrading libraries
2 parents 5b54cd2 + b81f787 commit 3d4b978

9 files changed

+41
-29
lines changed

CHANGELOG.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
## 0.3.0 / 1.0.0 - WIP
3+
## 0.3.0 -2024-08-06
44

5-
- Support for PHP 8.2, PHP 8.1 and PHP 8.0
5+
- Support for PHP 8.3, PHP 8.2, PHP 8.1 and PHP 8.0
6+
- Upgrade Libraries and dependencies
67

78
## 0.2.0 - 2021-07-01
89
### Add
@@ -13,7 +14,7 @@ Special characters are: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
1314

1415
## 0.1.9 - 2021-06-29
1516
### Add
16-
- Add Randomize::chars() for creating string (it is a kind of shortcut for Sequence class);
17+
- Add Randomize::chars() for creating a string (it is a kind of shortcut for Sequence class);
1718

1819

1920
## 0.1.8 - 2021-03-27

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^8.0|^8.1|^8.2"
23+
"php": "^8.0|^8.1|^8.2|^8.3"
2424
},
2525
"require-dev": {
2626
"phpstan/phpstan": "^1.9",
2727
"phpunit/phpunit": "^8.0|^9.3",
28+
"rector/rector": "^1",
2829
"squizlabs/php_codesniffer": "^3.7"
2930
},
3031
"autoload": {
@@ -49,7 +50,6 @@
4950
"format": "vendor/bin/phpcs --standard=PSR12 src",
5051
"formatfix": "vendor/bin/phpcbf --standard=PSR12 src",
5152
"phpstan": "vendor/bin/phpstan"
52-
5353
},
5454
"config": {
5555
"sort-packages": true

rector.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__.'/examples',
10+
__DIR__.'/src',
11+
__DIR__.'/tests',
12+
])
13+
// uncomment to reach your current PHP version
14+
->withPhpSets(
15+
php80: true,
16+
)
17+
->withPreparedSets(
18+
//deadCode: true,
19+
//codeQuality: true,
20+
//earlyReturn: true,
21+
//typeDeclarations: true,
22+
//privatization: true,
23+
// naming: true
24+
);

src/Models/Char.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ public function cleanAsciiCodes(array $array): void
288288

289289
/**
290290
* @return $this
291+
* @phpstan-ignore method.unused
291292
*/
292293
private function transformLower(): self
293294
{
@@ -300,6 +301,7 @@ private function transformLower(): self
300301
}
301302
/**
302303
* @return $this
304+
* @phpstan-ignore method.unused
303305
*/
304306
private function transformUpper(): self
305307
{
@@ -330,7 +332,7 @@ public function generate(): string
330332
$this->addPreset($this->presetAlphaLower);
331333
}
332334
foreach ($this->transformersStack as $transformerCode) {
333-
call_user_func(array($this , $this->transformers[$transformerCode]));
335+
call_user_func([$this, $this->transformers[$transformerCode]]);
334336
}
335337

336338
$rand_index = random_int(0, sizeof($this->ascii_codes) - 1);

src/Models/DateTime.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ public function range(string $min, string $max)
106106
*/
107107
public function generate()
108108
{
109-
return gmdate($this->format, rand($this->min, $this->max));
109+
return gmdate($this->format, random_int($this->min, $this->max));
110110
}
111111
}

src/Models/Integer.php

+1-12
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,13 @@ class Integer
77
public const DEFAULT_MIN = 0;
88
public const DEFAULT_MAX = 100;
99

10-
/**
11-
* @var int
12-
*/
13-
private $min;
14-
/**
15-
* @var int
16-
*/
17-
private $max;
18-
1910
/**
2011
* Integer constructor.
2112
* @param int $min
2213
* @param int $max
2314
*/
24-
public function __construct(int $min = self::DEFAULT_MIN, int $max = self::DEFAULT_MAX)
15+
public function __construct(private int $min = self::DEFAULT_MIN, private int $max = self::DEFAULT_MAX)
2516
{
26-
$this->min = $min;
27-
$this->max = $max;
2817
}
2918

3019

src/Models/LatLong.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function generate()
6767
$result = [];
6868
switch ($this->format) {
6969
case "array":
70-
$result = array($latitude, $longitude);
70+
$result = [$latitude, $longitude];
7171
break;
7272
case "object":
7373
$result = new \stdClass();

src/Models/Sample.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
*/
1212
class Sample
1313
{
14-
/**
15-
* @var array|mixed
16-
*/
17-
private $array;
1814
/**
1915
* @var int
2016
*/
@@ -38,9 +34,8 @@ class Sample
3834
*
3935
* @param int[]|string[]|\stdClass[] $array
4036
*/
41-
public function __construct($array = [])
37+
public function __construct(private $array = [])
4238
{
43-
$this->array = $array;
4439
}
4540

4641
/**
@@ -120,7 +115,7 @@ public function extractKeys()
120115
if (is_array($a)) {
121116
shuffle($a);
122117
}
123-
} catch (\Exception | \Error $e) {
118+
} catch (\Exception | \Error) {
124119
return null;
125120
}
126121

@@ -187,6 +182,8 @@ public function extract()
187182
}
188183
}
189184
if ($this->implode) {
185+
// @TODO implode only for scalar type items
186+
/** @phpstan-ignore-next-line */
190187
return implode(";", $results);
191188
} else {
192189
return $results;

src/Randomize.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ public static function chars($count = 10)
6969
* Return the model registered in $models property
7070
*
7171
* @param string $name
72-
* @param mixed $arguments
7372
* @return mixed
7473
* @throws ModelNotFoundException
7574
*/
76-
public static function __callStatic(string $name, $arguments)
75+
public static function __callStatic(string $name, mixed $arguments)
7776
{
7877
if (in_array($name, array_keys(self::$models))) {
7978
/*

0 commit comments

Comments
 (0)