Skip to content
docsv0.24.0

ControllerVerifier

Verifies a class follows one of the two controller conventions {@see Flavor} names, chosen at construction time (default {@see Flavor::Legacy}, matching this class's behavior before F1 — every existing caller that builds `new ControllerVerifier()` with no argument is unaffected): - {@see Flavor::Legacy}: extends the host's `Milpa\app\Providers\BaseController`, calls `parent::__construct()`, and every `#[Route]`-attributed method has an uppercase HTTP verb, a leading-slash path, the `(Request $request, array $params = [])` signature, an `HttpResponse` return type, no debug output, and no (verb, path) collision with a sibling method. Ported 1:1 from the original `scripts/verify-controller.php`. - {@see Flavor::Runtime}: a plain class (NOT extending `BaseController`) with a public `index(ServerRequestInterface $request): ResponseInterface` method — no `#[Route]` attribute (that is legacy-only routing; runtime routes come from a `RouteProviderInterface` plugin, so a `#[Route]` here is flagged as an ignored no-op, not an error), no debug output. Every FQCN this class checks against (`Milpa\app\Providers\BaseController`, `Milpa\Attributes\Route`, `Psr\Http\Message\ServerRequestInterface`, `Psr\Http\Message\ResponseInterface`) belongs to the generated CODE's target, not to this package — `coa:make controller` scaffolds a class that targets one of them (see the `.stub` templates under `Make/stubs/`), so this verifier closes the loop by checking the scaffolded output against the same convention it was generated for.

ControllerVerifier::__construct()

public function __construct(Milpa\DevTools\Make\Flavor $flavor = Milpa\DevTools\Make\Flavor::Legacy):

Parameters

Parameters of __construct()
NameTypeDescription
$flavorMilpa\DevTools\Make\Flavor

ControllerVerifier::verify()

public function verify(string $fqcn): Milpa\DevTools\Verify\VerificationResult

Reflects `$fqcn` and checks it against the constructor-selected {@see Flavor}'s convention.

Parameters

Parameters of verify()
NameTypeDescription
$fqcnstring