Skip to content

Commit f6181ca

Browse files
committed
Resolve conflict
1 parent c619238 commit f6181ca

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,35 @@ protected function _getMethodInfo(\ReflectionMethod $method)
102102
$parameters[] = $this->_getMethodParameterInfo($parameter);
103103
}
104104

105-
// Void methods must not use the return statement with any value
106-
$return = ((string) $method->getReturnType() === 'void') ? '' : 'return ';
105+
$returnType = $method->getReturnType();
106+
$returnTypeValue = $returnType
107+
? ($returnType->allowsNull() ? '?' : '') . $returnType->getName()
108+
: null;
107109

108110
$methodInfo = [
109111
'name' => ($method->returnsReference() ? '& ' : '') . $method->getName(),
110112
'parameters' => $parameters,
111-
'body' => "\$pluginInfo = \$this->pluginList->getNext(\$this->subjectType, '{$method->getName()}');\n" .
112-
"if (!\$pluginInfo) {\n" .
113-
" {$return}parent::{$method->getName()}({$this->_getParameterList(
114-
$parameters
115-
)});\n" .
116-
"} else {\n" .
117-
" {$return}\$this->___callPlugins('{$method->getName()}', func_get_args(), \$pluginInfo);\n" .
118-
"}",
119-
'returnType' => $method->getReturnType(),
113+
'body' => str_replace(
114+
[
115+
'%methodName%',
116+
'%return%',
117+
'%parameters%'
118+
],
119+
[
120+
$method->getName(),
121+
$returnTypeValue === 'void' ? '' : ' return',
122+
$this->_getParameterList($parameters)
123+
],
124+
<<<'METHOD_BODY'
125+
$pluginInfo = $this->pluginList->getNext($this->subjectType, '%methodName%');
126+
if (!$pluginInfo) {
127+
%return% parent::%methodName%(%parameters%);
128+
} else {
129+
%return% $this->___callPlugins('%methodName%', func_get_args(), $pluginInfo);
130+
}
131+
METHOD_BODY
132+
),
133+
'returnType' => $returnTypeValue,
120134
'docblock' => ['shortDescription' => '{@inheritdoc}'],
121135
];
122136

0 commit comments

Comments
 (0)