标签: phplint

CruiseControl - PHP lint检查通过ANT工作,但不通过CruiseControl

所以我正在编写一个ant buildfile,它将在cruisecontrol中使用并遇到一个奇怪的问题.我用Google搜索了问题,但没有遇到任何具体的解决方案,所以我想我会在这里发布问题.

我有以下蚂蚁任务:

<target name="module.lint">
    <apply executable="/usr/bin/php" failonerror="true">
        <arg value="-l" />
        <fileset dir="/path/to/my/elite/code" includes="**/*.php" />
    </apply>
</target>
Run Code Online (Sandbox Code Playgroud)

当我使用以下方式运行它:

ant -buildfile /path/to/my/elite/buildfiles/project/elite/build.xml module.lint
Run Code Online (Sandbox Code Playgroud)

它运行正常,但当我尝试通过CruiseControl GUI构建项目时,我收到以下错误:

[cc]Aug-09 15:51:04 ScriptRunner  - fileset: Setup scanner in dir /path/to/my/elite/code with patternSet{ includes: [**/*.php] excludes: [] }
[cc]Aug-09 15:51:04 ScriptRunner  -     [apply] Executing '/usr/bin/php' with arguments:
[cc]Aug-09 15:51:04 ScriptRunner  -     [apply] '-l'
[cc]Aug-09 15:51:04 ScriptRunner  -     [apply] '/path/to/my/elite/code/Script.php'
[cc]Aug-09 15:51:04 ScriptRunner  -     [apply]
[cc]Aug-09 15:51:04 ScriptRunner  -     [apply] The ' characters around the executable and arguments …
Run Code Online (Sandbox Code Playgroud)

ant cruisecontrol lint phplint

5
推荐指数
1
解决办法
407
查看次数

在仅打印出有错误的文件时如何递归所有文件递归?

我只想打印当前(递归)目录中的所有文件,而仅打印出有错误的文件,并在完成替换后将变量分配给1。

#!/bin/bash

lint_failed=0
find . -path ./vendor -prune -o -name '*.php' | parallel -j 4 sh -c 'php -l {} || echo -e "[FAIL] {}" && lint_failed=1';

if [ "$lint_failed" -eq "1" ]; then
    exit 1
fi
Run Code Online (Sandbox Code Playgroud)

范例

[失败] ./app/Model/Example.php

上面的代码找不到任何错误,但是如果我运行php -l ./app/Model/Example.php,则会返回错误。

php bash gnu-parallel phplint

5
推荐指数
1
解决办法
769
查看次数

php -l:抑制有效文件的输出

使用php -l myFile.php命令(PHP 5.5.30)时,如果文件有语法错误,那么我会得到正确的警告和堆栈跟踪等.

但是,如果文件没有语法警告,我会收到消息

myFile.php中未检测到语法错误

当语法有效时,有没有办法让命令没有输出?我只关心文件是否有无效的语法 - 我不需要一条消息说它有效.

php phplint

4
推荐指数
1
解决办法
1072
查看次数

PHP 代码嗅探器规则

我无法让这些规则发挥作用:

函数名后没有空格:

// good
public function cities()

// bad
public function cities ()
Run Code Online (Sandbox Code Playgroud)

确保等于之间的空格:

// good
$test = 'test';

// bad
$test ='test';
$test= 'test';
Run Code Online (Sandbox Code Playgroud)

args 中逗号后必须有空格:

// good
function ($arg1, $arg2)

// bad
function ($arg1,$arg2)
function ($arg1 ,$arg2)
Run Code Online (Sandbox Code Playgroud)

我的规则:

<?xml version="1.0"?>
<ruleset name="PSR2">
<description>The PSR-2 coding standard.</description>

<!-- PHP code MUST use the long <?php ?> tags or the short-echo <?= ?> tags; it MUST NOT use the other tag variations. -->
<rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound">
<severity>0</severity>
</rule>

<!-- PHP code …
Run Code Online (Sandbox Code Playgroud)

php phplint phpcodesniffer

3
推荐指数
1
解决办法
2万
查看次数

在 Jenkins 中构建和部署 Zend Framework PHP 应用程序

我正在设置 jenkins 作业来构建和部署 Zend Framework 2 php 应用程序。在我的 ant 构建脚本中,我定义了一个用于验证 php 文件的 lint 作业。

构建作业失败,因为 lint 在 ZF2 库文件中检测到错误。

这是 lint 生成的输出:

[apply] PHP Fatal error:  Constructor Zend\Captcha\Factory::factory() cannot be static in /var/lib/jenkins/workspace/XXX/vendor/zendframework/zendframework/library/Zend/Captcha/Factory.php on line 90
[apply] Errors parsing /var/lib/jenkins/workspace/XXX/vendor/zendframework/zendframework/library/Zend/Captcha/Factory.php
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么验证Zend/Captcha/Factory.php fails

ANT 任务如下所示:

    <target name="lint" description="Perform syntax check of sourcecode files">
  <apply executable="php" failonerror="true">
   <arg value="-l" />

   <fileset dir="${basedir}/">
    <include name="**/*.php" />
    <modified />
   </fileset>

   <fileset dir="${basedir}/tests">
    <include name="**/*.php" />
    <modified />
   </fileset>
  </apply>
 </target>
Run Code Online (Sandbox Code Playgroud)

jenkins zend-framework2 phplint

1
推荐指数
1
解决办法
978
查看次数