Skip to content

NullPointerException when phploc is used without a formatter #683

Closed
@tolidano

Description

I'm running the phing from composer (2.16)

On this page, you offer this:

<target name="project-size-and-tests" 
description="Measures the size of the project and count it's tests">
    <phploc countTests="true">
    <fileset dir=".">
        <include name="**/*.php" />
        <include name="*.php" />
    </fileset>
    </phploc>
</target>

However, if you ran that, you would get a NullPointerException.
The reason is that you are missing a formatter. You cannot output to the cli without one.

<target name="project-size-and-tests" 
description="Measures the size of the project and count it's tests">
    <phploc countTests="true">
    <fileset dir=".">
        <include name="**/*.php" />
        <include name="*.php" />
    </fileset>
    <formatter type="cli" usefile="false" />
    </phploc>
</target>

However, the documentation below on the formatter suggests misleading things:

  1. It says you need it if you don't define reportType, but it ALSO needs it even if you DO define that but define it as cli.
  2. it says outfile is required, but obviously it isn't (if Required can only be Yes or No, this should probably be No, however, I would suggest adding "Depends" or "Maybe" or "If usefile true"

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions