Skip to content

Commit 6851e13

Browse files
authored
Merge pull request #81 from bjeavons/php84-ci
Add PHP 8.4 to CI and make it compatible
2 parents f6a82ae + dad00ba commit 6851e13

17 files changed

+60
-92
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ jobs:
1212
# - windows-latest # Disabled - apparently checkouts have \r\n which breaks phpcs
1313
- macos-latest
1414
php-versions:
15-
- '7.2'
16-
- '7.3'
1715
- '7.4'
1816
- '8.0'
1917
- '8.1'
18+
- '8.2'
19+
- '8.3'
20+
- '8.4'
2021
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
2122
steps:
2223
- name: Checkout
@@ -39,3 +40,6 @@ jobs:
3940

4041
- name: Unit tests
4142
run: ./vendor/bin/phpunit
43+
44+
- name: PHPStan
45+
run: ./vendor/bin/phpstan analyze

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"require-dev": {
2020
"phpunit/phpunit": "^8.5",
2121
"php-coveralls/php-coveralls": "*",
22-
"squizlabs/php_codesniffer": "3.*"
22+
"squizlabs/php_codesniffer": "3.*",
23+
"phpstan/phpstan": "^2.0"
2324
},
2425
"suggest": {
2526
"ext-gmp": "Required for optimized binomial calculations (also requires PHP >= 7.3)"

phpstan-baseline.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Unsafe usage of new static\(\)\.$#'
5+
identifier: new.static
6+
count: 1
7+
path: src/Matchers/DictionaryMatch.php

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 0
6+
paths:
7+
- src
8+
- test

src/Matchers/BaseMatch.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace ZxcvbnPhp\Matchers;
66

7-
use JetBrains\PhpStorm\ArrayShape;
87
use ZxcvbnPhp\Math\Binomial;
98
use ZxcvbnPhp\Scorer;
109

@@ -48,10 +47,8 @@ public function __construct(string $password, int $begin, int $end, string $toke
4847
*
4948
* @param bool $isSoleMatch
5049
* Whether this is the only match in the password
51-
* @return array
52-
* Associative array with warning (string) and suggestions (array of strings)
50+
* @return array{'warning': string, "suggestions": string[]}
5351
*/
54-
#[ArrayShape(['warning' => 'string', 'suggestions' => 'string[]'])]
5552
abstract public function getFeedback(bool $isSoleMatch): array;
5653

5754
/**

src/Matchers/Bruteforce.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace ZxcvbnPhp\Matchers;
66

7-
use JetBrains\PhpStorm\ArrayShape;
87
use ZxcvbnPhp\Scorer;
98

109
/**
@@ -13,7 +12,7 @@
1312
*
1413
* Intentionally not named with Match suffix to prevent autoloading from Matcher.
1514
*/
16-
class Bruteforce extends BaseMatch
15+
final class Bruteforce extends BaseMatch
1716
{
1817
public const BRUTEFORCE_CARDINALITY = 10;
1918

@@ -32,7 +31,9 @@ public static function match(string $password, array $userInputs = []): array
3231
}
3332

3433

35-
#[ArrayShape(['warning' => 'string', 'suggestions' => 'string[]'])]
34+
/**
35+
* @return array{'warning': string, "suggestions": string[]}
36+
*/
3637
public function getFeedback(bool $isSoleMatch): array
3738
{
3839
return [

src/Matchers/DateMatch.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
namespace ZxcvbnPhp\Matchers;
66

7-
use JetBrains\PhpStorm\ArrayShape;
87
use ZxcvbnPhp\Matcher;
98

10-
class DateMatch extends BaseMatch
9+
final class DateMatch extends BaseMatch
1110
{
1211
public const NUM_YEARS = 119; // Years match against 1900 - 2019
1312
public const NUM_MONTHS = 12;
@@ -108,7 +107,9 @@ public static function match(string $password, array $userInputs = []): array
108107
return $matches;
109108
}
110109

111-
#[ArrayShape(['warning' => 'string', 'suggestions' => 'string[]'])]
110+
/**
111+
* @return array{'warning': string, "suggestions": string[]}
112+
*/
112113
public function getFeedback(bool $isSoleMatch): array
113114
{
114115
return [

src/Matchers/DictionaryMatch.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace ZxcvbnPhp\Matchers;
66

7-
use JetBrains\PhpStorm\ArrayShape;
87
use ZxcvbnPhp\Matcher;
98
use ZxcvbnPhp\Math\Binomial;
109

@@ -88,10 +87,8 @@ public function __construct(string $password, int $begin, int $end, string $toke
8887
}
8988

9089
/**
91-
* @param bool $isSoleMatch
92-
* @return array
90+
* @return array{'warning': string, "suggestions": string[]}
9391
*/
94-
#[ArrayShape(['warning' => 'string', 'suggestions' => 'string[]'])]
9592
public function getFeedback(bool $isSoleMatch): array
9693
{
9794
$startUpper = '/^[A-Z][^A-Z]+$/u';

src/Matchers/L33tMatch.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace ZxcvbnPhp\Matchers;
66

7-
use JetBrains\PhpStorm\ArrayShape;
87
use ZxcvbnPhp\Matcher;
98
use ZxcvbnPhp\Math\Binomial;
109

@@ -98,7 +97,9 @@ public function __construct(string $password, int $begin, int $end, string $toke
9897
}
9998
}
10099

101-
#[ArrayShape(['warning' => 'string', 'suggestions' => 'string[]'])]
100+
/**
101+
* @return array{'warning': string, "suggestions": string[]}
102+
*/
102103
public function getFeedback(bool $isSoleMatch): array
103104
{
104105
$feedback = parent::getFeedback($isSoleMatch);

src/Matchers/RepeatMatch.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace ZxcvbnPhp\Matchers;
66

7-
use JetBrains\PhpStorm\ArrayShape;
87
use ZxcvbnPhp\Matcher;
98
use ZxcvbnPhp\Scorer;
109

11-
class RepeatMatch extends BaseMatch
10+
final class RepeatMatch extends BaseMatch
1211
{
1312
public const GREEDY_MATCH = '/(.+)\1+/u';
1413
public const LAZY_MATCH = '/(.+?)\1+/u';
@@ -85,7 +84,9 @@ public static function match(string $password, array $userInputs = []): array
8584
return $matches;
8685
}
8786

88-
#[ArrayShape(['warning' => 'string', 'suggestions' => 'string[]'])]
87+
/**
88+
* @return array{'warning': string, "suggestions": string[]}
89+
*/
8990
public function getFeedback(bool $isSoleMatch): array
9091
{
9192
$warning = mb_strlen($this->repeatedChar) == 1

0 commit comments

Comments
 (0)