Skip to content
New issue

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

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

Already on GitHub? # to your account

Incorrect PHPDoc Formatting #1

Closed
Jubeki opened this issue Jun 22, 2022 · 4 comments · Fixed by #3
Closed

Incorrect PHPDoc Formatting #1

Jubeki opened this issue Jun 22, 2022 · 4 comments · Fixed by #3
Assignees

Comments

@Jubeki
Copy link
Contributor

Jubeki commented Jun 22, 2022

  • Pint Version: 0.1.0
  • PHP Version: 8.1.6

Description:

The Laravel Code Style has the following style throughout the source code:

laravel_phpdoc_alignment

After @param should be two spaces then a type-hint then another two spaces and then the $variable

  /**
   * Here is a description for what the function does
-  * @param string $foo
+  * @param  string  $foo
   * @return string
   */
  public function bar($foo) {}

laravel_phpdoc_order

First should be the description after that @param then @return and at last @throws
The default rule phpdoc_order has a different order: description, @param, @throws, @return

  /**
   * Here is a description for what the function does
   * @param string $foo
   * @param  string  $foo
-  * @throws \Exception
   * @return string
+  * @throws \Exception
   */
  public function bar($foo) {}

laravel_phpdoc_seperation

Between each group of tags should be an empty line for seperation. @param and @return are always of the same group and are not to be seperated with an empty line.
The default behaviour for phpdoc_seperation is also an empty line between @param and @return.

  /**
   * Here is a description for what the function does
+  *
   * @param string $foo
   * @param  string  $foo
-  *
   * @return string
+  *
   * @throws \Exception
   */
  public function bar($foo) {}

Steps To Reproduce:

  1. Create Fixtures for the example
  2. Run pint
  3. Check the result remains unchanged

Possible Solution

Since there are no default rules for PHP-CS-Fixer I created custom ones.
There are three Fixers for PHP-CS-Fixer which could be included here.
https://github.com/Jubeki/laravel-code-style/tree/main/src/Fixers

Do you have an interest in a PR?

@nunomaduro
Copy link
Member

@Jubeki Yes. Do you mind of pull requesting that?

@Jubeki
Copy link
Contributor Author

Jubeki commented Jun 22, 2022

Sure, I will do that.

@nunomaduro
Copy link
Member

#3

@jesseleite
Copy link

jesseleite commented Jul 4, 2022

After @param should be two spaces then a type-hint then another two spaces and then the $variable

Just a quick question on Laravel's docblock style with the double spaces thing. I notice pint is correcting to 4 spaces on a few of our docblocks because we specify a @param without a type...

image

Is a type required to be a valid phpdoc block?

ablancobarreda added a commit to ablancobarreda/pint that referenced this issue Jan 5, 2023
ablancobarreda added a commit to ablancobarreda/pint that referenced this issue Jan 5, 2023
Merge pull request laravel#1 from ablancobarreda/3--UploadImages
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
4 participants