1. 云栖社区>
  2. PHP教程>
  3. 正文

Scan your code for old-style constructors using phpunit. - Ken Guest

作者:用户 来源:互联网 时间:2017-12-01 17:51:53

Scan your code for old-style constructors using phpunit. - Ken Guest - 摘要: 本文讲的是Scan your code for old-style constructors using phpunit. - Ken Guest, There are less than seven days left until PHP 7 is released, which drops support for old-style constructors – the ones

There are less than seven days left until PHP 7 is released, which drops support for old-style constructors – the ones where a method is a constructor if it shares the same name as the class.

You don’t want to spend too much time scrolling through codebases for that though do you? Better things to do, like watch videos of conference talks you’ve missed and such.

Well, you’re in luck. If you use php_codesniffer( and if you don’t, well shame on you), you’ll be able to get a report of old-style constructors fairly quickly.

This will run php code sniffer and identify old-style constructors. $ phpcs --standard=Squiz --extensions=php --sniffs=Generic.NamingConventions.ConstructorName . It’s a bit long-winded, so wrap it up in a bash alias, say in your .bashrc: $ alias findoldphpconstructors='phpcs --standard=Squiz --extensions=php --sniffs=Generic.NamingConventions.ConstructorName .' Want a CSV report of the same? Use this: alias findoldphpconstructorsToCSV='phpcs --standard=Squiz --report=csv --extensions=php --sniffs=Generic.NamingConventions.ConstructorName . | cut -f1,2 -d,'

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索,以便于您获取更多的相关知识。