Skip to content

Undeclarable vendor classes should become run-time traps instead of aborting the build; per-file exclude for Composer roots #628

Open

Description

@blacktrs

Reported in #614 (item 13, design feedback).

Problem. Composer packages ship one class per supported dependency version and pick one at run time (google/cloud-core Logger/AppEngineFlexFormatter.php Monolog 1/2 variant next to ...V3.php; psy/psysh Readline/Hoa/FileLink.php). php never loads the other variant, so its signature is never checked. Manticore compiles every file and stops:

compile failed: Declaration of LegacyFormatter::format(array $record) must be compatible with LineFormatter::format(LogRecord $r): string

Proposal.

  1. A class that cannot be declared (incompatible signature, missing parent) in a file reached only through Composer autoload is marked undeclarable with the diagnostic kept as a warning; the first new, static call, class_exists-autoload or extends of it throws at run time with the original message — same model as undefined-function traps.
  2. Manifest: per-file / glob exclude inside a Composer root (today only the package-level composer.packages allow-list exists).

Acceptance. The LineFormatter/LegacyFormatter example from #614 builds, prints the LineFormatter result, and new LegacyFormatter throws the declaration error at run time.

Activity

  1. added
    enhancement
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions