|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Code-Insight library. |
|
4
|
|
|
* For the full copyright and license information, please view |
|
5
|
|
|
* the LICENSE file that was distributed with this source code. |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
|
8
|
|
|
* @link https://github.com/console-helpers/code-insight |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\CodeInsight\BackwardsCompatibility; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class InPortalClassChecker extends ClassChecker |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Methods for which scope change isn't a BC break. |
|
19
|
|
|
* |
|
20
|
|
|
* @var array |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $ignoreScopeChangeMethods = array('mapPermissions', 'SetCustomQuery'); |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Returns backwards compatibility checker name. |
|
26
|
|
|
* |
|
27
|
|
|
* @return string |
|
28
|
|
|
*/ |
|
29
|
1 |
|
public function getName() |
|
30
|
|
|
{ |
|
31
|
1 |
|
return 'inportal_class'; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Processes method. |
|
36
|
|
|
* |
|
37
|
|
|
* @return void |
|
38
|
|
|
*/ |
|
39
|
1 |
|
protected function processMethod() |
|
40
|
|
|
{ |
|
41
|
1 |
|
if ( $this->isEventHandler() && ($this->isEvent() || $this->ignoreScopeChange()) ) { |
|
42
|
1 |
|
$this->targetMethodData['Scope'] = $this->sourceMethodData['Scope']; |
|
43
|
1 |
|
} |
|
44
|
|
|
|
|
45
|
1 |
|
if ( $this->isTagProcessor() && ($this->sourceMethodData['ParameterSignature'] === 'array $params') ) { |
|
46
|
1 |
|
$this->targetMethodData['Scope'] = $this->sourceMethodData['Scope']; |
|
47
|
1 |
|
} |
|
48
|
|
|
|
|
49
|
1 |
|
parent::processMethod(); |
|
50
|
1 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Builds string representation of a parameter. |
|
54
|
|
|
* |
|
55
|
|
|
* @param array $parameter_data Parameter data. |
|
56
|
|
|
* |
|
57
|
|
|
* @return string |
|
58
|
|
|
*/ |
|
59
|
1 |
|
protected function paramToString(array $parameter_data) |
|
60
|
|
|
{ |
|
61
|
1 |
|
$hash_part = parent::paramToString($parameter_data); |
|
62
|
|
|
|
|
63
|
1 |
|
if ( $this->isEventHandler() ) { |
|
64
|
1 |
|
$hash_part = str_replace('&$event', '$event', $hash_part); |
|
65
|
1 |
|
$hash_part = str_replace('\kEvent $event', '$event', $hash_part); |
|
66
|
1 |
|
$hash_part = str_replace('kEvent $event', '$event', $hash_part); |
|
67
|
1 |
|
} |
|
68
|
1 |
|
elseif ( $this->isTagProcessor() ) { |
|
69
|
1 |
|
$hash_part = str_replace('array $params', '$params', $hash_part); |
|
70
|
1 |
|
$hash_part = str_replace('$params', 'array $params', $hash_part); |
|
71
|
1 |
|
} |
|
72
|
|
|
|
|
73
|
1 |
|
return $hash_part; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Determines if current class is an event handler. |
|
78
|
|
|
* |
|
79
|
|
|
* @return boolean |
|
80
|
|
|
*/ |
|
81
|
1 |
|
protected function isEventHandler() |
|
82
|
|
|
{ |
|
83
|
1 |
|
$class_name = $this->sourceClassData['Name']; |
|
84
|
|
|
|
|
85
|
1 |
|
return substr($class_name, -12) === 'EventHandler' || $class_name === 'AdminEventsHandler'; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Determines if current class is a tag processor. |
|
90
|
|
|
* |
|
91
|
|
|
* @return boolean |
|
92
|
|
|
*/ |
|
93
|
1 |
|
protected function isTagProcessor() |
|
94
|
|
|
{ |
|
95
|
1 |
|
return substr($this->sourceClassData['Name'], -12) === 'TagProcessor'; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Determines if current method is an event. |
|
100
|
|
|
* |
|
101
|
|
|
* @return boolean |
|
102
|
|
|
*/ |
|
103
|
1 |
|
protected function isEvent() |
|
104
|
|
|
{ |
|
105
|
1 |
|
return substr($this->sourceMethodData['Name'], 0, 2) === 'On'; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Determines if method scope change should be ignored. |
|
110
|
|
|
* |
|
111
|
|
|
* @return boolean |
|
112
|
|
|
*/ |
|
113
|
1 |
|
protected function ignoreScopeChange() |
|
114
|
|
|
{ |
|
115
|
1 |
|
return in_array($this->sourceMethodData['Name'], $this->ignoreScopeChangeMethods); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
} |
|
119
|
|
|
|