PHPackages                             suilven/php-travis-enhancer - 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. suilven/php-travis-enhancer

ActiveProject[Testing &amp; Quality](/categories/testing)

suilven/php-travis-enhancer
===========================

Add code quality tools for PHP analysis, and search for code duplication

1.0.3(5y ago)0295[3 issues](https://github.com/gordonbanderson/php-travis-enhancer/issues)1MITPHPCI failing

Since Jun 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/gordonbanderson/php-travis-enhancer)[ Packagist](https://packagist.org/packages/suilven/php-travis-enhancer)[ RSS](/packages/suilven-php-travis-enhancer/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (11)Versions (6)Used By (1)

PHP Travis Enhancer
===================

[](#php-travis-enhancer)

[![Build Status](https://camo.githubusercontent.com/4230b716fcdfd8c1f584d3f41afd18e816e20563a2cdb1d11e4133991a97ce34/68747470733a2f2f7472617669732d63692e6f72672f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e6365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gordonbanderson/php-travis-enhancer)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8bd3991722f96678ae4b6c8c1ba657d9a993d481266cbfb4c30498d23523a957/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e6365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gordonbanderson/php-travis-enhancer/?branch=master)[![codecov.io](https://camo.githubusercontent.com/4b695dbc92173f85de9e391ee04c695bf22464f338d3f2b5ae243c2b54d191a0/68747470733a2f2f636f6465636f762e696f2f6769746875622f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e6365722f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/gordonbanderson/php-travis-enhancer?branch=master)

[![Latest Stable Version](https://camo.githubusercontent.com/2ea55c65574baf9463f034a9b59928adfa39430d0620095afe11b706fe7780d8/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f7068702d7472617669732d656e68616e6365722f76657273696f6e)](https://packagist.org/packages/suilven/php-travis-enhancer)[![Latest Unstable Version](https://camo.githubusercontent.com/ed96b4b9bb8d2f9ec6005eab73e871f1cd80b9b867018603ce96f8c519e98696/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f7068702d7472617669732d656e68616e6365722f762f756e737461626c65)](//packagist.org/packages/suilven/php-travis-enhancer)[![Total Downloads](https://camo.githubusercontent.com/e39f60a25047280c0f7829ef7e6b9d38e4fdbb4ea1f804895efac97e69716141/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f7068702d7472617669732d656e68616e6365722f646f776e6c6f616473)](https://packagist.org/packages/suilven/php-travis-enhancer)[![License](https://camo.githubusercontent.com/51cc23526b2b7be692a7ce8207a81c82b6814566b126231f93a620e4f6b409d9/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f7068702d7472617669732d656e68616e6365722f6c6963656e7365)](https://packagist.org/packages/suilven/php-travis-enhancer)[![Monthly Downloads](https://camo.githubusercontent.com/7a76bd3120f9037c567096c068d10faa192a7c97567a8e83fa94c0fbb5aecb39/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f7068702d7472617669732d656e68616e6365722f642f6d6f6e74686c79)](https://packagist.org/packages/suilven/php-travis-enhancer)[![Daily Downloads](https://camo.githubusercontent.com/774658be61354e6b0d1c70557db889a3924f82a32c1902865056b3504b613312/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f7068702d7472617669732d656e68616e6365722f642f6461696c79)](https://packagist.org/packages/suilven/php-travis-enhancer)[![composer.lock](https://camo.githubusercontent.com/9afc788aa90ee40c63d799cc6ca68cd97c9bd9baeae7520b05130d8d90543ab6/68747470733a2f2f706f7365722e707567782e6f72672f7375696c76656e2f7068702d7472617669732d656e68616e6365722f636f6d706f7365726c6f636b)](https://packagist.org/packages/suilven/php-travis-enhancer)

[![GitHub Code Size](https://camo.githubusercontent.com/0217ce54b746668cd5f84851f8d27d9d10d54039699bf65a2e8e3fcc6458cc1a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e636572)](https://github.com/gordonbanderson/php-travis-enhancer)[![GitHub Repo Size](https://camo.githubusercontent.com/69ba1d04dbd530714b6f1cc6dded0e34ab65c73402358356814df9b1f282f329/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e636572)](https://github.com/gordonbanderson/php-travis-enhancer)[![GitHub Last Commit](https://camo.githubusercontent.com/418a962c736e5761844c4fe193910b0e9c3008fa9faad9672362c30c4ba1339c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e636572)](https://github.com/gordonbanderson/php-travis-enhancer)[![GitHub Activity](https://camo.githubusercontent.com/7ddea66225d864ea1a3e936fe6750a011b959184be32539e386d44391709c65b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6d6d69742d61637469766974792f6d2f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e636572)](https://github.com/gordonbanderson/php-travis-enhancer)[![GitHub Issues](https://camo.githubusercontent.com/1fd7a0db61a6301ea85dd8f0933714cfdfb5e67635f652cf7929955435109506/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e636572)](https://github.com/gordonbanderson/php-travis-enhancer/issues)

[![codecov.io](https://camo.githubusercontent.com/06e0348356a9b396bfbf66225d3fb5e14b02b3a58c6d54cd25b1578f3dbd70fc/68747470733a2f2f636f6465636f762e696f2f6769746875622f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e6365722f6272616e63682e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/06e0348356a9b396bfbf66225d3fb5e14b02b3a58c6d54cd25b1578f3dbd70fc/68747470733a2f2f636f6465636f762e696f2f6769746875622f676f72646f6e62616e646572736f6e2f7068702d7472617669732d656e68616e6365722f6272616e63682e7376673f6272616e63683d6d6173746572)

Add stricter PHPStan and PHPCS coding standard checks, linting, Psalm standards checking, and detection of code duplication to your PHP projects.

---

Usage
=====

[](#usage)

Introduction
------------

[](#introduction)

The goal of this package is to add strict coding checks to your PHP packages. I'd added these tasks manuallly to a couple of modules manually, and decided it was time to automate this as far as possible. Hence the existence of this package.

Any or all of the following coding checks can be added:

- lint - simply parses your PHP code looking for syntax errors, the build will break if there are some
- phpcs - checks PHP code against a subsection of the Slevomat coding standards. Some of the checks oppose each other, I have commented those out in `ruleset.xml` that break code fixing. Automated fixes can then be achieved using `composer fixcs`, but some kinds of fixes can only be done manually.
- phpstan - run PHPStan, a static PHP analysis tool, over your codebase. I have set the level to a fairly strict value of 6, you may wish to manually change this
- psalm - run Psalm, an alternative static analysis checker. Note this is somewhat strict regarding PHPDoc, which hey is a good thing.
- duplication - this is provided as an extra check for Travis, the build will fail if swathes of duplicate code is found.

Warning!!
---------

[](#warning)

Note that this module alters your codebase, as such run this on a backed up source tree, preerably in a separate branch from master so that a pull request can later be submitted.

*The following files are altered*

- `travis.yml` - additional code quality checks added to the matrix, install and running steps
- `composer.json` - packages required for code checking, scripts to run code checks
- `ruleset.xml` - Based on PSR2 but with the addition of the Slevomat coding standards
- `tests/phpstan.neon` - basic config file for phpstan to autoload files

Adding Code Checking Tools
--------------------------

[](#adding-code-checking-tools)

### Installation

[](#installation)

```
composer require --dev suilven/php-travis-enhancer
```

### Adding All Checks

[](#adding-all-checks)

This will take several minutes to run. If identical flags already exist, ditto coomposer script names, then these are left as is in `.travis.yml` and `composer.json` respecctively.

```
vendor/bin/phpte all
```

Adding Individual Checks
------------------------

[](#adding-individual-checks)

Checks can be added indiviually if so desired.

```
vendor/bin/phpte phpstan
vendor/bin/phpte phpcs
vendor/bin/phpte lint
vendor/bin/phpte duplication
vendor/bin/phpte psalm
```

Note that the script `checkCode` in the altered composer file will only include the individual command installed.

### Removal

[](#removal)

This module is one shot, as such remove it after being used

```
composer remove suilven/php-travis-enhancer
```

### Checking Code Locally

[](#checking-code-locally)

If the checks were installed using `all` then `composer checkCode` will run through the code checks. It is an alias for

```
composer checkcs && composer lint && composer psalm && composer phpstan
```

If any one of these fail it will exit immediately.

### What Does a Run Look Like?

[](#what-does-a-run-look-like)

This is snipped but hopefully enough to provide context. Here I am testing on an old small SilverStripe module.

```
> composer checkcs
> vendor/bin/phpcs --standard=ruleset.xml --extensions=php --tab-width=4 -sp src tests
EE 2 / 2 (100%)

FILE: /var/www/src/PrevNextSiblingExtension.php
----------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 6 LINES
----------------------------------------------------------------------
  1 | ERROR | [x] Missing declare(strict_types = 1).
    |       |     (SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing)
 10 | ERROR | [ ] Method name "PrevNextSiblingExtension::NextSibling"
    |       |     is not in camel caps format
    |       |     (PSR1.Methods.CamelCapsMethodName.NotCamelCaps)
 10 | ERROR | [x] Expected 2 blank lines after method, found 1.
    |       |     (SlevomatCodingStandard.Classes.MethodSpacing.IncorrectLinesCountBetweenMethods)
 10 | ERROR | [ ] Method
    |       |     \WebOfTalent\PrevNextSibling\PrevNextSiblingExtension::NextSibling()
    |       |     does not have return type hint nor @return
    |       |     annotation for its return value.
    |       |     (SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint)
 13 | ERROR | [x] Useless variable $result.
    |       |     (SlevomatCodingStandard.Variables.UselessVariable.UselessVariable)
 14 | ERROR | [x] Expected 1 lines before "return", found 0.
    |       |     (SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing.IncorrectLinesCountBeforeControlStructure)
 17 | ERROR | [ ] Method name
    |       |     "PrevNextSiblingExtension::PreviousSibling" is not
    |       |     in camel caps format
    |       |     (PSR1.Methods.CamelCapsMethodName.NotCamelCaps)
 17 | ERROR | [ ] Method
    |       |     \WebOfTalent\PrevNextSibling\PrevNextSiblingExtension::PreviousSibling()
    |       |     does not have return type hint nor @return
    |       |     annotation for its return value.
    |       |     (SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint)
 20 | ERROR | [x] Expected 1 lines before "return", found 0.
    |       |     (SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing.IncorrectLinesCountBeforeControlStructure)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

```

### Automatically Fixing Errors

[](#automatically-fixing-errors)

Those errors marked above with an `X` can be automatically fixed.

```
> composer fixcs
> vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --tab-width=4 -sp src tests
FF 2 / 2 (100%)

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
/var/www/src/PrevNextSiblingExtension.php             5      4
/var/www/tests/PrevNextSiblingExtensionTest.php       15     0
----------------------------------------------------------------------
A TOTAL OF 20 ERRORS WERE FIXED IN 2 FILES
----------------------------------------------------------------------

```

### Run Code Check After Automatic Fixing

[](#run-code-check-after-automatic-fixing)

These errors need fixed manually

```
> composer checkcs
> vendor/bin/phpcs --standard=ruleset.xml --extensions=php --tab-width=4 -sp src tests
E. 2 / 2 (100%)

FILE: /var/www/src/PrevNextSiblingExtension.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 10 | ERROR | Method name "PrevNextSiblingExtension::NextSibling" is
    |       | not in camel caps format
    |       | (PSR1.Methods.CamelCapsMethodName.NotCamelCaps)
 10 | ERROR | Method
    |       | \WebOfTalent\PrevNextSibling\PrevNextSiblingExtension::NextSibling()
    |       | does not have return type hint nor @return annotation
    |       | for its return value.
    |       | (SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint)
 18 | ERROR | Method name "PrevNextSiblingExtension::PreviousSibling"
    |       | is not in camel caps format
    |       | (PSR1.Methods.CamelCapsMethodName.NotCamelCaps)
 18 | ERROR | Method
    |       | \WebOfTalent\PrevNextSibling\PrevNextSiblingExtension::PreviousSibling()
    |       | does not have return type hint nor @return annotation
    |       | for its return value.
    |       | (SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint)
----------------------------------------------------------------------

```

Afterthoughts
-------------

[](#afterthoughts)

I've had a go at applying this to a reasonably large codebase (Manticore PHP Search Client) and gave up due to the sheer volume of errors. As such I am uing this with new projects (including this one), and retrofixing old small projects.

---

License
-------

[](#license)

[![License](https://camo.githubusercontent.com/1e1cb7bae9fc55a01fc5443d26e358dc21c129253bcfa9841db85c4f25aa2ecf/687474703a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6d69742d626c75652e7376673f7374796c653d666c61742d737175617265)](http://badges.mit-license.org)

- **[MIT license](http://opensource.org/licenses/mit-license.php)**
- Copyright 2020 © [Gordon Anderson](http://gordonbanderson.com).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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 ~9 days

Total

4

Last Release

2131d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/770fae946ca5ca8f0f1f0179462c84d3ca60e9bd32cac3f522fdb64c2e384789?d=identicon)[suilven](/maintainers/suilven)

---

Top Contributors

[![gordonbanderson](https://avatars.githubusercontent.com/u/7060?v=4)](https://github.com/gordonbanderson "gordonbanderson (30 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/suilven-php-travis-enhancer/health.svg)

```
[![Health](https://phpackages.com/badges/suilven-php-travis-enhancer/health.svg)](https://phpackages.com/packages/suilven-php-travis-enhancer)
```

###  Alternatives

[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[mglaman/phpstan-drupal

Drupal extension and rules for PHPStan

20729.0M123](/packages/mglaman-phpstan-drupal)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69417.9M511](/packages/spatie-phpunit-snapshot-assertions)[liip/test-fixtures-bundle

This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications

1798.3M42](/packages/liip-test-fixtures-bundle)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8017.0M43](/packages/orchestra-workbench)

PHPackages © 2026

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