Skip to content

Commit c0c0a37

Browse files
Oleksandr Gorkunal.kravchuk
authored andcommitted
MAGETWO-89899: Proxy/Interceptor generator does not understand PHP 7.1 syntax
1 parent d33db64 commit c0c0a37

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,26 @@ protected function _getMethodInfo(\ReflectionMethod $method)
109109
$methodInfo = [
110110
'name' => ($method->returnsReference() ? '& ' : '') . $method->getName(),
111111
'parameters' => $parameters,
112-
'body' => "\$pluginInfo = \$this->pluginList->getNext(\$this->subjectType, '{$method->getName()}');\n" .
113-
"if (!\$pluginInfo) {\n" .
114-
" " .($returnTypeValue === 'void' ? '' : 'return')
115-
." parent::{$method->getName()}({$this->_getParameterList(
116-
$parameters
117-
)});\n" .
118-
"} else {\n" .
119-
" " .($returnTypeValue === 'void' ? '' : 'return')
120-
." \$this->___callPlugins('{$method->getName()}', func_get_args(), \$pluginInfo);\n" .
121-
"}",
112+
'body' => str_replace(
113+
[
114+
'%methodName%',
115+
'%return%',
116+
'%parameters%'
117+
],
118+
[
119+
$method->getName(),
120+
$returnTypeValue === 'void' ? '' : 'return',
121+
$this->_getParameterList($parameters)
122+
],
123+
<<<'METHOD_BODY'
124+
$pluginInfo = $this->pluginList->getNext($this->subjectType, '%methodName%');
125+
if (!$pluginInfo) {
126+
%return% parent::%methodName%(%parameters%);
127+
} else {
128+
%return% $this->___callPlugins('%methodName%', func_get_args(), $pluginInfo);
129+
}
130+
METHOD_BODY
131+
),
122132
'returnType' => $returnTypeValue,
123133
'docblock' => ['shortDescription' => '{@inheritdoc}'],
124134
];

0 commit comments

Comments
 (0)