laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.

Home Page:https://laravel.com/docs/pint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not adhere to all PSR-12 rules

JohnnyWalkerDigital opened this issue · comments

  • Pint Version: 1.1.2
  • PHP Version: 8.0.20

Description:

PSR-12 states: "...the coding style guide and requires adherence to PSR-1, the basic coding standard."

PSR-1, the basic coding standard, states:

  • Class names MUST be declared in StudlyCaps.
  • Class constants MUST be declared in all upper case with underscore separators.
  • Method names MUST be declared in camelCase.
  • Files SHOULD either declare symbols (classes, functions, constants, etc.) or cause side-effects (e.g. generate output, change .ini settings, etc.) but SHOULD NOT do both.
  • Namespaces and classes MUST follow an "autoloading" PSR: [PSR-0, PSR-4].

All of these rules fail to be checked by Laravel Pint in PSR-12 mode.

Steps To Reproduce:

Simply create a model that breaks all these rules. For example:

<?php

use Illuminate\Database\Eloquent\Model;

class camelCase extends Model
{
    public const lowercase = 0;

    public function StudlyCase()
    {
        echo self::lowercase;
    }
}

echo "Hello World!";

And run Laravel Pint.

Pint simply uses https://cs.symfony.com/doc/ruleSets/PSR12.html for that preset. Therefore, you will need to report this issue to PHP CS Fixer if you feel that the preset is not working as expected. Yet, keep in mind that, everything you mentioned is considered a "risky" rule, as changing a class name (etc) causes your code to break.