Completed
Push — master ( f4cd48...0c8693 )
by Eugene
08:29
created

PhpUnitCompat::expectExceptionMessageMatches()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the Tarantool Client package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Tarantool\Client\Tests;
15
16
/**
17
 * A compatibility layer for the legacy PHPUnit 7.
18
 */
19
trait PhpUnitCompat
20
{
21
    public function expectExceptionMessageMatches(string $regularExpression) : void
22
    {
23
        if (is_callable('parent::expectExceptionMessageRegExp')) {
24
            parent::expectExceptionMessageRegExp($regularExpression);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (expectExceptionMessageRegExp() instead of expectExceptionMessageMatches()). Are you sure this is correct? If so, you might want to change this to $this->expectExceptionMessageRegExp().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
25
26
            return;
27
        }
28
29
        parent::expectExceptionMessageMatches($regularExpression);
30
    }
31
}
32