-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fixed]eval error with void method #92
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP Fatal error: A void function must not return a value in $PATH/vendor/swoft/framework/src/Proxy/Proxy.php(46) : eval()'d code on line 14 when void method in Bean Object, example : ``` /** * @bean() **/ class A { public function test() : void { } } ``` Proxy::newProxyInstance make this template : ``` class B extend A { public function test() : void { return $this->__handler_xxx->invoke('test', func_get_args()); } } ```
huangzhhui
reviewed
Jun 8, 2018
@@ -76,13 +82,14 @@ private static function getMethodsTemplate(array $reflectionMethods, string $han | |||
$returnType = $reflectionMethodReturn->__toString(); | |||
$returnType = $returnType === 'self' ? $reflectionMethod->getDeclaringClass()->getName() : $returnType; | |||
$template .= " : $returnType"; | |||
// if returnType is void | |||
if ($returnType === 'void') { | |||
$methodBody = str_replace('return ', '', $methodBody); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的处理不严谨,如果 $methodName
包含 return
关键词则会被替换掉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
替换为 return+空格的字符串,语法层,应该已经杜绝了methodName包含 替换内容的可能
huangzhhui
added a commit
that referenced
this pull request
Jun 12, 2018
7003d920 Merge commit '30a1120da2a33a98360ee4da4e4586ad3412b5f2' e8da8609 [fixed]eval error with void method (#92) 5cf5896c [fixed] logger->messages init error (#91) 52bbec6c Merge pull request #114 from aprchen/patch-1 847f23b4 fix spanid c559c93e add coWrite(); use swoft/swoole-ide-helper (#83) 21d268b7 change fix e88a03f6 fix index err 620394d5 Merge commit '1643eb132396c22e6c9be8c90d123a31487455dd' 54f1675d Merge branch 'master' of https://github.com/swoft-cloud/swoft-component 8cf725ac refactor bean scan d6c20a92 ws-server: bug fixed for connection info lost. fix cannot connect to root path d91c68d1 add template of validator e591de64 Merge branch 'master' of github.com:aprchen/swoft-component 001b46ed 格式修改,添加返回值类型,添加is_iterable兼容 1ea88d43 Update XmlHelper.php fbfec258 Update XmlHelper.php 4fc2b08f Update XmlHelperTest.php c38e5110 Update XmlHelperTest.php 9e65bc4b 格式化 4a1ef3db 添加xml解析,完善单元测试 1996c5b4 Merge pull request #2 from inhere/master 651ef229 new: add timezone setting. fix some bug for Config 4fbf22cb fix: bug fixed for array heleper e828b7b3 up: change config() to config(key, default) 72aa48c6 add server type option a5acf660 new: add global function config(). add new option for devtool 72e97a05 fix: The server object does not need a reference git-subtree-dir: src/framework git-subtree-split: 7003d920fb31936f59f7851f0acf81544e007fae
swoft-bot
added a commit
that referenced
this pull request
Jan 15, 2019
f9910dc Merge commit 'b4f8d0a17a1c9a99274d0e250f6179d14a8728a8' 036d98b Merge branch 'master' of github.com:swoft-cloud/swoft-component 0d9ccbe Update Aop.php (#222) cacd775 修复Number验证器最大和最小的template没有生效的问题 (#218) 7ebaf5f 修复Number验证器最大和最小的template没有生效的问题 (#218) ed18988 fix error on trigger event handler (#196) bf188ad fix a bug when warnings appear in the high version of swoole (#195) 4ec3be6 自定义组件支持别名配置 (#181) 609dd83 修复restart不能正常使用的BUG (#180) 0bcd9bc 修改连接池配置的timeout字段为float (#177) 0044361 修改自定义组件只能扫描Aop、Command、Bootstrap三个文件的BUG (#169) 99916fc 兼容swoole 4.0.3版本 (#166) a1d6ace 增加用户自定义组件配置 (#150) d0f7f88 Upstream travis ci config (#160) afb115f 修复Json Validator会失效的BUG (#153) 5fdf6c7 修复自定义注解无法使用Aop切面编程的BUG (#139) 3c147d1 Optimize (#143) c98825b 修复执行php bin/swoft stop命令时master进程异常未退出的问题,以及停止失败后,pid文件被删除的问题 (#134) 940f76f 修改`ComposerHelper::getDirByNamespace`匹配有误的BUG (#137) 427dcb6 Update PoolHelper.php (#131) fc38546 Scan bean according to Composer settings (#115) 851f3f0 Add psysh for debug (#109) e55fae5 Parse namespace to dir path according to composer settings (#103) 290a2f4 fix swoft-cloud/swoft#277 (#96) 0d2dade fix logWriter (#95) 1f1af6c Uniform log path format (#94) 148daeb [fixed]eval error with void method (#92) a22481a [fixed] logger->messages init error (#91) 69975cd add coWrite(); use swoft/swoole-ide-helper (#83) 7f66cef change fix 410b028 fix index err git-subtree-dir: src/framework git-subtree-split: f9910dc9266e9f87c158d89286a2f07dc67f2a18
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PHP Fatal error: A void function must not return a value in $PATH/vendor/swoft/framework/src/Proxy/Proxy.php(46) : eval()'d code on line 14
when void method in Bean Object, example :
Proxy::newProxyInstance make this template :