Questions tagged [psr-1]

PSR-1 is a PHP Standards Recommendation describing PHP's Basic Coding Standard.

PSR-1 is a Standards Recommendation describing PHP's Basic Coding Standard.

36 questions
2
votes
1 answer

PSR for using description of class

I can't find anything saying in PSR about where should placed comment about class and namespace. Is it should be first description of class or namespace?
Timur
  • 488
  • 4
  • 14
2
votes
1 answer

Is class declaration and object initialization in the same file PSR-1 compliant?

PSR-1 states: 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. Let's suppose we have following code: // db.php file class…
Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
2
votes
1 answer

PSR standard for short-echo tags spacing

The PSR coding standards are very clear about most of their conventions, including the very first entry in PSR-1: PHP code MUST use the long tags or the short-echo tags; it MUST NOT use the other tag variations. but what is not…
Gordy
  • 91
  • 1
  • 8
2
votes
1 answer

class name always StudlyCaps or there's exceptions on PSR-1?

If the class name a is a abreviation in UPPER case like "CORS", the class name must still be in StudlyCaps like that: class Cors { } Below is the way of my preference, but i would to know if it is an anti-pattern: class CORS { }
Daniel Faria
  • 1,476
  • 5
  • 24
  • 45
1
vote
0 answers

How to config phpcs.xml to accept acronym with the CamelCaps rule?

I have the following error when I "phpcs" my code : 223 | ERROR | Method name "Query::MySQLQueryBuilder" is not in camel | | caps format | | (PSR1.Methods.CamelCapsMethodName.NotCamelCaps) I would not to exclude the rule but…
Amina
  • 46
  • 4
1
vote
1 answer

PHP PSR1 echo side effects

I was working on a command line application and I have this class that handles the business logic. This class has some method that loops all data from a \Generator and echo out some values. I use \Generator because this command line application…
KevDev
  • 541
  • 2
  • 6
  • 20
1
vote
1 answer

Can I use the if-statement in single row according to the PSR-2?

I need to know if I'am allowed to use single row if-statements according to the PSR-2 Coding Style. I've already read the docs but i couldn't find any information about…
1
vote
1 answer

Is there any PSR / convention about Alternative Syntax?

I've seen a lot of posts talking about why alternative Syntax in PHP is good/bad. It's not the topic, I'm a convention lover and I want to know if there's about convention about it. Have a clean code is one of my priority. I'm pretty sure it's not a…
1
vote
0 answers

PSR for nested IF condition

I am just to migrate my code in to PSR standard. I am not sure about how to write it inside nested condition. I am confused by line spacing. Can I use one line space after If condition ? Below is my example code. if ($this->value) { if…
shivanshu patel
  • 782
  • 10
  • 19
1
vote
3 answers

PSR-1 2.3 Side Effects Rule example

Following on from this other question. In the PSR-1 Guidelines, the section 2.3 Side Effects rule restricts using include and declaring functions in the same file, e.g.:
icc97
  • 11,395
  • 8
  • 76
  • 90
0
votes
0 answers

Is the following code PSR-1 and PSR-12 compliant?

For a project assigned to me, I have to stick to following the PSR coding standard for PHP. Now, I am having a hard time understanding one thing. Is the following PSR-1 and PSR-12 compliant?
coderboy
  • 1,710
  • 1
  • 6
  • 16
0
votes
0 answers

Is it necessary to use namespaces as per PHP's PSR-1 coding standard?

I am new to following the coding standard PSR for PHP, specifically conforming to PSR-1 and PSR-12. Now I am confused about one thing. That is, is it necessary to use namespaces as per the PSR-1 standard? There's no explicit mention of the fact that…
coderboy
  • 1,710
  • 1
  • 6
  • 16
0
votes
1 answer

Is there a way to set/change the coding standard for php in null-ls in nvim?

I have setup null-ls plugin to use phpcs for diagnostics and phpcdf for formatting. However I cannot seem to find a way to set the coding standard for phpcs/phpcbf. I want to change it from PEAR to PSR-1. Any help will be appreciated! thank you all…
anikomei
  • 73
  • 1
  • 9
0
votes
0 answers

PSR-2 VS Codeigniter Framework Style guidelines

There are contradictions between PSR-2 and Codeigniter Style Guidelines: Allman style indenting in CI which is discouraged in PSR-2 elseifs on new line in allman private methods in classes prefixed with underscore in CI and NOT in PSR-2. TRUE,…
0
votes
1 answer