zendframework/zend-coding-standard
Zend Framework Coding Standard ruleset for PHP_CodeSniffer to enforce ZF repository style, with composer scripts for checking (phpcs) and auto-fixing (phpcbf). Note: repository abandoned; moved to laminas/laminas-coding-standard.
#22 refactors documentation. It now follows the PHP-FIG PSR-12 style.
#22 refactors the ruleset. It uses PSR-12 as the base ruleset with these additional rules:
goto language construct SHOULD NOT be used.global keyword MUST NOT be used.PHP_SAPI SHOULD be used instead of the php_sapi_name()
function.declare(strict_types=1) directive MUST be declared and be the first
statement in a file.[...] SHOULD be used instead of list(...).Abstract prefix.Exception suffix.Interface suffix.Trait suffix.self:: MUST be used without spaces
around the scope resolution operator.::class MUST be used instead of __CLASS__,
get_class(), get_class($this), get_called_class(), get_parent_class()
and string reference.$this MUST NOT be called inside a static method or
function.final keyword on methods MUST be omitted in final declared classes.break and continue structures with
a numeric argument argument.continue control structure MUST NOT be used in switch statements,
break SHOULD be used instead.=== instead of ==.&& and || operators SHOULD be used instead of and and or.use MUST be used in closures.# and MUST
NOT be empty. They SHOULD NOT be used for already typehinted arguments,
except arrays.[@param](https://github.com/param), [@return](https://github.com/return) and [@throws](https://github.com/throws) SHOULD not be aligned or
contain multiple spaces between the tag, type and description.[@throws](https://github.com/throws) tags.[@api](https://github.com/api), [@author](https://github.com/author), [@category](https://github.com/category), [@created](https://github.com/created), [@package](https://github.com/package),
[@subpackage](https://github.com/subpackage) and [@version](https://github.com/version) MUST NOT be used in comments. Git commits
provide accurate information.[@var](https://github.com/var) tag MAY be used in inline comments to document the Type
of properties. Single-line property comments with a [@var](https://github.com/var) tag SHOULD
be written as one-liners. The [@var](https://github.com/var) MAY NOT be used for constants.#8 adds some sniffs from webimpress/coding-standard.
#10 adds additional sniffs.
#8 replaces sniffs in favor of webimpress/coding-standard as these are more reliable or fixes more cases.
#10 adds additional sniffs.
#5 adds online documentation: https://docs.zendframework.com/zend-coding-standard/
#5 adds PSR-12 rules.
NOTE: PSR-12 is not finalized. e.g. The ! operator and : placement for
return values are still under discussion. We will change these rules, and,
when PSR-12 is finalized, adapt them.
#5 extends PSR-12 with ZendFramework specific rules:
NOTE: Most of these rules should look familiar as they are already being used in components rewritten for PHP 7.1.
global keyword may not be used.PHP_SAPI constant must be used instead of the php_sapi_name()
function.#.[@api](https://github.com/api), [@author](https://github.com/author), [@category](https://github.com/category), [@created](https://github.com/created), [@package](https://github.com/package),
[@subpackage](https://github.com/subpackage) and [@version](https://github.com/version) may not be used in comments. Git commits
provide accurate information.[@param](https://github.com/param), [@throws](https://github.com/throws) and [@return](https://github.com/return) should not be aligned or
contain multiple spaces between the tag, type and description.[@throws](https://github.com/throws)
tags.[@var](https://github.com/var) tag may be used in inline comments to document the Type of
properties.[@var](https://github.com/var) tag should be written as one-liners.[@see](https://github.com/see), [@copyright](https://github.com/copyright)
and [@license](https://github.com/license). The copyright date should only be adjusted if the file has
changed.::class should be used instead of
__CLASS__, get_class(), get_class($this), get_called_class() and
get_parent_class().= null, must have
the ? symbol present.Throwable instead of Exception.!) operator must be followed by exactly one space.&& and || operators must be used instead of AND and OR.?? should be used when possible.+=, .=) should be used when possible.use.__construct, not after the class.== and != comparison operators should not be used. Use ===
and !== instead.[...] should be used instead of list(...).bool instead of
boolean, int instead of integer, etc. The binary and unset cast
operators are not allowed.; should not be used if they can be omitted.self keyword should be used instead of the current class name, and
should not have spaces around ::.$this.echo, print, return, include, include_once,
require, require_once, and new, should have one space after them.-> should not have any spaces around it.How can I help you explore Laravel packages today?