worksome/coding-style

Worksomes coding style

Installs: 45 490

Dependents: 1

Suggesters: 0

Security: 0

Stars: 7

Watchers: 6

Forks: 0

Open Issues: 0

Type:composer-plugin

v0.6.2 2021-11-29 14:25 UTC

README

Latest Stable Version Total Downloads Latest Unstable Version License

Worksomes Coding Style

This repository contains the coding style followed by Worksome.

It includes configuration for phpcs, phpstan and rector.

Setup

Install this composer package

composer require worksome/coding-style --dev

Run the generate command for generating the config files.

composer generate-coding-style-stubs

Add the following section to your composer.json file

"scripts": {
    "phpcs": "vendor/bin/phpcs",
    "phpcbf": "vendor/bin/phpcbf",
    "phpstan": "vendor/bin/phpstan analyse",
    "rector-ci": "vendor/bin/rector process --dry-run --ansi",
    "rector": "vendor/bin/rector process --ansi"
},

Usage

For using it simply run one of the scripts added to composer.

$ composer phpcs
$ composer phpstan
$ composer rector-ci

Custom PhpStan rules

This section will list all the custom phpstan rules this package adds.

Generic

Rules that are applied to all projects.

NamespaceBasedSuffix (configurable)

Laravel

Rules that are only applied in a Laravel context.

DisallowAppHelperUsage

This rule disallows the usage of laravel's app helper function in favour of using dependency injection instead.

NamespaceBasedSuffix

Sets up configuration for suffixing the following namespaces

  • App\Events: Event
  • App\Listener: Listener
  • App\Policies: Policy
  • App\Jobs: Job

This makes sures events, listeners, policies and jobs has the same suffix.