Repository navigation
docs: explain the design in one page and slim AGENTS.md - #17
Merged
Merged
Conversation
Some reasons for how the package and its tests are built were recorded only in AGENTS.md or in commit messages: why usages carry their files outside dead-code-detector's origins, why the readers do not build on phpstan-drupal's maps, why the result cache hashes paths within the analysed tree, and why rule tests share a container while Twig's keep their own. State each in the docblock or config comment of what it explains: - OriginFiles: dead-code-detector's public origins cannot name a YAML file, and the constructor that could is internal. - ServiceDefinitions and DrupalFiles: what phpstan-drupal's ServiceMap and ExtensionMap lack, and that both are static state. - DrupalFilesResultCacheMetaExtension: the tests excluder judges usages by a wiring file's place in the tree, and relative paths survive the checkout moving. - DeadCodeRuleTestCase: separate containers took more code than the tests, and running one file analyses only its own fixtures. - The Twig tests' neon: bare-name matching would let a template keep another mechanism's fixture alive in the shared analysis. Assisted-by: Claude <noreply@anthropic.com>
The readers and OriginFiles were registered with autowired: false, with no recorded reason. Nothing here depends on it: analysis and tests pass without it. None of the PHPStan extensions this package builds on turns autowiring off, and PHPStan does so only to tell apart several services of one class, which the readers are not. Drop the setting and the step that asked for it. The providers still receive their readers by name. Readers can now be autowired into a site's own providers, as dead-code-detector's own helpers are. Assisted-by: Claude <noreply@anthropic.com>
kasperg
force-pushed
the
docs/design
branch
7 times, most recently
from
October 14, 2026 07:31
1d9bad4 to
f40a4f3
Compare
The reasons for how the package is built were spread over AGENTS.md, docblocks and commit messages. AGENTS.md, which every agent session loads, carried the architecture, the conventions and the cross-cutting rationale, while some reasons were recorded nowhere current: why the analysis is strict, why tests run in random order, and why logic moves out of providers. Add docs/design.md for contributors: - Principles: reuse before building, read the site's files and never a running site, when unsure code is used, and the toolchain decides versions. - Code structure: readers and decisions, thin providers, and the directories. - How each part is checked and tested, as a table with the reason for each check. - The steps for adding a provider, moved from AGENTS.md. Slim AGENTS.md to the documentation pointers and the commands. Reasons tied to one class are in its docblock since the previous commit. The README links to the design page, and docs/extending.md to the provider steps in their new place. Assisted-by: Claude <noreply@anthropic.com>
The README opened with "[shipmonk/dead-code-detector] extension that teaches it…", with no article, so "it" pointed back at a package name inside a link. Open with "A dead-code-detector extension". Assisted-by: Claude <noreply@anthropic.com>
The supported Drupal and PHP versions, and that Drupal 10 is not supported, came after composer require and the neon includes. A Drupal 10 site learned it was unsupported only after trying to install. List the requirements first, under "Requires:". Assisted-by: Claude <noreply@anthropic.com>
The lists under "Supported Drupal mechanisms" began their items in either case, sometimes within one list. Start every item with a capital, as most already did. Assisted-by: Claude <noreply@anthropic.com>
The last Callbacks bullet read "They count from where they appear…; array callables are dead-code-detector's own", leaving unclear what "they" were and what array callables mean for the reader. Split it in two: a callback counts from where its string appears, and array callables such as [$this, 'method'] are dead-code-detector's to handle. Assisted-by: Claude <noreply@anthropic.com>
The README and docs/extending.md told readers to run `phpstan clear-result-cache`, while the README runs PHPStan as vendor/bin/phpstan everywhere else. Without a global PHPStan the command fails. Run it as vendor/bin/phpstan in both. Assisted-by: Claude <noreply@anthropic.com>
The Releases paragraph mixed which commits make which release, what a release produces, and the maintainer's token setup, which only a maintainer needs and which came last. Give each its own bullet. Assisted-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reasons for how the package is built were spread over AGENTS.md, docblocks and commit messages, and some were recorded nowhere current. AGENTS.md, which every agent session loads, carried the architecture, the conventions and the cross-cutting rationale.
This adds
docs/design.mdfor contributors: the principles, the code structure (readers and decisions, thin providers, the directories), a table of how each part is checked and tested with the reason for each check, and the steps for adding a provider. AGENTS.md shrinks to the documentation pointers and the commands.The first three commits:
OriginFilesexists, whyServiceDefinitionsandDrupalFilesdo not build on phpstan-drupal's maps, why the result cache hashes paths within the analysed tree, why rule tests share a container, and why Twig's keep their own.autowired: falseon the readers andOriginFileshad no recorded reason, and nothing depends on it. None of the PHPStan extensions this package builds on turns autowiring off, and PHPStan itself does so only to tell apart several services of one class. Readers can now be autowired into a site's own providers, as dead-code-detector's own helpers are.docs/extending.mdlinks to the provider steps in their new place.Six smaller commits then fix what a review of the README found: the requirements now come before the install steps, the opening sentence has a subject, list items start with a capital, the Callbacks bullet on string callbacks is split, the result-cache command runs through
vendor/bin/phpstan, and the Releases paragraph is a list.The page states reasons without saying where they came from, and gives a tool's rules only by pointing at its configuration. Whether to build on phpstan-drupal's maps is left for a separate discussion; the current reasons sit in the two readers' docblocks.
Verified locally:
make checksandmake lint-commitspass. Removingautowired: falsewas also checked on its own: analysis and all 390 tests pass.make test-mutationwas not run, as no code changed.