Code Monkey home page Code Monkey logo

coding-standard's Introduction

PHP Psalm Type coverage

IxDF Coding Standard for Laravel

An opinionated ruleset focused on strict types. Suitable for both applications and packages.

Installation

  1. Install the package via composer by running:
composer require --dev interaction-design-foundation/coding-standard
  1. Add composer scripts into your composer.json:
"scripts": {
  "cs:check": "phpcs -p -s --colors --report-full --report-summary",
  "cs:fix": "phpcbf -p --colors"
}
  1. Create file phpcs.xml on base path of your repository with content
<?xml version="1.0"?>
<ruleset name="My Coding Standard">
    <!-- Include all rules from the IxDF Coding Standard -->
    <rule ref="IxDFCodingStandard"/>

    <!-- Paths to check -->
    <file>app</file>
    <file>config</file>
    <file>database</file>
    <file>lang</file>
    <file>routes</file>
    <file>tests</file>
</ruleset>

Usage

  • To run checks only:
composer cs:check
  • To automatically fix many CS issues:
composer cs:fix

Ignoring parts of a File

Disable parts of a file:

$xmlPackage = new XMLPackage;
// phpcs:disable
$xmlPackage['error_code'] = get_default_error_code_value();
$xmlPackage->send();
// phpcs:enable

Disable a specific rule:

// phpcs:disable Generic.Commenting.Todo.Found
$xmlPackage = new XMLPackage;
$xmlPackage['error_code'] = get_default_error_code_value();
// TODO: Add an error message here.
$xmlPackage->send();
// phpcs:enable

Ignore a specific violation:

$xmlPackage = new XMLPackage;
$xmlPackage['error_code'] = get_default_error_code_value();
// phpcs:ignore Generic.Commenting.Todo.Found
// TODO: Add an error message here.
$xmlPackage->send();

Development

Versioning

New rules or Sniffs may not be introduced in minor or bugfix releases and should always be based on the develop branch and queued for the next major release, unless considered a bugfix for existing rules.

Reference

Rules can be added, excluded or tweaked locally, depending on your preferences. More information on how to do this can be found here:

coding-standard's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

szepeviktor

coding-standard's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Lock file maintenance

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

composer
composer.json
  • php ^8.2
  • dealerdirect/phpcodesniffer-composer-installer ^1.0
  • slevomat/coding-standard ^8.14
  • squizlabs/php_codesniffer ^3.9
  • phpunit/phpunit ^10.5
  • vimeo/psalm ^5.22
  • friendsofphp/php-cs-fixer ^3.54
github-actions
.github/workflows/format_php.yml
  • actions/checkout v4
  • shivammathur/setup-php v2
  • actions/cache v4
  • actions/cache v4
  • EndBug/add-and-commit v9
.github/workflows/psalm.yml
  • actions/checkout v4
  • chetan/git-restore-mtime-action v2
  • shivammathur/setup-php v2
  • actions/cache v4
  • actions/cache v4
.github/workflows/test.yml
  • actions/checkout v4
  • shivammathur/setup-php v2
  • ramsey/composer-install v2
.github/workflows/validator.yml
  • actions/checkout v4
  • shivammathur/setup-php v2
  • actions/cache v4
  • szepeviktor/phpcs-ruleset-validator v0.4.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.