Skip to content

Add Compiler::validate() standalone validation method #295

Description

@philipobenito

Summary

Add a Compiler::validate() public method that runs the full analysis pipeline without generating code or writing files, returning an AnalysisResult directly.

Context

Currently, the analysis pipeline only runs as part of compile(). Users cannot ask "is my container valid?" without writing a compilation artefact. The --dry-run flag on the CLI comes close but still runs the full compilation; isStale() runs a subset.

A standalone validate() method would allow CI-level assurance without side effects, and could power a --validate CLI flag.

Implementation notes

  • Compiler::validate(Container|string $container): AnalysisResult - accepts a Container instance or bootstrap file path
  • Reuses the existing DefinitionAnalyser::analyse() path
  • AnalysisResult already has hasErrors(), errors, and warnings properties
  • Consider adding hasWarnings() to AnalysisResult for parity with hasErrors()
  • The distinction between warnings (non-fatal) and errors (fatal at compile-time) should be clearly documented

Target

6.1+ minor release

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions