Skip to content

php: every file's <?php open tag counts branch +1 (ternary ? alternation matches the tag) #2541

Closed

Description

@squid-protocol

Summary

Found by the #1096 control corpus: every PHP file records branch >= 1 from its own <?php open tag — the branch rule's bare ternary ? alternation matches the ? in the tag.

Evidence

finditer on data/php/a.php (a file with zero planted branch keywords) returns ['?']; the end-to-end scan records branch 1. All four corpus php files carry the constant +1 (main 4 = tag + if/else/switch; a/c = 1 = tag alone). Pattern tail: ...|&&|\|\||\?\?|\?.

Impact

A systematic per-file branch inflation on the entire PHP ecosystem — every file's cognitive-load/branch mass is shifted up by its open tag(s), including ?>/<?= variants.

Fix shape

Exclude tag context from the ? alternation (e.g. negative lookbehind for < and lookahead for php|=|>), or strip tags in prism before counting.

References

#1096 corpus ledger php-open-tag-counts-branch; data/php/expected_signals.json bakes the current behavior.

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

    core-engineModifications to the central physics and parsing engine

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions