umanit / dev-bundle
Helper classes and dependencies for usual dev environment
2.2.0
2026-04-23 14:49 UTC
Requires
- php: ^8.2
- dama/doctrine-test-bundle: ^8.3
- doctrine/doctrine-bundle: ^2.8
- doctrine/orm: ^2.14|^3.5
- mockery/mockery: ^1.6
- nikic/php-parser: ^5.4
- php-parallel-lint/php-parallel-lint: ^1.4
- phparkitect/phparkitect: ^0.5.4
- phpro/grumphp: ^2.12
- phpstan/phpstan: ^2.0
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.5
- slevomat/coding-standard: ^8.19
- spatie/phpunit-watcher: ^1.24
- squizlabs/php_codesniffer: ^4.0
- symfony/framework-bundle: ^6.4|^7.3
- umanit/coding-standard: ^1.0
- vincentlanglet/twig-cs-fixer: ^3.5
- zenstruck/foundry: ^2.4
- zenstruck/mailer-test: ^1.4
- zenstruck/messenger-test: ^1.11
README
This bundle is used for development at UmanIT.
It provides multiple tools and rules to ease development.
PHP Arkitect
Rules for PHP Arkitect:
NotAbuseFinalUsage: Disallow to use final classes if at least one public method of your class is called in another public method of the same class.NotUseConcreteWhenInterfaceExists: Disallow the use of a concrete class inside typehint if an interface exists for tha class.NotUseGenericException: Disallow the use of generic\Exceptionclass.
Usage
Edit your arkitect.php file to include the following:
use Arkitect\Expression\ForClasses\ResideInOneOfTheseNamespaces;
use Umanit\DevBundle\Arkitect\Expression\ForClasses\NotAbuseFinalUsage;
use Umanit\DevBundle\Arkitect\Expression\ForClasses\NotUseGenericException;
// [...]
$rules[] = Rule
::allClasses()
->that(new ResideInOneOfTheseNamespaces('App'))
->should(new NotUseGenericException())
->because('we want to force usage of SPL exceptions or custom ones')
;
$rules[] = Rule
::allClasses()
->that(new ResideInOneOfTheseNamespaces('App'))
->should(new NotUseConcreteWhenInterfaceExists())
->because('we want to depend on interfaces, not concrete implementations')
;
$rules[] = Rule
::allClasses()
->that(new ResideInOneOfTheseNamespaces('App'))
->should(new NotAbuseFinalUsage())
->because('we want avoid final classes which reduce extensibility')
;
Foundry
Various tools to ease tests creation:
- A database reseter usable as a Symfony command.
- Some utilities function to ease the creation of entities.
- Possibility to use aliases on Doctrine entities within factories.
- A per-class key/value store accessible via
addToStore/getListFromStore(lists) andsetInStore/getFromStore(scalars), so child factories can accumulate state between persists without declaring static properties (which PHPStan flags on@immutableFoundry factories). The store is reset automatically viaResetInterface.
PHPStan
Rules for PHPStan:
EnsureFunctionBackslashRule: Ensure that some optimizable functions are called with backslash.NoWhereOnQueryBuilderRule: Disallow to usewheremethod onQueryBuilderin favor ofandWhere.
Usage
Edit your phpstan.neon file to include the following:
rules:
- Umanit\DevBundle\PHPStan\Rules\EnsureFunctionBackslashRule
- Umanit\DevBundle\PHPStan\Rules\NoWhereOnQueryBuilderRule
TestUtils
One static method TestUtils::setId to set the id of an entity by reflection. Useful for tests when your entities do
not expose a setId method.
Usage
In your test:
TestUtils::setId($entity, 42);