OpenAPITools / OpenAPITools/openapi-generator

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

Open
#4,726 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Client: PHP Enhancement: Code format General: Discussion Server: PHP
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with CONTRIBUTING.md and inventory the PHP generators for PHP_CodeSniffer packages, PSR-2 references, and any phpcs.xml files or other linter configurations mentioned in the issue. The work is done when the applicable PHP generators and linters consistently use PSR-12 rules; the question about adding type annotations remains separate and unresolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.