cytopia/php-cs-fixer

By cytopia

Updated almost 3 years ago

Alpine-based multistage-build version of php-cs-fixer for reproducible usage in CI

Image
5

500K+

cytopia/php-cs-fixer repository overview

Docker image for php-cs-fixer

Tag License

lint build nightly

View Dockerfiles on GitHub.

Available Architectures: amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x

Tiny Alpine-based multistage-build dockerized version of php-cs-fixer[1]. The image is built nightly against multiple stable versions and pushed to Dockerhub.

[1] Official project: https://github.com/FriendsOfPHP/PHP-CS-Fixer

:whale: Available Docker image versions

Docker

Rolling releaess

The following Docker image tags are rolling releases and are built and updated every night.

nightly

Docker TagGit RefPHPCFPHPAvailable Architectures
latestmasterlatestlatestamd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
latest-php8.1masterlatest8.1amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
latest-php8.0masterlatest8.0amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
latest-php7.4masterlatest7.4amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
3master3.x.xlatestamd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
3-php8.1master3.x.x8.1amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
3-php8.0master3.x.x8.0amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
3-php7.4master3.x.x7.4amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2master2.x.xlatestamd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php8.1master2.x.x8.1amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php8.0master2.x.x8.0amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.4master2.x.x7.4amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.3master2.x.x7.3amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.2master2.x.x7.2amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.1master2.x.x7.1amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.0master2.x.x7.0amd64, i386, arm64, arm/v7, arm/v6, ppc64le
2-php5.6master2.x.x5.6amd64, i386, arm64, arm/v7, arm/v6, ppc64le
Point in time releases

The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date.

build

Docker TagGit RefPHPCFPHPAvailable Architectures
latest-<tag>git: <tag>latestlatestamd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
latest-php8.1-<tag>git: <tag>latest8.1amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
latest-php8.0-<tag>git: <tag>latest8.0amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
latest-php7.4-<tag>git: <tag>latest7.4amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
3-<tag>git: <tag>3.x.xlatestamd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
3-php8.1-<tag>git: <tag>3.x.x8.1amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
3-php8.0-<tag>git: <tag>3.x.x8.0amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
3-php7.4-<tag>git: <tag>3.x.x7.4amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-<tag>git: <tag>2.x.xlatestamd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php8.1-<tag>git: <tag>2.x.x8.1amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php8.0-<tag>git: <tag>2.x.x8.0amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.4-<tag>git: <tag>2.x.x7.4amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.3-<tag>git: <tag>2.x.x7.3amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.2-<tag>git: <tag>2.x.x7.2amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.1-<tag>git: <tag>2.x.x7.1amd64, i386, arm64, arm/v7, arm/v6, ppc64le, s390x
2-php7.0-<tag>git: <tag>2.x.x7.0amd64, i386, arm64, arm/v7, arm/v6, ppc64le
2-php5.6-<tag>git: <tag>2.x.x5.6amd64, i386, arm64, arm/v7, arm/v6, ppc64le

Where <tag> refers to the chosen git tag from this repository.

:open_file_folder: Docker mounts

The working directory inside the Docker container is /data/ and should be mounted locally.

:computer: Usage

Generic
$ docker run --rm cytopia/php-cs-fixer --help

Usage:
  list [options] [--] [<namespace>]

Arguments:
  namespace            The namespace name

Options:
      --raw            To output raw command list
      --format=FORMAT  The output format (txt, xml, json, or md) [default: "txt"]

Help:
  The list command lists all commands:

    php /usr/bin/php-cs-fixer list

  You can also display the commands for a specific namespace:

    php /usr/bin/php-cs-fixer list test

  You can also output the information in other formats by using the --format option:

    php /usr/bin/php-cs-fixer list --format=xml

  It's also possible to get raw list of commands (useful for embedding command runner):

    php /usr/bin/php-cs-fixer list --raw
Dry-run
$ docker run --rm -v $(pwd):/data cytopia/php-cs-fixer fix --dry-run --diff .
Loaded config default.
Using cache file ".php_cs.cache".
   1) fail.php
      ---------- begin diff ----------
--- Original
+++ New
@@ @@
 <?php

  echo "test";

-if (  1 ==2) {
- echo "asd"; }
+if (1 ==2) {
+    echo "asd";
+}
      ----------- end diff -----------

Checked all files in 0.004 seconds, 10.000 MB memory used
Example Makefile

You can add the following Makefile to your project for easy generation of php-cs-fixer.

ifneq (,)
.error This Makefile requires GNU Make.
endif

.PHONY: lint _lint-pcf _update-pcf

CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
PCF_VERSION = 2

lint:
	@echo "################################################################################"
	@echo "# Linting Stage"
	@echo "################################################################################"
	@$(MAKE) --no-print-directory _lint-pcf

_lint-pcf: _update-pcf
	@echo "------------------------------------------------------------"
	@echo " PHP Code Style Fixer"
	@echo "------------------------------------------------------------"
	@if docker run --rm \
		-v $(CURRENT_DIR):/data \
		cytopia/php-cs-fixer:$(PCF_VERSION) \
		fix --dry-run --diff .; then \
		echo "OK"; \
	else \
		echo "Failed"; \
		exit 1; \
	fi

_update-pcf:
	docker pull cytopia/php-cs-fixer:$(PCF_VERSION)
Travis CI integration
---
sudo: required
language: minimal
services:
  - docker
script:
  - make lint
Docker images

Save yourself from installing lot's of dependencies and pick a dockerized version of your favourite linter below for reproducible local or remote CI tests:

GitHubDockerHubTypeDescription
awesome-ciaci-hub-imgBasicTools for git, file and static source code analysis
file-lintflint-hub-imgBasicBaisc source code analysis
linkchecklinkcheck-hub-imgBasicSearch for URLs in files and validate their HTTP status code
ansibleansible-hub-imgAnsibleMultiple versions and flavours of Ansible
ansible-lintalint-hub-imgAnsibleLint Ansible
gofmtgfmt-hub-imgGoFormat Go source code [1]
goimportsgimp-hub-imgGoFormat Go source code [1]
golintglint-hub-imgGoLint Go code
eslintelint-hub-imgJavascriptLint Javascript code
jsonlintjlint-hub-imgJSONLint JSON files [1]
kubevalkubeval-hub-imgK8sLint Kubernetes files
checkmakecm-hub-imgMakeLint Makefiles
phpcbfpcbf-hub-imgPHPPHP Code Beautifier and Fixer
phpcspcs-hub-imgPHPPHP Code Sniffer
phplintplint-hub-imgPHPPHP Code Linter [1]
php-cs-fixerpcsf-hub-imgPHPPHP Coding Standards Fixer
banditbandit-hub-imgPythonA security linter from PyCQA
blackblack-hub-imgPythonThe uncompromising Python code formatter
mypymypy-hub-imgPythonStatic source code analysis
pycodestylepycs-hub-imgPythonPython style guide checker
pydocstylepyds-hub-imgPythonPython docstyle checker
pylintpylint-hub-imgPythonPython source code, bug and quality checker
terraform-docstfdocs-hub-imgTerraformTerraform doc generator (TF 0.12 ready) [1]
terragrunttg-hub-imgTerraformTerragrunt and Terraform
terragrunt-fmttgfmt-hub-imgTerraformterraform fmt for Terragrunt files [1]
yamlfmtyfmt-hub-imgYamlFormat Yaml files [1]
yamllintylint-hub-imgYamlLint Yaml files

[1] Uses a shell wrapper to add enhanced functionality not available by original project.

Makefiles

Visit cytopia/makefiles for dependency-less, seamless project integration and minimum required best-practice code linting for CI. The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else.

:page_facing_up: License

MIT License

Copyright (c) 2019 cytopia

Tag summary

Content type

Image

Digest

sha256:4681712ca

Size

36.2 MB

Last updated

almost 3 years ago

Requires Docker Desktop 4.37.1 or later.