Download the PHP package apermo/apermo-coding-standards without Composer

On this page you can find all versions of the php package apermo/apermo-coding-standards. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package apermo-coding-standards

Apermo WordPress Coding Standards

CI codecov Packagist Version PHP Version

Shared PHPCS ruleset for WordPress projects. Combines WordPress Coding Standards, Slevomat type hints, YoastCS, and PHPCompatibility into a single reusable standard.

Requirements

Installation

The Composer Installer Plugin automatically registers the standard with PHPCS.

Usage

Reference the Apermo standard in your project's phpcs.xml:

Then run:

Project Configuration

The Apermo standard includes rules that require project-specific settings. Without these, you either get false positives or miss valid warnings. Copy phpcs.xml.dist.example as a starting point, or add the properties below to your existing phpcs.xml.

Text Domain (text_domain)

WordPress.WP.I18n validates that all translation calls use the correct text domain. Set this to your plugin or theme slug:

Global Prefixes (prefixes)

WordPress.NamingConventions.PrefixAllGlobals checks that global functions, hooks, constants, and namespace declarations use your project prefix. Two entries are needed because the namespace root is PascalCase while the function/hook prefix is snake_case:

The PascalCase entry allows namespace My_Plugin\Admin; but flags namespace Other\Admin;. The snake_case entry validates function names like my_plugin_init() and hook names like my_plugin_loaded.

For nested namespace roots (e.g. a vendor namespace), set the full root:

This allows namespace Acme\My_Plugin\Admin; but flags namespace Acme\Other;.

Minimum WordPress Version (minimum_wp_version)

Controls which WordPress functions are flagged as deprecated. Set this to the oldest WordPress version your project supports:

What's Included

Standard Purpose
WordPress Coding Standards WordPress PHP conventions
Slevomat Coding Standard Type hint enforcement
YoastCS Additional quality rules
PHPCompatibility PHP version compatibility checks

Notable Opinions

REST Permission Callback (Apermo.WordPress.RequireRestPermissionCallback)

Flags register_rest_route() calls without a permission_callback in the args array. Omitting this callback leaves the endpoint open to unauthenticated access — the #1 REST API security hole.

Only array literal args are checked. Variable or function call args are assumed correct (cannot verify statically).

Customization via phpcs.xml:

No Filter Sanitize String (Apermo.PHP.NoFilterSanitizeString)

Flags deprecated PHP filter constants that give a false sense of security:

Constant Deprecated Since Suggested Replacement
FILTER_SANITIZE_STRING PHP 8.1 sanitize_text_field()
FILTER_SANITIZE_STRIPPED PHP 8.1 sanitize_text_field()
FILTER_SANITIZE_MAGIC_QUOTES PHP 7.4 wp_slash()

Customization via phpcs.xml:

Require Option Autoload (Apermo.WordPress.RequireOptionAutoload)

Warns when add_option() or update_option() is called without an explicit autoload parameter. The default behavior loads the option on every page request — a common performance footgun for options that are rarely needed.

Customization via phpcs.xml:

Exit Usage (Apermo.PHP.ExitUsage)

Enforces exit() as the canonical form. Flags die, die(), and bare exit (without parentheses). Auto-fixable with phpcbf.

Customization via phpcs.xml:

Minimum Variable Name Length (Apermo.NamingConventions.MinimumVariableNameLength)

Warns on variable names shorter than 4 characters (excluding $). Common short names are allowed by default: i, id, key, url, row, tag, map, max, min, sql, raw.

Customization via phpcs.xml:

Text Domain Validation

WordPress.WP.I18n text domain checking is active via the WordPress ruleset. See Project Configuration for setup instructions.

Forbidden Nested Closures (Apermo.Functions.ForbiddenNestedClosure)

Closures and arrow functions nested inside other closures or arrow functions are warned. Extract the inner callback to a named function instead.

Customization via phpcs.xml:

Commented-Out Code (Apermo.PHP.ExplainCommentedOutCode)

Commented-out PHP code in // comments must be preceded by a /** */ doc-block explanation starting with a recognized keyword:

Keyword Intent
Disabled Temporarily turned off, will be re-enabled
Kept Intentionally preserved as reference or rollback
Debug Diagnostic code kept for future troubleshooting
Review Seen but needs human review before deciding
WIP Work in progress, actively being developed

Examples:

An optional date in YYYY-MM-DD format can be added in parentheses after the keyword.

Supersedes Squiz.PHP.CommentedOutCode — that rule is disabled automatically.

Customization via phpcs.xml:

Multiple Empty Lines (Apermo.WhiteSpace.MultipleEmptyLines)

No more than one consecutive empty line is allowed outside functions and closures. Inside functions, Squiz.WhiteSpace.SuperfluousWhitespace already enforces this.

Auto-fixable with phpcbf.

Customization via phpcs.xml:

Require Not Include (Apermo.PHP.RequireNotInclude)

include and include_once are forbidden because they silently continue on failure. Use require/require_once instead.

Not auto-fixable (changing include to require may alter behavior).

Use // phpcs:ignore Apermo.PHP.RequireNotInclude to suppress when include is genuinely intended.

Separate error codes (IncludeFound, IncludeOnceFound) allow independent configuration:

Array Complexity (Apermo.DataStructures.ArrayComplexity)

Flags deeply nested or wide associative arrays that would benefit from typed objects (DTOs, value objects). Arrays with many string keys or deep nesting often indicate data structures that should be classes.

Three independent checks. The first two apply to array literals (advisory, since literals often mirror external WordPress API shapes the caller does not own). The third applies to custom function, method, and closure parameters whose default value or PHPStan/Psalm @param array{...} shape is complex — those are errors, because the signature author owns the shape and can refactor to a DTO.

Check Warning Error Default threshold Applies to
Literal nesting depth TooDeep TooDeepError warn > 3, error > 5 Array literals
Literal key count TooManyKeys TooManyKeysError warn > 10, error > 20 Array literals
Parameter shape — ComplexParameterKeys / ComplexParameterDepth error > 5 keys, error > 2 depth Custom function/method/closure params

Default thresholds for literals are tuned so idiomatic WordPress usage (a WP_Query call with meta_query, a 7-key arg set to register_post_type, etc.) stays silent. Genuinely monolithic shapes still surface.

Only outermost literal arrays are checked — nested sub-arrays are not reported separately. Numeric arrays (without =>) are ignored entirely. The canonical fix for a literal TooDeep warning is to extract the complex sub-array into its own variable.

Customization via phpcs.xml:

Global Post Access (Apermo.WordPress.GlobalPostAccess)

Flags global $post; inside functions, methods, closures, and arrow functions. Top-level (template) usage is allowed because the WordPress loop sets $post there. Functions should receive WP_Post or a post ID as a parameter.

Implicit Post Function (Apermo.WordPress.ImplicitPostFunction)

Flags WordPress template functions called without an explicit post argument inside function scopes. These functions implicitly read the global $post, creating hidden dependencies.

Severity depends on what was passed, not which function:

Code Severity When
MissingArgument error Post param exists but no argument provided
NullArgument error Literal null passed as post argument
IntegerArgument warning Literal int or $var->ID passed (except get_post(), where the int overload triggers a fresh DB fetch)
NoPostParameter error Function has no post param at all

Customization via phpcs.xml:

Forbidden stdClass (Apermo.PHP.ForbiddenObjectCast + SlevomatCodingStandard.PHP.ForbiddenClasses)

Discourages stdClass usage in favor of typed classes. Two rules work together:

Both emit warnings (not errors) to allow gradual migration.

Customization via phpcs.xml:

Hook Documentation (Apermo.Hooks.RequireHookDocBlock)

WordPress hook invocations (do_action, apply_filters, and their _ref_array and _deprecated variants) must be preceded by a PHPDoc block.

The sniff checks:

Code When
Missing No PHPDoc block before the hook call
MissingParam Hook passes arguments but doc block has no @param tags
MissingReturn apply_filters* call without a @return tag

All violations are errors.

Customization via phpcs.xml:

Docblock Summary Style (Apermo.Commenting.DocSummaryStyle)

Enforces third-person singular docblock summaries per the WordPress PHP Documentation Standards. The rule of thumb: prepending "It" to the summary must read grammatically — Displays the post title. ("It displays…") passes; Display the post title. ("It display…") does not.

Applies to function, method, class, interface, trait, and enum docblocks. Property, constant, and bare-variable docblocks are skipped — their summaries are idiomatically noun-form.

Three layered checks, evaluated in order. First match wins.

Code When
AntiPattern First phrase matches a known bad opener (Allows you to…, Lets you…, Used to…, This function/method/class…)
BareInfinitive First word is a bare-infinitive verb whose third-person form adds -es (Process, Pass, Fix, Focus, Access, …)
NotThirdPerson First word does not end in s and is not on the whitelist

Whitelist (pass-through): Callback, Wrapper, Helper, Utility, Alias, Shortcut. Common noun-lead openers that WordPress style tolerates.

All violations are warnings. No autofixer — rewriting verb forms reliably requires handling irregulars (Do→Does, Have→Has, Go→Goes) that a naive +s rule gets wrong.

Customization via phpcs.xml:

Consistent Assignment Alignment (Apermo.Formatting.ConsistentAssignmentAlignment)

Consecutive assignment statements must use a consistent style: either all = operators are aligned to the same column, or all use a single space before =. Mixing styles within a group is warned. Auto-fixable with phpcbf — deviators are adjusted to match the majority style.

Groups where all operators are aligned but padded beyond the longest variable + 1 space are flagged as OverAligned errors (not auto-fixable).

A group of assignments breaks on: blank lines, non-assignment statements, or EOF.

Supersedes Generic.Formatting.MultipleStatementAlignment — that rule is disabled automatically.

Customization via phpcs.xml:

Consistent Double Arrow Alignment (Apermo.Arrays.ConsistentDoubleArrowAlignment)

Multi-line associative arrays must use a consistent => style: either all arrows are aligned to the same column, or all use a single space before =>. Mixing styles within an array is warned. Auto-fixable with phpcbf — deviators are adjusted to match the majority style.

Arrays where all arrows are aligned but padded beyond the longest key + 1 space are flagged as OverAligned errors (not auto-fixable).

Only outermost arrays are checked — nested sub-arrays are analyzed independently. Single-line arrays are skipped.

Supersedes WordPress.Arrays.MultipleStatementAlignment — that rule is disabled automatically.

Customization via phpcs.xml:

Elseif Over Else If (PSR2.ControlStructures.ElseIfDeclaration)

else if must be written as elseif. Upgraded from the PSR2 default warning to an error.

Auto-fixable with phpcbf.

Custom Sniffs

Place custom sniffs in Apermo/Sniffs/<Category>/<SniffName>Sniff.php. PHPCS discovers them automatically.

Example: Apermo/Sniffs/Naming/FunctionPrefixSniff.php is referenced as Apermo.Naming.FunctionPrefix.

Contributing

Development

Release Process

  1. Create a release/X.Y.Z branch from main
  2. Update CHANGELOG.md with the version heading and release date
  3. Open a PR — CI runs tests, PHPStan, and validates the changelog
  4. Merge the PR — GitHub Actions creates a draft release with the tag
  5. Review and publish the draft release on GitHub

AI Disclaimer

This project is developed with major assistance from Claude Code (Anthropic). Claude handles the bulk of the implementation — writing sniffs, tests, fixtures, CI workflows, and documentation — while the maintainer reviews, steers, and makes final decisions. Projects with stricter rules regarding the use of AI-generated code should refrain from forking or reusing code from this repository.

License

MIT


All versions of apermo-coding-standards with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
squizlabs/php_codesniffer Version ^3.13.6
wp-coding-standards/wpcs Version ^3.4.1
slevomat/coding-standard Version ^8.0
yoast/yoastcs Version ^3.0
phpcompatibility/phpcompatibility-wp Version ^2.1
dealerdirect/phpcodesniffer-composer-installer Version ^1.0
automattic/vipwpcs Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package apermo/apermo-coding-standards contains the following files

Loading the files please wait ...