Feature #13317

Implement PHP code standard and formatter

Added by David Juhasz about 1 year ago. Updated about 1 month ago.

Status:VerifiedStart date:05/14/2020
Priority:MediumDue date:
Assignee:-% Done:

0%

Category:-
Target version:Access to Memory (AtoM) - Release 2.7.0
Sponsored:No Tested version:

Description

Problem

AtoM has a custom coding standard that is not compatible with predominant PHP coding standards, e.g. PSR-1, PSR-12, Symfony's CS. Because the AtoM CS is idiosyncratic it requires extensive configuration to automate code formatting with a PHP code formatter. Maintaining unique coding standards for AtoM also requires maintaining independent documentation of the standard, and PHP developers that want to contribute code to the project must learn a new and niche coding standard.

Proposed Solution
  1. Select an existing PHP coding standard and code formatting tool that can implement the chosen standard with minimal configuration
  2. Configure the chosen code formatter to implement the chosen coding standard, and run the tool to reformat the existing AtoM code (in a dev branch)
  3. Do QA testing of the re-formatted AtoM code, to make sure the formatter hasn't broken any functionality
  4. Merge the re-formatted dev branch to the current main (qa) branch
  5. Set up a continuous integration script to validate new code against the coding standard before the code can be merged to the main "stable" and "qa" branches of AtoM
  6. Document usage of the code formatter and configuration to enable developers to use the formatter to automate formatting of code contributed to AtoM
Suggested coding standards and formatters
  • PHP CS Fixer (started by SensioLabs, developers of Symfony) and PHP CodeSniffer look to be the two most popular FOSS CS validators/formatters
  • Symfony has their own Coding Standard and recommends PHP-CS-Fixer for validation and auto-formatting

Related issues

Related to Access to Memory (AtoM) - Task #13460: Run unit tests on Github per PR and merged commit (on qa ... Verified 01/19/2021

History

#1 Updated by David Juhasz about 1 year ago

  • Subject changed from Implement existing PHP code standard and formatter to Implement PHP code standard and formatter
  • Description updated (diff)

#2 Updated by José Raddaoui Marín 5 months ago

  • Related to Task #13460: Run unit tests on Github per PR and merged commit (on qa and stable branches) added

#4 Updated by José Raddaoui Marín 3 months ago

  • Assignee set to David Juhasz
  • Target version set to Release 2.7.0

#6 Updated by José Raddaoui Marín 3 months ago

  • Status changed from New to QA/Review
  • Assignee deleted (David Juhasz)

Merged in qa/2.x. Leaving it in QA/Review while we work in 2.7.

#7 Updated by José Raddaoui Marín 3 months ago

Initial feedback from https://github.com/artefactual/atom/pull/1276, the failing checks details diff is not very clear. The following change uses the shorter unified diff to make it a bit clearer:

https://github.com/artefactual/atom/pull/1278

#8 Updated by José Raddaoui Marín about 1 month ago

  • Status changed from QA/Review to Verified

Also available in: Atom PDF