Skip to content

PSR12 / There must be 1 space after the property type #3729

@Phillip85

Description

@Phillip85

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions