PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

PSR12 / There must be 1 space after the property type

Open Phillip85 opened this issue 3 years ago • 0 comments

Describe the bug

Code sample

class test 
{
    public FlightHeader  $flight_header;
    public Carbon        $flight_date;
    public BookingNumber $booking_number;
}

Custom ruleset

<?xml version="1.0"?>
<ruleset name="schauinsland" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
    <rule ref="PSR12"/>
    <rule ref="Squiz.NamingConventions.ValidVariableName.NotCamelCaps"/>
    <rule ref="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps"/>
    <rule ref="Squiz.NamingConventions.ValidVariableName.StringNotCamelCaps"/>
    <rule ref="Generic.Arrays.DisallowLongArraySyntax">
        <type>warning</type>
    </rule>
    <rule ref="Generic.PHP.ForbiddenFunctions">
        <properties>
            <property name="forbiddenFunctions" type="array">
                <element key="sizeof" value="count"/>
                <element key="delete" value="unset"/>
                <element key="print" value="echo"/>
                <element key="create_function" value="null"/>
            </property>
        </properties>
    </rule>

    <exclude-pattern>/vendor/</exclude-pattern>
</ruleset>

To reproduce

 11 | ERROR | [x] There must be 1 space after the property type
    |       |     declaration; 2 found
 12 | ERROR | [x] There must be 1 space after the property type
    |       |     declaration; 8 found

Expected behavior no error

Reason The PSR12 does not disalow multiple spaces after the declaration:

There MUST be a space between type declaration and property name.

it just says there must be a space, not one space

Phillip85 avatar Dec 12 '22 11:12 Phillip85