question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[REQ][PHP] Follow PSR-12 Coding Style Guide

See original GitHub issue

Is your feature request related to a problem? Please describe.

From PSR-2 Coding Style Guide:

Deprecated - As of 2019-08-10 PSR-2 has been marked as deprecated. PSR-12 is now recommended as an alternative.

Describe the solution you’d like

  1. Change PHP style guide link at Guidelines For Contributing to PSR-12 Extended Style Guide
  2. All PHP generators which follow PSR-2 coding guide should follow new rules from PSR-12. Tool PHP_CodeSniffer already supports PSR-12 ruleset from 3.5.0 version. If your generator contains PHP_CodeSniffer package then migrate to ^3.5 version and use ruleset like phpcs --standard=PSR12 /path/to/code(or adjust phpcs.xml in your template).
  3. Adjust all other PHP linters and prettifiers to follow PSR-12.

Additional context

Question to PHP members of technical committee: As soon as required PHP version is 7.1 or higher should we add type annotations to PHP templates? I mean int $bar = 0;

cc @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ackintosh (2017/09), @renepardon (2018/12)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ybelenkocommented, May 13, 2022

And by the way PSR-2 and PSR-12 are rather controversial “standards” - otherwise things like PSR-2-R would not appear.

Yes, I noticed it earlier. But we need to stick to some coding style in PHP anyway(originally it was PSR-2 in this repo, now it’s PSR-12). It’s easier to contribute when you can just follow some standard and it’s easier to review changes. Beside we can turn off controversial rules in PHP CS Fixer anytime.

As soon as you’re the major contributor and author of generators mentioned above then I don’t insist. Will add CS Fixer to rest of PHP generators still.

0reactions
Articuscommented, May 13, 2022

@Articus should we add friendsofphp/php-cs-fixer package to php-dt(beta) andphp-mezzio-ph? What do you think.

In my opinion - nope. This package is needed neither to run generated code nor to adjust generated code for existing project integration. So there is no need to bloat generated composer.json with it.

And by the way PSR-2 and PSR-12 are rather controversial “standards” - otherwise things like PSR-2-R would not appear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PSR-12: Extended Coding Style - PHP-FIG
This specification extends, expands and replaces PSR-2, the coding style guide and requires adherence to PSR-1, the basic coding standard.
Read more >
PSR-12 Style Guide - xoops-modules-cookbook
This document references other standards, guidelines and style guides. The following document hierarchy outlines the order of precedence.
Read more >
A Quick Guide to PSR Coding Style Recommendations
General PHP Rules. Code style must follow PSR-1, PSR-2 and PSR-12. Generally speaking, everything string-like that's not public-facing ...
Read more >
PSR-2 and PSR-12: Why We Need Standards and How to ...
What is Code Style/Standard and Why PSR-2/PSR-12? ... In PHP language, for a long time, the most popular standard has been PSR-2.
Read more >
Coding Style Guide - laminas-coding-standard - Laminas Docs
There MAY NOT be any content before the opening tag. Inline HTML in PHP code SHOULD be avoided. All code MUST be executable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found