Conditions | 8 |
Paths | 3 |
Total Lines | 46 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function compare(ClassReflector $oldApi, ClassReflector $newApi): array |
||
12 | { |
||
13 | $changelog = []; |
||
14 | |||
15 | foreach ($oldApi->getAllClasses() as $oldClass) { |
||
16 | try { |
||
17 | $newClass = $newApi->reflect($oldClass->getName()); |
||
18 | } catch (IdentifierNotFound $exception) { |
||
19 | $changelog[] = sprintf('[BC] Class %s has been deleted', $oldClass->getName()); |
||
20 | continue; |
||
21 | } |
||
22 | |||
23 | foreach ($oldClass->getMethods() as $oldMethod) { |
||
24 | // @todo ignore private methods |
||
25 | try { |
||
26 | $newMethod = $newClass->getMethod($oldMethod->getName()); |
||
|
|||
27 | } catch (\OutOfBoundsException $exception) { |
||
28 | $changelog[] = sprintf( |
||
29 | '[BC] Method %s in class %s has been deleted', |
||
30 | $oldMethod->getName(), |
||
31 | $oldClass->getName() |
||
32 | ); |
||
33 | continue; |
||
34 | } |
||
35 | |||
36 | foreach ($oldMethod->getParameters() as $oldParameter) { |
||
37 | $newParameter = $newMethod->getParameter($oldParameter->getName()); |
||
38 | |||
39 | if (null === $newParameter) { |
||
40 | $changelog[] = sprintf( |
||
41 | '[BC] Parameter %s in %s%s%s has been deleted', |
||
42 | $oldParameter->getName(), |
||
43 | $oldClass->getName(), |
||
44 | $oldMethod->isStatic() ? '#' : '::', |
||
45 | $oldMethod->getName() |
||
46 | ); |
||
47 | continue; |
||
48 | } |
||
49 | |||
50 | // @todo check if types changed, or becoming default |
||
51 | // @todo check if a new param (without a default) was added |
||
52 | } |
||
53 | } |
||
54 | } |
||
55 | |||
56 | return $changelog; |
||
57 | } |
||
59 |