@@ -102,21 +102,35 @@ 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 ' ;
105
+ $ returnType = $ method ->getReturnType ();
106
+ $ returnTypeValue = $ returnType
107
+ ? ($ returnType ->allowsNull () ? '? ' : '' ) . $ returnType ->getName ()
108
+ : null ;
107
109
108
110
$ methodInfo = [
109
111
'name ' => ($ method ->returnsReference () ? '& ' : '' ) . $ method ->getName (),
110
112
'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 ,
120
134
'docblock ' => ['shortDescription ' => '{@inheritdoc} ' ],
121
135
];
122
136
0 commit comments