Regexp通过PHP源代码中的引用来检测通过的通话时间 [英] Regexp to detect call time pass by references in PHP source code
问题描述
我正在寻找一个正则表达式,它将准确地识别源代码中引用的任何PHP调用时间传递,以帮助迁移到PHP 5.3。
目前,我有 [^ =&] \s *& \s * \ $
,但是这并不会过滤掉分配情况( $ var =& $ othervar;
)。
这个正则表达式应该与eclipse兼容(抱歉,不知道regexp eclipse解析的味道)。
编辑:这个更接近(虽然有点黑客):(?<!([& =] \s {0,15} ))& \s * \ $
您可以使用 phpcs 为此。它有一个通过引用检测呼叫时间通过的规则:
确保在调用函数时变量不会被引用传递。
通过此在线生成器,可以轻松生成PHPCS(和PMD)的规则集:
- http:// edorian。 g ith。
I'm looking for a regular expression that will accurately identify any PHP call time pass by references in source code in order to aid migration to PHP 5.3.
Currently, I have
[^=&]\s*&\s*\$
, but this doesn't filter out assignment cases ($var = &$othervar;
).This regexp should be compatible with eclipse (sorry, not sure what flavor of regexp eclipse parses).
Edit: This one is a little bit closer (although a bit of a hack):
(?<!([&=]\s{0,15}))&\s*\$
解决方案You can use phpcs for this. It has a rule to detect Call Time Pass by References:
Ensures that variables are not passed by reference when calling a function.
There is also a plugin to integrate phpcs into Eclipse
Generating rulesets for PHPCS (and PMD) is easy with this online generator:
这篇关于Regexp通过PHP源代码中的引用来检测通过的通话时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!