Skip to content

Commit bb6cb84

Browse files
committed
Use PHPStan strict rules
1 parent d827339 commit bb6cb84

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
},
2222
"require-dev": {
2323
"symfony/phpunit-bridge": "^4.2 || ^5",
24-
"phpstan/phpstan": "^1"
24+
"phpstan/phpstan": "^1",
25+
"phpstan/phpstan-strict-rules": "^1.1"
2526
},
2627
"autoload": {
2728
"psr-4": {

phpstan.neon.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ parameters:
33
paths:
44
- src
55
- tests
6+
7+
includes:
8+
- vendor/phpstan/phpstan-strict-rules/rules.neon

tests/BaseTestCase.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
class BaseTestCase extends TestCase
1717
{
18-
/** @var string */
19-
protected $pregFunction;
18+
/** @var string|null */
19+
protected $pregFunction = null;
2020

2121
/**
2222
* @param class-string<\Exception> $class
@@ -27,7 +27,7 @@ protected function doExpectException($class, $message = null)
2727
{
2828
if (method_exists($this, 'expectException')) {
2929
$this->expectException($class);
30-
if ($message) {
30+
if (null !== $message) {
3131
$this->expectExceptionMessage($message);
3232
}
3333
} else {
@@ -69,11 +69,11 @@ protected function expectPcreEngineException($pattern)
6969
*/
7070
protected function expectPcreException($pattern, $error = null)
7171
{
72-
if (!$this->pregFunction) {
72+
if (null === $this->pregFunction) {
7373
$this->fail('Preg function name is missing');
7474
}
7575

76-
if (!$error) {
76+
if (null !== $error) {
7777
// Only use a message if the error can be reliably determined
7878
if (PHP_VERSION_ID >= 80000) {
7979
$error = 'Internal error';
@@ -82,7 +82,7 @@ protected function expectPcreException($pattern, $error = null)
8282
}
8383
}
8484

85-
if ($error) {
85+
if (null !== $error) {
8686
$message = sprintf('%s: failed executing "%s": %s', $this->pregFunction, $pattern, $error);
8787
} else {
8888
$message = null;
@@ -97,11 +97,11 @@ protected function expectPcreException($pattern, $error = null)
9797
*/
9898
protected function expectPcreWarning($warning = null)
9999
{
100-
if (!$this->pregFunction) {
100+
if (null === $this->pregFunction) {
101101
$this->fail('Preg function name is missing');
102102
}
103103

104-
$warning = $warning ?: 'No ending matching delimiter \'}\' found';
104+
$warning = $warning !== null ? $warning : 'No ending matching delimiter \'}\' found';
105105
$message = sprintf('%s: %s', $this->pregFunction, $warning);
106106
$this->doExpectWarning($message);
107107
}

0 commit comments

Comments
 (0)