Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR12/Squiz/PEAR standards all error on promoted properties with docblocks #3342

Closed
Arslanoov opened this issue May 10, 2021 · 3 comments · Fixed by #3343
Closed

PSR12/Squiz/PEAR standards all error on promoted properties with docblocks #3342

Arslanoov opened this issue May 10, 2021 · 3 comments · Fixed by #3343
Milestone

Comments

@Arslanoov
Copy link

Arslanoov commented May 10, 2021

Describe the bug
Promoted properties without PHPDoc was fixed in 3.6.0, but with PHPDoc it still gives an error (in 3.6.0):
Multi-line function declaration not indented correctly; expected 8 spaces but found 0

Code sample

use Symfony\Component\Validator\Constraints as Assert;

final class Command
{
    public function __construct(
        /**
         * @var string
         * @Assert\NotBlank()
         */
        public string $username
    )
    {
    }
}

Custom ruleset

<?xml version="1.0" encoding="UTF-8"?>

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
    <arg name="basepath" value="."/>
    <arg name="cache" value=".phpcs-cache"/>
    <arg name="colors"/>
    <arg name="extensions" value="php"/>

    <rule ref="PSR12"/>

    <file>src/</file>
</ruleset>

To reproduce
You can try to build this project:
https://github.com/Arslanoov/messenger-api

  1. git clone https://github.com/Arslanoov/messenger-api.git
  2. make init
  3. make install-deps
  4. make cs

Or create a class with promoted properties and PHPDoc

ERROR | [x] Multi-line function declaration not indented correctly; expected 8 spaces but found 0

Expected behavior
No error on promoted properties with PHPDoc

Versions (please complete the following information):

  • OS: Ubuntu 20.04
  • PHP: 8.0
  • PHPCS: 3.6.0
  • Standard: PSR12
@Arslanoov
Copy link
Author

With PHPDoc
with

Without PHPDoc
withour

@jrfnl
Copy link
Contributor

jrfnl commented May 10, 2021

Related to #3227, #3210, #3323

@jrfnl
Copy link
Contributor

jrfnl commented May 10, 2021

PR #3343 should fix this. Testing appreciated.

@gsherwood gsherwood added this to the 3.6.1 milestone May 11, 2021
@gsherwood gsherwood changed the title Error on promoted properties with PHPDoc PSR12/Squiz/PEAR standards all error on promoted properties with docblocks May 27, 2021
gsherwood added a commit that referenced this issue May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants