Search by

Development tools & coding standard scripts for Polymorphine libraries

Package info

github.com/polymorphine/dev

pkg:composer/polymorphine/dev

Statistics

Installs: 1 707

Dependents: 10

Suggesters: 0

Stars: 0

Open Issues: 0

0.8.0 2026-11-23 12:07 UTC

This package is auto-updated.

Last update: 2026-11-23 13:52:51 UTC


README

Latest stable release Build status Coverage status PHP version LICENSE

Development tools & coding standard scripts for Polymorphine libraries

  • PHPUnit testing library with a executable script wrapper for shared config.
  • Combination of PHP-CS-Fixer and CodeSniffer with custom settings and executable wrappers that simplify shared configuration for projects using this package.
  • Package skeleton scripted with Skeletons engine.

Installation with Composer

composer require --dev polymorphine/dev

Project initialization (skeleton)

vendor/bin/polymorphine-skeleton init

After initialization this tool will be run mostly to check project's file consistency. Run help instead of init for more information about this tool.

Composer scripts

To run project tests you could use these composer scripts - see composer.json to learn equivalent tool commands called directly.

Calling these tools from project's root directory would require path to bin directory, like vendor/bin/polymorphine-phpunit instead of polymorphine-phpunit alone. Unless installed globally, there's no point in registering executable paths for each project.

  • PhpUnit tests:
    composer test-php
  • Coding standard tests:
    composer test-cs
  • Project skeleton validation:
    composer test-skeleton

Each tool comes with a wrapper binary that simplifies configuration management & IDE setup (PhpStorm).

PhpUnit

The testing framework comes with polymorphine-phpunit wrapper script that eliminates the need to deploy the same configuration file across multiple projects. Instead it is generated within ignored .dev/cache directory on its first run.

PhpStorm setup

Settings > PHP > Test Frameworks:

  • Add 'PHPUnit local'
  • Select path to phpunit.phar (misleading description) and point to vendor/bin/polymorphine-phpunit binary.
  • Check default configuration file and point to either phpunit.template.xml inside this package or .dev/cache/phpunit.xml inside project root directory (this file will be generated by wrapper script after running PhpUnit manually or with composer test-php command).
  • Add new PhpUnit config in Run/Debug configuration using Defined in the configuration file option and specifying project root directory as Custom working directory.

PHP-CS-Fixer

PHP-CS-Fixer will automatically fix code formatting. Use it through polymorphine-csfixer wrapper script that will load custom Polymorphine configuration (see: cs-fixer.php) shared by all projects.

PhpStorm code inspection setup

Real-time notifications on code formatting might be set up in PhpStorm Settings > PHP > Quality Tools > PHP CS Fixer:

  • Turn on inspection
  • Set path to vendor\bin\polymorphine-csfixer script in ... menu (or polymorphine-csfixer.bat on Windows).
  • Select any ruleset (this setting will be ignored) and run mode.
PhpStorm External tool setup

Alternatively you can setup manual trigger to fix/check current file as external tool in Settings > Tools > External Tools. Here's now to configure php-cs-fixer environment:

  • Program: set path to $ProjectFileDir$\vendor\bin\polymorphine-csfixer (or ...polymorphine-csfixer.bat on Windows)
  • Parameters: set filename with (optional) --fix flag to fix currently opened file: --fix "$FilePathRelativeToProjectRoot$". You might add a copy of the tool without this flag to only check the code formatting.
  • Working directory: set to $ProjectFileDir$
  • You might add keyboard shortcuts to run commands in Settings > Keymap > External Tools

CodeSniffer

CodeSniffer tool is used only because of Fixer limitations. Not every style constraint violation can be automatically fixed, so this tool will inform you about inconsistencies that require manual fixing.CodeSniffer will check style errors that need to be adjusted manually like: naming conventions, line lengths and some phpDoc constraints.

Package provides polymorphine-phpcs binary wrapper that handles shared configuration without affecting project's working directory.

PhpStorm setup (inspection)

Code sniffer does not change the code by itself, so it's better to set is as one of the inspections in Settings > PHP > Quality Tools > PHP_CodeSniffer:

  • Turn on inspection
  • Set path to vendor\bin\polymorphine-phpcs script in ... menu (or polymorphine-phpcs.bat on Windows)
  • Limit file extensions to php
  • Select Custom coding standard and set its path to current project root directory

Setting project root directory as a custom coding standard is a workaround for a globally installed script to find project's root directory (current working directory is not available when script is called by IDE).

CodeSniffer custom PhpDoc requirements

  • Original public API method signatures should include phpDoc block comments. These comments are required for methods with composite type declarations like: callable, Closure, array, iterable, Traversable, Iterator and Generator.

    Original method is the one that introduces new signature - it doesn't override parent's method nor provides implementation for method defined by an interface. In case of traits every public method is considered original API.

  • Composite type declarations must include their internal types or callback signatures, and PhpDoc's @param and @return for these types cannot be omitted - for example:

    /**
     * @param callable(int, Foo\Bar): list<string> $callback Required argument tag
     *
     * @return array<string, Closure(string): ReturnType> Associative map of callables
     */
    public function callbackMap(int $value, callable $callback, Foo\Bar $bar): array