Completed
Push — master ( 53faed...4a3ff7 )
by Eugene
07:16
created

PhpUnitCompat::assertEqualsCanonicalizing()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 6
rs 10
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
 * Compatibility layer for legacy PHPUnit versions.
18
 */
19
trait PhpUnitCompat
20
{
21
    /**
22
     * TestCase::expectExceptionMessageRegExp() is deprecated since PHPUnit 8.4.
23
     */
24
    public function expectExceptionMessageMatches(string $regularExpression) : void
0 ignored issues
show
Unused Code introduced by
The parameter $regularExpression is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
    {
26
        is_callable('parent::expectExceptionMessageMatches')
27
            ? parent::expectExceptionMessageMatches(...func_get_args())
28
            : parent::expectExceptionMessageRegExp(...func_get_args());
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...
29
    }
30
31
    /**
32
     * Assert::assertEquals()'s $delta, $maxDepth, $canonicalize parameters are deprecated since PHPUnit 8.0.
33
     */
34
    public static function assertEqualsCanonicalizing($expected, $actual, string $message = '') : void
35
    {
36
        is_callable('parent::assertEqualsCanonicalizing')
37
            ? parent::assertEqualsCanonicalizing($expected, $actual, $message)
38
            : parent::assertEquals($expected, $actual, $message, 0.0, 10, true);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertEquals() instead of assertEqualsCanonicalizing()). Are you sure this is correct? If so, you might want to change this to $this->assertEquals().

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...
39
    }
40
41
    /**
42
     * Assert::assertRegExp() is deprecated since PHPUnit 9.1.
43
     */
44
    public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = '') : void
0 ignored issues
show
Unused Code introduced by
The parameter $pattern is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $string is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $message is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        is_callable('parent::assertMatchesRegularExpression')
47
            ? parent::assertMatchesRegularExpression(...func_get_args())
48
            : parent::assertRegExp(...func_get_args());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertRegExp() instead of assertMatchesRegularExpression()). Are you sure this is correct? If so, you might want to change this to $this->assertRegExp().

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...
49
    }
50
}
51