@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | namespace Kenjis\MonkeyPatch\Patcher; |
12 | 12 | |
13 | -require __DIR__ . '/MethodPatcher/NodeVisitor.php'; |
|
14 | -require __DIR__ . '/MethodPatcher/PatchManager.php'; |
|
13 | +require __DIR__.'/MethodPatcher/NodeVisitor.php'; |
|
14 | +require __DIR__.'/MethodPatcher/PatchManager.php'; |
|
15 | 15 | |
16 | 16 | use LogicException; |
17 | 17 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | { |
65 | 65 | if ($start_method && $token === '{') |
66 | 66 | { |
67 | - if(self::isVoidFunction($tokens, $key)){ |
|
68 | - $new_source .= '{ ' . self::CODENORET; |
|
67 | + if (self::isVoidFunction($tokens, $key)) { |
|
68 | + $new_source .= '{ '.self::CODENORET; |
|
69 | 69 | } |
70 | - else{ |
|
71 | - $new_source .= '{ ' . self::CODE; |
|
70 | + else { |
|
71 | + $new_source .= '{ '.self::CODE; |
|
72 | 72 | } |
73 | 73 | $start_method = false; |
74 | 74 | $replacement['key'] = key(self::$replacement); |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | * @param $key |
101 | 101 | * @return bool |
102 | 102 | */ |
103 | - protected static function isVoidFunction($tokens, $key){ |
|
104 | - if($key - 1 <= 0){ |
|
103 | + protected static function isVoidFunction($tokens, $key) { |
|
104 | + if ($key - 1 <= 0) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | $token = $tokens[$key - 1]; |
108 | - if(is_array($token)){ |
|
108 | + if (is_array($token)) { |
|
109 | 109 | $token = $token[1]; |
110 | 110 | } |
111 | 111 | //Loop backwards though the start of the function block till you either find "void" or the end of the |
112 | 112 | //parameters declaration. |
113 | - while($token !== ")"){ |
|
114 | - if(strpos($token, "void") !== false){ |
|
113 | + while ($token !== ")") { |
|
114 | + if (strpos($token, "void") !== false) { |
|
115 | 115 | return true; |
116 | 116 | } |
117 | 117 | $token = $tokens[$key - 1]; |
118 | - if(is_array($token)){ |
|
118 | + if (is_array($token)) { |
|
119 | 119 | $token = $token[1]; |
120 | 120 | } |
121 | 121 | $key--; |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | if(self::isVoidFunction($tokens, $key)){ |
68 | 68 | $new_source .= '{ ' . self::CODENORET; |
69 | - } |
|
70 | - else{ |
|
69 | + } else{ |
|
71 | 70 | $new_source .= '{ ' . self::CODE; |
72 | 71 | } |
73 | 72 | $start_method = false; |
@@ -78,13 +77,11 @@ discard block |
||
78 | 77 | { |
79 | 78 | $replacement = false; |
80 | 79 | } |
81 | - } |
|
82 | - else |
|
80 | + } else |
|
83 | 81 | { |
84 | 82 | $new_source .= $token; |
85 | 83 | } |
86 | - } |
|
87 | - else |
|
84 | + } else |
|
88 | 85 | { |
89 | 86 | $new_source .= $token[1]; |
90 | 87 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | namespace Kenjis\MonkeyPatch\Patcher; |
12 | 12 | |
13 | -require __DIR__ . '/MethodPatcher/NodeVisitor.php'; |
|
14 | -require __DIR__ . '/MethodPatcher/PatchManager.php'; |
|
13 | +require __DIR__.'/MethodPatcher/NodeVisitor.php'; |
|
14 | +require __DIR__.'/MethodPatcher/PatchManager.php'; |
|
15 | 15 | |
16 | 16 | use LogicException; |
17 | 17 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | { |
65 | 65 | if ($start_method && $token === '{') |
66 | 66 | { |
67 | - if(self::isVoidFunction($tokens, $key)){ |
|
68 | - $new_source .= '{ ' . self::CODENORET; |
|
67 | + if (self::isVoidFunction($tokens, $key)) { |
|
68 | + $new_source .= '{ '.self::CODENORET; |
|
69 | 69 | } |
70 | - else{ |
|
71 | - $new_source .= '{ ' . self::CODE; |
|
70 | + else { |
|
71 | + $new_source .= '{ '.self::CODE; |
|
72 | 72 | } |
73 | 73 | $start_method = false; |
74 | 74 | $replacement['key'] = key(self::$replacement); |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | * @param $key |
101 | 101 | * @return bool |
102 | 102 | */ |
103 | - protected static function isVoidFunction($tokens, $key){ |
|
104 | - if($key - 1 <= 0){ |
|
103 | + protected static function isVoidFunction($tokens, $key) { |
|
104 | + if ($key - 1 <= 0) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | $token = $tokens[$key - 1]; |
108 | - if(is_array($token)){ |
|
108 | + if (is_array($token)) { |
|
109 | 109 | $token = $token[1]; |
110 | 110 | } |
111 | 111 | //Loop backwards though the start of the function block till you either find "void" or the end of the |
112 | 112 | //parameters declaration. |
113 | - while($token !== ")"){ |
|
114 | - if(strpos($token, "void") !== false){ |
|
113 | + while ($token !== ")") { |
|
114 | + if (strpos($token, "void") !== false) { |
|
115 | 115 | return true; |
116 | 116 | } |
117 | 117 | $token = $tokens[$key - 1]; |
118 | - if(is_array($token)){ |
|
118 | + if (is_array($token)) { |
|
119 | 119 | $token = $token[1]; |
120 | 120 | } |
121 | 121 | $key--; |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | if(self::isVoidFunction($tokens, $key)){ |
68 | 68 | $new_source .= '{ ' . self::CODENORET; |
69 | - } |
|
70 | - else{ |
|
69 | + } else{ |
|
71 | 70 | $new_source .= '{ ' . self::CODE; |
72 | 71 | } |
73 | 72 | $start_method = false; |
@@ -78,13 +77,11 @@ discard block |
||
78 | 77 | { |
79 | 78 | $replacement = false; |
80 | 79 | } |
81 | - } |
|
82 | - else |
|
80 | + } else |
|
83 | 81 | { |
84 | 82 | $new_source .= $token; |
85 | 83 | } |
86 | - } |
|
87 | - else |
|
84 | + } else |
|
88 | 85 | { |
89 | 86 | $new_source .= $token[1]; |
90 | 87 | } |