File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
lib/internal/Magento/Framework/Interception
Test/Unit/Code/Generator/_files Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -102,17 +102,20 @@ protected function _getMethodInfo(\ReflectionMethod $method)
102
102
$ parameters [] = $ this ->_getMethodParameterInfo ($ parameter );
103
103
}
104
104
105
+ // Void methods must not use the return statement with any value
106
+ $ return = ((string ) $ method ->getReturnType () === 'void ' ) ? '' : 'return ' ;
107
+
105
108
$ methodInfo = [
106
109
'name ' => ($ method ->returnsReference () ? '& ' : '' ) . $ method ->getName (),
107
110
'parameters ' => $ parameters ,
108
111
'body ' => "\$pluginInfo = \$this->pluginList->getNext( \$this->subjectType, ' {$ method ->getName ()}'); \n" .
109
112
"if (! \$pluginInfo) { \n" .
110
- " return parent:: {$ method ->getName ()}( {$ this ->_getParameterList (
113
+ " { $ return} parent:: {$ method ->getName ()}( {$ this ->_getParameterList (
111
114
$ parameters
112
115
)}); \n" .
113
- "} else { \n" .
114
- " return \$this->___callPlugins(' {$ method ->getName ()}', func_get_args(), \$pluginInfo); \n" .
115
- "} " ,
116
+ "} else { \n" .
117
+ " { $ return} \$this->___callPlugins(' {$ method ->getName ()}', func_get_args(), \$pluginInfo); \n" .
118
+ "} " ,
116
119
'returnType ' => $ method ->getReturnType (),
117
120
'docblock ' => ['shortDescription ' => '{@inheritdoc} ' ],
118
121
];
Original file line number Diff line number Diff line change @@ -12,6 +12,19 @@ class Interceptor extends \Magento\Framework\Interception\Code\Generator\TSample
12
12
$this->___init();
13
13
}
14
14
15
+ /**
16
+ * {@inheritdoc}
17
+ */
18
+ public function returnVoid() : void
19
+ {
20
+ $pluginInfo = $this->pluginList->getNext($this->subjectType, 'returnVoid');
21
+ if (!$pluginInfo) {
22
+ parent::returnVoid();
23
+ } else {
24
+ $this->___callPlugins('returnVoid', func_get_args(), $pluginInfo);
25
+ }
26
+ }
27
+
15
28
/**
16
29
* {@inheritdoc}
17
30
*/
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ class TSample
10
10
private $ value ;
11
11
private $ variadicValue ;
12
12
13
+ public function returnVoid () : void
14
+ {
15
+ // Nothing to do here
16
+ }
17
+
13
18
public function getValue () : string
14
19
{
15
20
return $ this ->value ;
You can’t perform that action at this time.
0 commit comments