Passed
Pull Request — master (#50)
by Marco
02:36
created

MethodConcretenessChanged::__invoke()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 2
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\MethodBased;
6
7
use Roave\BackwardCompatibility\Change;
8
use Roave\BackwardCompatibility\Changes;
9
use Roave\BetterReflection\Reflection\ReflectionMethod;
10
use function sprintf;
11
12
/**
13
 * A method that changes from concrete to abstract forces all child class
14
 * implementations to implement it, and is therefore a BC break
15
 */
16
final class MethodConcretenessChanged implements MethodBased
17
{
18
    public function __invoke(ReflectionMethod $fromMethod, ReflectionMethod $toMethod) : Changes
19
    {
20
        if ($fromMethod->isAbstract() || ! $toMethod->isAbstract()) {
21
            return Changes::empty();
22
        }
23
24
        return Changes::fromList(Change::changed(
25
            sprintf(
26
                'Method %s() of class %s changed from concrete to abstract',
27
                $fromMethod->getName(),
28
                $fromMethod->getDeclaringClass()->getName()
29
            ),
30
            true
31
        ));
32
    }
33
}
34