đ Dependency Assertions â
dependsOnlyOn() â
You can use regexes to select dependencies.
php
$this
->allClasses()
->should(fn(Expr $expr) => $expr
->dependsOnlyOn(
names: [ArrayAccess::class, /* ... */],
patterns: ['App\Dto.+', /* ... */],
)
);dependsOnlyOnAttribut() â
If you use the rule toHaveAttribute(), they are included by default in the permitted dependencies.
php
$this
->allClasses()
->should(fn(Expr $expr) => $expr
->dependsOnlyOnAttribut(
names: [\Attribute::class, /* ... */],
patterns: ['Attributes\Custom.+', /* ... */],
)
);dependsOnlyOnImplementation() â
If you use the rules toImplement() and toOnlyImplement(), they are included by default in the permitted dependencies.
php
$this
->allClasses()
->should(fn(Expr $expr) => $expr
->dependsOnlyOnImplementation(
names: [\ArrayAccess::class, /* ... */],
patterns: ['Contracts\Dto.+', /* ... */],
)
);dependsOnlyOnInheritance() â
If you use the rule toExtend(), they are included by default in the permitted dependencies.
php
$this
->allClasses()
->should(fn(Expr $expr) => $expr
->dependsOnlyOnInheritance(
names: [Controller::class, /* ... */],
patterns: ['Controllers\Admin.+', /* ... */],
)
);dependsOnlyOnUseTrait() â
If you use the rules toUseTrait() and toOnlyUseTrait(), they are included by default in the permitted dependencies.
php
$this
->allClasses()
->should(fn(Expr $expr) => $expr
->dependsOnlyOnUseTrait(
names: [\HasFactor::class, /* ... */],
patterns: ['Concerns\Models.+', /* ... */],
)
);toNotDependsOn() â
You can use regexes to select dependencies.
php
$this
->allClasses()
->should(fn(Expr $expr) => $expr
->toNotDependsOn(
names: [ArrayAccess::class, /* ... */],
patterns: ['App\Dto.+', /* ... */],
)
);dependsOnlyOnFunction() â
You can use regexes to select dependencies.
php
$this
->allClasses()
->should(fn(Expr $expr) => $expr
->dependsOnlyOnFunction(
names: ['strtolower', /* ... */],
patterns: ['array_.+', /* ... */],
)
);toNotDependsOnFunction() â
Prohibit the use of specific functions. You can use regexes to select dependencies.
php
$this
->allClasses()
->should(fn(Expr $expr) => $expr
->toNotDependsOnFunction(
names: ['goto', /* ... */],
patterns: ['.+exec', /* ... */],
)
);