15
15
16
16
class BaseTestCase extends TestCase
17
17
{
18
- /** @var string */
19
- protected $ pregFunction ;
18
+ /** @var string|null */
19
+ protected $ pregFunction = null ;
20
20
21
21
/**
22
22
* @param class-string<\Exception> $class
@@ -27,7 +27,7 @@ protected function doExpectException($class, $message = null)
27
27
{
28
28
if (method_exists ($ this , 'expectException ' )) {
29
29
$ this ->expectException ($ class );
30
- if ($ message ) {
30
+ if (null !== $ message ) {
31
31
$ this ->expectExceptionMessage ($ message );
32
32
}
33
33
} else {
@@ -69,11 +69,11 @@ protected function expectPcreEngineException($pattern)
69
69
*/
70
70
protected function expectPcreException ($ pattern , $ error = null )
71
71
{
72
- if (! $ this ->pregFunction ) {
72
+ if (null === $ this ->pregFunction ) {
73
73
$ this ->fail ('Preg function name is missing ' );
74
74
}
75
75
76
- if (! $ error ) {
76
+ if (null !== $ error ) {
77
77
// Only use a message if the error can be reliably determined
78
78
if (PHP_VERSION_ID >= 80000 ) {
79
79
$ error = 'Internal error ' ;
@@ -82,7 +82,7 @@ protected function expectPcreException($pattern, $error = null)
82
82
}
83
83
}
84
84
85
- if ($ error ) {
85
+ if (null !== $ error ) {
86
86
$ message = sprintf ('%s: failed executing "%s": %s ' , $ this ->pregFunction , $ pattern , $ error );
87
87
} else {
88
88
$ message = null ;
@@ -97,11 +97,11 @@ protected function expectPcreException($pattern, $error = null)
97
97
*/
98
98
protected function expectPcreWarning ($ warning = null )
99
99
{
100
- if (! $ this ->pregFunction ) {
100
+ if (null === $ this ->pregFunction ) {
101
101
$ this ->fail ('Preg function name is missing ' );
102
102
}
103
103
104
- $ warning = $ warning ? : 'No ending matching delimiter \'} \' found ' ;
104
+ $ warning = $ warning !== null ? $ warning : 'No ending matching delimiter \'} \' found ' ;
105
105
$ message = sprintf ('%s: %s ' , $ this ->pregFunction , $ warning );
106
106
$ this ->doExpectWarning ($ message );
107
107
}
0 commit comments