psr-2 Questions

5

Solved

Are there objective reasons for using spaces instead of tabs for indenting files as per PSR-2 standard, can someone provide: facts, references, specific expertise on which PSR-2 standard is based...
Palaeozoic asked 26/2, 2016 at 10:55

5

PSR suggests, method names MUST be declared in camelCase and class names MUST be declared in StudlyCaps.
Treacle asked 23/9, 2015 at 5:36

5

Solved

Question: are parentheses required in PSR-2 PHP ternary syntax? Looking for which (if either) of the following ternary statement's syntax is compliant with PSR-2 - I also need to be pointed to doc...
Rehnberg asked 15/10, 2014 at 18:3

1

Solved

I want to run phpcs tool, but this error is coming, ERROR: Referenced sniff "PHPCompatibility" does not exist I ran phpcs -i. That gave me , The installed coding standards are PEAR, PSR1, Zend, S...
Favourite asked 29/6, 2018 at 7:52

2

Solved

I currently follow PSR-2 and PSR-4. I'm running into a small dilemma when trying to name a few classes. Here's an example. I have a base REST client, \Vendor\RestClient\AbstractClient. I have two ...
Retractor asked 18/12, 2015 at 16:20

1

Solved

For example Symfony uses \Controller. Yii2 uses \controllers and \models. Is there a standard about ...s|es like PSR?
Hamsun asked 29/12, 2017 at 9:47

1

What is the correct way according to PSR2 for having spaces between keys and values of multiline array. $result = [ 'key1' => 'value1', 'another_key' => 'value2', 'some_other_key' => '...
Ancheta asked 2/11, 2017 at 12:16

1

I work on a proprietary project that uses quite a lot of factories of one form or another. Most of them don't instantiate the class by name, fortunately, but whether new self() or new static() is u...
Royston asked 20/10, 2017 at 13:10

2

Solved

In my opinion, sample #2 seems to be the more readable way of commenting. But if I apply PSR-2 to both samples, sample #1 won't change but the result of sample #2 changes as below and it's not a ...
Stilly asked 15/10, 2017 at 6:45

4

Solved

I use PSR-2 for code styling my code. When I inspect a file using Codesniffer most of the times I get the following error. 332 | ERROR | [x] Expected 1 newline at end of file; 0 found It's obvi...
Bodega asked 15/3, 2016 at 18:42

2

Solved

I am trying to figure out which code style to enforce with the phpcs code sniffer. Since the popularity of Symfony2, it seems to be a good practice to use its code standard. On the other hand, its...
Tonsillectomy asked 15/6, 2015 at 16:30

2

Solved

I want my IDE (PhpStorm) to enforce PSR-2 compatible formatting on all of own files. Occasionally however, I have to submit patches on legacy code where I only want to commit functional changes, no...
Duester asked 12/5, 2017 at 5:10

3

Solved

Okay, I know php-cs-fixer allows following levels of fixes for coding standards: php php-cs-fixer.phar fix /path/to/project --level=psr0 php php-cs-fixer.phar fix /path/to/project --level=psr1 php ...
Stoned asked 24/4, 2015 at 5:11

1

I am using Laravel 5.1 now. The migrations class file generated by php artisan make:migration create_users_table --create=users command, would be like this: <?php use Illuminate\Database\Sch...
Dyal asked 20/12, 2016 at 2:4

1

Solved

What is allowed between these two: $value = 'value'; $user = 'John'; $timestamp = 1480927909; $day = date('Y-m-d', $timestamp); or $value = 'value'; $user = 'John'; $timestamp = 1480927909; $da...
Mckeehan asked 5/12, 2016 at 8:58

1

Solved

Can I use if-statement like: if(true) return $value; Or must use always with braces: if(true) { return $value; }
Indifferentism asked 8/8, 2015 at 19:5

1

Solved

Is it a valid way(PSR-2) to write code with 2 blank lines in a row? For example: $a = 1; $b = 2; Or there always has to be only one blank line beetween $a and $b?
Hautrhin asked 30/4, 2015 at 13:4
1

© 2022 - 2025 — McMap. All rights reserved.