Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Commit 3a4038b

Browse files
committed
fix: cs for php8.0
1 parent 39e4975 commit 3a4038b

8 files changed

+13
-42
lines changed

src/Arrays/ArrayExtractor.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99

1010
class ArrayExtractor
1111
{
12-
private array $model;
13-
14-
private function __construct(array $model)
12+
private function __construct(private array $model)
1513
{
16-
$this->model = $model;
1714
}
1815

1916
public static function withModel(array $model): self

src/Arrays/ArrayKeysCamelCaseConverter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function convertArrayKeys(array $arrayItems): array
2020
$value = self::convertArrayKeys($value);
2121
}
2222

23-
if (is_string($key) && strpos($key, '_') !== false) {
23+
if (is_string($key) && str_contains($key, '_')) {
2424
$key = CaseConverter::toCamelCase($key);
2525
}
2626

src/Arrays/TagAndAttributeRemover.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,10 @@
2626

2727
class TagAndAttributeRemover
2828
{
29-
private DOMDocument $domHtml;
30-
private array $allowedTags;
31-
private array $currentTags;
32-
private array $allowedUrlPrefixes;
3329
private static array $urlAttributes = ['href', 'src'];
3430

35-
private function __construct(DOMDocument $domHtml, array $currentTags, array $allowedTags, array $allowedUrlPrefixes)
31+
private function __construct(private DOMDocument $domHtml, private array $currentTags, private array $allowedTags, private array $allowedUrlPrefixes)
3632
{
37-
$this->domHtml = $domHtml;
38-
$this->currentTags = $currentTags;
39-
$this->allowedTags = $allowedTags;
40-
$this->allowedUrlPrefixes = $allowedUrlPrefixes;
4133
}
4234

4335
public static function cleanHtml(string $html, string $allowedTagsAndAttributesList, ?string $allowedUrlPrefixes = ''): string
@@ -66,7 +58,7 @@ public static function cleanHtml(string $html, string $allowedTagsAndAttributesL
6658

6759
private static function safeExplodeString(string $delimiter, string $string, ?bool $allowEmptyArrayElement = true): array
6860
{
69-
if (strpos($string, $delimiter) !== false) {
61+
if (str_contains($string, $delimiter)) {
7062
return explode($delimiter, $string);
7163
}
7264

@@ -154,7 +146,7 @@ private function removeAttributesWithNotAllowedUrlPrefixes(DOMElement $node, DOM
154146
{
155147
$isAllowed = 0;
156148
foreach ($this->allowedUrlPrefixes as $allowedUrlPrefix) {
157-
if (strpos($attribute->nodeValue, $allowedUrlPrefix) === 0) {
149+
if (str_starts_with($attribute->nodeValue, $allowedUrlPrefix)) {
158150
$isAllowed = 1;
159151
break;
160152
}

src/EqualsBuilder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
final class EqualsBuilder
1616
{
17-
private $isEquals = true;
17+
private bool $isEquals = true;
1818

1919
public static function create(): EqualsBuilder
2020
{
@@ -55,7 +55,7 @@ private function checkIfValuesAreAnObjectAndEqual($leftHandedValue, $rightHanded
5555
return false;
5656
}
5757

58-
if (get_class($leftHandedValue) !== get_class($rightHandedValue)) {
58+
if ($leftHandedValue::class !== $rightHandedValue::class) {
5959
$this->isEquals = false;
6060

6161
return false;

src/Pipeline/Pipeline.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
use Psr\Container\ContainerInterface;
88
use Selami\Stdlib\Resolver;
99
use ReflectionClass;
10-
use function PHPUnit\Framework\isInstanceOf;
1110

1211
class Pipeline implements PipelineInterface
1312
{
14-
private ?ContainerInterface $container;
1513
private array $stages = [];
1614

17-
private function __construct(?ContainerInterface $container = null)
15+
private function __construct(private ?\Psr\Container\ContainerInterface $container = null)
1816
{
19-
$this->container = $container;
2017
}
2118

2219
public static function new(): self

src/Resolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function getParameterHints(string $className, string $methodName):
3131
self::checkMethodName($className, $methodName);
3232
try {
3333
$method = new ReflectionMethod($className, $methodName);
34-
} catch (ReflectionException $e) {
34+
} catch (ReflectionException) {
3535
throw new ClassOrMethodCouldNotBeFound(
3636
sprintf('%s::%s coulnd not be found.', $className, $methodName)
3737
);

src/Semver.php

+1-9
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,9 @@
1515
final class Semver
1616
{
1717
private static string $semverPattern = '/(\d+).(\d+).(\d+)(|[-.+](?:dev|alpha|beta|rc|stable)(.*?))$/i';
18-
private int $major;
19-
private int $minor;
20-
private int $patch;
21-
private ?string $preRelease;
2218

23-
private function __construct(int $major, int $minor, int $patch, ?string $preRelease = null)
19+
private function __construct(private int $major, private int $minor, private int $patch, private ?string $preRelease = null)
2420
{
25-
$this->major = $major;
26-
$this->minor = $minor;
27-
$this->patch = $patch;
28-
$this->preRelease = $preRelease;
2921
}
3022

3123
public static function createFromString(string $version): self

src/Slugifier.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,27 @@
99

1010
class Slugifier
1111
{
12-
/**
13-
* @var string|array $subject
14-
*/
15-
private $subject;
16-
1712
private Transliterator $transliterator;
1813
/**
1914
* @param string|iterable $subject
2015
*/
21-
private function __construct($subject)
16+
private function __construct(private $subject)
2217
{
23-
$this->subject = $subject;
2418
$this->transliterator = Transliterator::create('Any-Latin; Latin-ASCII');
2519
}
2620
/**
2721
* @param mixed<string|iterable> $subject
2822
* @return string|iterable<string>
2923
*/
30-
public static function slugify($subject)
24+
public static function slugify(mixed $subject): string|iterable
3125
{
3226
return (new self($subject))
3327
->getSlugifiedResult();
3428
}
3529
/**
3630
* @return string|iterable<string>
3731
*/
38-
private function getSlugifiedResult()
32+
private function getSlugifiedResult(): string|iterable
3933
{
4034
if (is_iterable($this->subject)) {
4135
return $this->getSlugifiedIterable($this->subject);
@@ -57,7 +51,6 @@ private function getSlugifiedString($subject) : string
5751
}
5852

5953
/**
60-
* @param iterable $subject
6154
* @return iterable<string>
6255
*/
6356
private function getSlugifiedIterable(iterable $subject) : iterable

0 commit comments

Comments
 (0)