PHPackages                             lamansky/phpcs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. lamansky/phpcs

ActivePhpcodesniffer-standard[Testing &amp; Quality](/categories/testing)

lamansky/phpcs
==============

An opinionated PHP code standard that mostly tries to make sure your PHP doesn’t look too different from other languages in your project.

1.0.0(5y ago)0115MITPHP

Since Aug 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lamansky/phpcs)[ Packagist](https://packagist.org/packages/lamansky/phpcs)[ Docs](https://github.com/lamansky/phpcs)[ RSS](/packages/lamansky-phpcs/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (3)Versions (2)Used By (5)

Lamansky PHP Code Standard
==========================

[](#lamansky-php-code-standard)

Enforces a set of coding style rules on your PHP project using [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).

Highlights
----------

[](#highlights)

This standard is a superset of [PSR-1](https://www.php-fig.org/psr/psr-1/) and adds, among other things, the following rules:

- Must indent with 4 spaces, not tabs.
- Opening braces must be on the same line: `class MyClass {`.
- No assigning variables in `if` statements (e.g. `if ($var = get()) {`).
- No “Yoda” conditions (e.g. `if (true === $var) {`).
- No inline control structures (curly brackets always required).
- No group `use` declarations.
- All methods and class constants must declare visibility.
- All functions must declare a return type.
- Can only declare arrays with `[]`, not `array()`.
- Multi-line array declarations must have trailing commas.
- Single-quote strings must be used where possible.

Installation and Usage
----------------------

[](#installation-and-usage)

You don’t need to install PHP\_CodeSniffer separately. It will be installed when you install this package.

With [Composer](http://getcomposer.org) installed on your computer and initialized for your PHP project, run this command from the terminal in your project’s root directory:

```
composer require --dev lamansky/phpcs
```

Then, in your project’s directory, add a file called `phpcs.xml` that contains the following XML code. (Replace `YourProject` with the name of your project.)

```

```

If you use the [Atom text editor](https://atom.io/), install the [linter](https://atom.io/packages/linter) and [linter-phpcs](https://atom.io/packages/linter-phpcs) packages to get on-the-fly error notices as you code.

Alternatively, you can check for coding errors by running PHP\_CodeSniffer from the terminal in your project’s directory:

```
./vendor/bin/phpcs . -pv --ignore=vendor --extensions=php
```

### Customizing the Rules

[](#customizing-the-rules)

This ruleset contains a few custom rules, but it mostly imports rules from its dependencies.

If you wish to exclude a rule, you can find its `ref` ID in the `Lamansky/ruleset.xml` file and then exclude it in your project’s `phpcs.xml` file, by putting the ID into the `name` attribute of an `exclude` tag like this:

```

```

Some of the rules have settings that you can change to tweak how the rule is evaluated. These settings are declared as public variables in the PHP classes that control the various rules. Here’s an example of setting a value for one of these settings:

```

```

Custom Rules
------------

[](#custom-rules)

Most of the rules are imported from other projects, but there are a few rules that are unique to this project.

### Lamansky.Functions.DeclarationSpace

[](#lamanskyfunctionsdeclarationspace)

Enforces a space between the function name and parameters list when declaring a function: `function abc (...)`. This is a visual cue that helps distinguish a function declaration from a function invocation when skimming code.

### Lamansky.Functions.ReturnType

[](#lamanskyfunctionsreturntype)

This rule performs the following three functions:

- Requires every function to either declare a [return type](https://www.php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration) (e.g. `function abc (...) : string`) or have a docblock `@return` tag.
- Alerts you if a function returns `null` but doesn’t have a nullable return type (e.g. `?string`).
- Alerts you if a function returns a value despite having a `void` return type.

If you wish to allow functions to omit a return type declaration, but wish to retain the other functionality, set the `allowUndeclaredReturnType` property to `true`.

Docblock `@return` tags are supported for cases in which PHP7’s return type declaration support isn’t sufficiently flexible. If your project only supports PHP8 or above, then you can use [union types](https://wiki.php.net/rfc/union_types_v2) and the [`mixed` keyword](https://wiki.php.net/rfc/mixed_type_v2) and probably have no need of the docblock fallback. You can disable it by setting the `requireNativeDeclaration` property to `true`.

Related
-------

[](#related)

- [eslint-config-lamansky](https://github.com/lamansky/eslint-config-lamansky): A code standard for JavaScript.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2106d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c526e960850903d0e2530bbfaac68c57d3d4cfb9df0cbed04435e74ac98a895?d=identicon)[lamansky](/maintainers/lamansky)

---

Top Contributors

[![lamansky](https://avatars.githubusercontent.com/u/10708810?v=4)](https://github.com/lamansky "lamansky (1 commits)")

---

Tags

PHP\_CodeSniffertypehintfunctionsniffsrulesetspacedeclarationreturn type

### Embed Badge

![Health badge](/badges/lamansky-phpcs/health.svg)

```
[![Health](https://phpackages.com/badges/lamansky-phpcs/health.svg)](https://phpackages.com/packages/lamansky-phpcs)
```

###  Alternatives

[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k123.5M1.8k](/packages/slevomat-coding-standard)[dealerdirect/phpcodesniffer-composer-installer

PHP\_CodeSniffer Standards Composer Installer Plugin

596161.9M1.9k](/packages/dealerdirect-phpcodesniffer-composer-installer)[phpcsstandards/phpcsextra

A collection of sniffs and standards for use with PHP\_CodeSniffer.

10224.3M44](/packages/phpcsstandards-phpcsextra)[moxio/php-codesniffer-sniffs

Custom sniffs for PHP\_CodeSniffer

18283.0k3](/packages/moxio-php-codesniffer-sniffs)[consistence/coding-standard

Consistence - Coding Standard - PHP Code Sniffer rules

75833.3k94](/packages/consistence-coding-standard)[youwe/testing-suite

Contains Youwe's default testing packages for php.

13176.9k8](/packages/youwe-testing-suite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
