PHPackages                             soderlind/coding-standard - 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. soderlind/coding-standard

AbandonedArchivedPhpcodesniffer-standard

soderlind/coding-standard
=========================

PHP CodeSniffer sniff that checks if all global PHP functions are fully qualified.

0.0.7(6y ago)1221[1 issues](https://github.com/soderlind/coding-standard/issues)MITPHP

Since Jan 3Pushed 6y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (7)Used By (0)

My PHP CodeSniffer sniff
========================

[](#my-php-codesniffer-sniff)

Sniff
-----

[](#sniff)

`FullyQualifiedGlobalFunctions`, a PHP CodeSniffer sniff that checks if the global PHP functions are missing a backslash.

### Why?:

[](#why)

Function resolution without the backslash forces the PHP globals to verify for each function call if function belongs to current namespace or the global namespace. With the backslash PHP does not check the current namespace and therefore execution is faster.

Install
-------

[](#install)

Install it with `composer require --dev soderlind/coding-standard`

Use
---

[](#use)

Create a `phpcs.xml.dist` in the project root folder. Something like this:

```

	/vendor/*

		Checks if global PHP functions are fully qualified.

```

If you set `onlyOptimizedFunctions` to true, backslash will only be added to [optimized functions](https://github.com/soderlind/coding-standard/blob/master/FullyQualifiedGlobalFunctions/Sniffs/FullyQualifiedGlobalFunctionsSniff.php#L21-L61).

[![#f03c15](https://camo.githubusercontent.com/0f961518a7ec2afddbe358d250696841250391fd10d08f87047ec0e63321be23/68747470733a2f2f706c616365686f6c642e69742f31352f6630336331352f3030303030303f746578743d2b)](https://camo.githubusercontent.com/0f961518a7ec2afddbe358d250696841250391fd10d08f87047ec0e63321be23/68747470733a2f2f706c616365686f6c642e69742f31352f6630336331352f3030303030303f746578743d2b) **NOTE**, `` doesn't work atm. If you want to add backslash only to the optimized functions, [use the command line](#command-line)

### Check

[](#check)

`./vendor/bin/phpcs -p test.php`

```
FILE: test.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 5 | ERROR | [x] Function array_diff() should be referenced via a fully
   |       |     qualified name, e.g.: \array_diff()
 7 | ERROR | [x] Function in_array() should be referenced via a fully qualified
   |       |     name, e.g.: \in_array()
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

```

### Fix

[](#fix)

`./vendor/bin/phpcbf -p test.php`

```
PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
test.php                                              2      0
----------------------------------------------------------------------
A TOTAL OF 2 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------

```

### Command line

[](#command-line)

Instead of adding the rule to your `phpcs.xml.dist` file, you can run it from the command line, e.g.:

`./vendor/bin/phpcbf -p test.php --standard=FullyQualifiedGlobalFunctions --runtime-set onlyOptimizedFunctions true`

License
-------

[](#license)

MIT License

Copyright (c) 2020 Per Søderlind

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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

Every ~1 days

Total

6

Last Release

2322d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1649452?v=4)[Per Søderlind](/maintainers/soderlind)[@soderlind](https://github.com/soderlind)

---

Top Contributors

[![soderlind](https://avatars.githubusercontent.com/u/1649452?v=4)](https://github.com/soderlind "soderlind (43 commits)")

### Embed Badge

![Health badge](/badges/soderlind-coding-standard/health.svg)

```
[![Health](https://phpackages.com/badges/soderlind-coding-standard/health.svg)](https://phpackages.com/packages/soderlind-coding-standard)
```

###  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)[doctrine/coding-standard

The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.

31914.1M739](/packages/doctrine-coding-standard)[cakephp/cakephp-codesniffer

CakePHP CodeSniffer Standards

23711.0M658](/packages/cakephp-cakephp-codesniffer)[drupal/coder

Coder is a library to review Drupal code.

3043.6M461](/packages/drupal-coder)[phpcsstandards/phpcsutils

A suite of utility functions for use with PHP\_CodeSniffer

6233.4M58](/packages/phpcsstandards-phpcsutils)[wp-cli/wp-cli-tests

WP-CLI testing framework

422.7M87](/packages/wp-cli-wp-cli-tests)

PHPackages © 2026

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