How to beautify the output of phing?

谁都会走 提交于 2019-12-06 16:31:40

What you could try is using phing.listener.XmlLogger and piping it through xsltproc with your own stylesheet.

Given a basic build.xml file that just lints your PHP:

<?xml version="1.0" ?>
<project name="Example" basedir=".">

    <target name="lint" description="PHP syntax check">
        <phplint>
            <fileset dir="src">
                <include name="**/*.php"/>
            </fileset>
        </phplint>
    </target>

</project>

Coupled with parse.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="text"
        omit-xml-declaration="yes"/>

    <xsl:template match="/build">
        <xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable>

        <xsl:for-each select="target">
            <xsl:text>Task: </xsl:text>
            <xsl:value-of select="concat(@name, $newline)" />

            <xsl:choose>
                <xsl:when test="task/message[@priority = 'error']">
                    <xsl:value-of select="concat(task/message[@priority = 'error'], $newline)"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>No errors</xsl:text>
                    <xsl:value-of select="$newline" />
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

Invoked with phing -logger phing.listener.XmlLogger lint | xsltproc parse.xsl - will give you something clean like:

Task: lint
Fatal error: Only variables can be passed by reference in Request.class.php on line 128

u have a sytax error on line 2 mytest

it comes basically when inapropriate code is passed or is not properly closed like {}

can you post the line 2 of mytest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!