Repository navigation
Prepare 0.5.0 - #41
Merged
Merged
Conversation
A module can list folders under nested (or true) and they become the modules Parent.Child. Outside the parent a child does not exist: its classes are the parent's and only the parent's public list exposes them. Inside the parent the public API of each child applies, a child lists its siblings in depends_on, and cycles, the baseline and the reports use the full names. PublicApiPolicy takes the consuming module.
…-module A nested module belongs to its parent, so it may use any class of its ancestors. Selecting a module with --module now also keeps the violations of the modules nested in it.
A new docblocks config key (false by default) makes the extractor read the class names in docblock types as references of kind docblock: @PARAM, @return, @var, @Property*, @method, @throws, @extends, @implements, @use, @mixin, the bound of @template and @phpstan-type, with generics, unions, shapes and callable signatures inside them. Names are resolved with the namespace and imports of the file. Template names, type aliases, pseudo-types and anything that does not parse are never references. The rules treat the new kind like any other. The option is part of the analysis cache fingerprint, the PHPStan rule follows it (and takes a cordon.docblocks parameter), and the position matrix of the oracle gets docblock cells with two more mutations for the calibration.
A docblock mention of the event a listener handles is the listener's reference, so listeners.cycles and listeners.depends_on apply to it. A class that a file uses in code and in a docblock is reported at the line of its first use in code, so docblocks: true does not move a violation and a @cordon-ignore on that line keeps matching. A class named only in docblocks keeps its docblock line.
Cordon\Laravel\Architecture returns the Mermaid flowchart of cordon:graph and the Markdown files of cordon:docs without writing to disk or running a command, so a dashboard can show them through public API. It is the only class that integrations such as the Filament plugin need beyond Cordon\Testing\Cordon.
A page under integrations for the separate package that shows the modules, their graph and their cards in a Filament panel, linked from the sidebar and from the roadmap in the README.
docs() analysed the host paths and cordon:docs did not, so host_access violations reached the README total and the module cards only in the first. Both now call ModuleDocs::files(), which keeps the current cordon:docs output: the modules only, without the code outside them.
A module affected only because it depends on a change now brings its nested modules too, since they use its internals. Without them, --tests skipped their tests.
A project that binds its own DependencyExtractor no longer reuses a cache written by another one.
Reference and TableUse accepted any string as kind. The cache round-trip test now covers the listener, docblock and tables fixtures too.
The label was looked up with string prefixes, so a sibling edge between nested modules showed an interface declared on the parent, which the rules ignore for siblings. It now goes through ModuleMap::visible().
The card listed only what the outside sees. It now also lists what the other modules inside the parent can use.
cordon:graph --format=c4 prints a C4-PlantUML diagram: a container boundary for the application, a component per module with the description of its metadata, a relationship per dependency with its number of references and named interfaces (red with violations), and a boundary per parent for nested modules. cordon:docs --diagrams=c4 also writes it as architecture.puml. Names and descriptions are escaped for PlantUML.
PlantUML ignores UpdateRelStyle emitted after its Rel, and one emitted before it styles every later arrow, so the violating relationships now carry a "violation" tag defined once with AddRelTag. A backslash is followed by a zero-width space so that "App\tenant" is not drawn with a tab. Also fix the docs sentence about what architecture.puml counts.
Without it the label of a parent's named interface was silently dropped for a nested project (Orders -> Billing.Payments lost Billing::Api), and the C4 export did exactly that. The map is now a required argument, before the optional focus, and every caller passes it.
A parent that entered as the parent of an affected child did not bring in its other children, and a module first reached as a parent and later as a dependent never did. A child using its parent is not an edge, so a sibling using the parent's internals was missed from the affected list and from --tests. Every affected module, whatever the reason, now brings in all its nested modules. Over-including a sibling is accepted, missing a test is not.
The extractor ran with the defaults, so the docblocks and tables datasets added nothing to the round-trip. The test now enables both and checks that each fixture really has the references or uses it is there for.
Add external_dependency and tables to the rules tables of the README and the docs site, in the format 0.4.0 introduced, and to the count of built-in rules in the custom-rules guides and the introduction. Update the tests that assert the built-in rule list (RuleSetTest, which 0.4.0 grew) and the nested layers findings (one per class since 0.4.0).
A nested module that layers does not name was skipped by the layers rule, as source and as target, so a child could depend on an upper layer unnoticed. It now takes the layer of its nearest ancestor that layers names, like external_dependency and tables do.
Architecture::docs() and cordon:docs built their own Analyzer without the cache, so each call re-parsed the project. ModuleDocs now takes the module-only snapshot from the Verifier, which shares the extractor with cordon:verify. That run keeps the cached host files instead of dropping them.
…print Docblock references depend on phpdoc-parser and table inference on Laravel's inflector (illuminate/support), so an update of either must not reuse cached analyses.
…l and AGENTS.md The fix-violations skill and AGENTS.md named seven rules. They now cover the two new ones, with how to fix each without just widening packages, and the Parent.Child naming.
…ot and replace Also note in CONTRIBUTING.md and AGENTS.md that PHPStan needs --memory-limit=512M, so composer analyse is the way to run it.
…ache fingerprint illuminate/support has no version of its own in a project with laravel/framework, so the fingerprint held an empty '@' for it and a Laravel upgrade kept the cache. It now reads the version Composer records under 'replaced' or 'provided'.
…lament plugin ships
…there Many tests run bin/cordon or PHPStan in a process of their own. PCOV only measured the test process, so that code counted as uncovered, and a mutant was never applied there. A PHPUnit extension now gives every PHP process the suite starts an ini file through PHP_INI_SCAN_DIR. It prepends a file that applies the mutant and records the coverage of the process, which is then added to the test that started it. composer coverage and composer mutate also lift Composer's 300 second limit, which cut a local mutation run short.
- @cordon-ignore comments through the analysis cache: warm runs, the round trip, and damaged entries. - @phpstan-import-type and the templates of a @method tag in docblocks. - cordon:why for a package that the baseline or a rule turned off keeps out of the report, and without installed.json. - cordon:affected with no module, with a file that does not parse, with a cache it cannot use, and with a tests folder inside another. - The github format for an invalid named interface. - A DB::table chain through a dynamic method, PSR-0 underscores in a namespace, and a classmap entry that is a file.
The tests of nested modules, named interfaces, docblock references and packages.shared now declare the classes they cover, so that their mutants run against them. The score goes from 83.6% to 90.3% (0.4: 90.3%), and the mutants left uncovered are the constants and property defaults, as in 0.4. New tests for the 0.5 survivors that a plausible bug would leave behind: the order and the line of docblock references among the others, the reason and the segment match of the public list of a parent, a class written in another letter case outside the named interfaces, RuleSet::enabled(), the tables rule factory and the non-string entries of packages.shared.
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.
Brings 0.5.0 to
main. The changelog has the full list, and UPGRADE.md covers what you may notice. Nothing is required: with an unchangedconfig/cordon.php, 0.5 gives the same report as 0.4, and every addition is off until it is configured.nestedturns folders of a module into modules such asBilling.Invoices(ADR 0021).interfacesnames part of a module's public API, anddepends_on => ['Catalog::Pricing']limits a dependency to it (ADR 0022).docblocks(ADR 0023, closes Opt-in docblock types #24).cache(ADR 0024).cordon:verify --since=<ref>andcordon:affected, which lists the changed modules, the ones that depend on them and their test folders (ADR 0025).external_dependencyandpackages: limits on the Composer packages a module may use (ADR 0026).tables: a heuristic rule,offby default, for modules that alter, query or point a foreign key at another module's tables (ADR 0027).cordon:graph --format=c4andcordon:docs --diagrams=c4export a C4-PlantUML diagram.Cordon\Laravel\Architecturereturns the graph and the module docs as text. It stays@internaluntil the Filament plugin that uses it is published (ADR 0028).It is a minor version, so a
^0.4constraint will not pick it up without asking.Verification.
The suite passes cold with
--fail-on-warningon PHP 8.4 (1,269 passed) and on PHP 8.2 with--prefer-lowest(1,261 passed, 8 skipped). Since Seed the PHPStan directory cache in cold test runs #40 there is no known warning left. Pint, PHPStan and the docs build pass.Line coverage is 97.5%. Many tests run
bin/cordonor PHPStan in a process of their own, and that code used to count as uncovered (91.6%, below the 95% gate). A PHPUnit extension now records the coverage of those processes and applies the mutant there too. It works throughPHP_INI_SCAN_DIR, so every PHP process the suite starts is included. The coverage gap also hid paths with no test at all. They have tests now:@cordon-ignorethrough the cache,@phpstan-import-type, and somecordon:whyandcordon:affectedcases.The mutation score is 90.3% (0.4: 90.3%, gate 88%). The tests of the 0.5 features now declare the classes they cover. The 0.5 survivors that a plausible bug would leave behind have tests. Those left cannot change behaviour:
UndeclaredDependencyRulelines 63 and 100,LayerRuleline 71: removing the'|'separator or switching the sides of the file and module (or class) key. A file path always ends in.phpand a module or class name cannot contain a dot, so no two pairs join into the same text.UndeclaredDependencyRuleline 110,ReferenceCollectorline 319:= trueto= false. Onlyisset()reads these arrays, and it is true forfalsetoo.ModuleFilterline 36: droppingarray_unique()orarray_values(). The names are only searched within_array(), so a repeated name or a gap in the keys changes nothing.RuleSetline 274: droppingarray_values()from packages.shared. The rule only spreads the list into another one, which renumbers it, and loops over it.RuleSetline 72: another string innew PackageMap('', ''). Without a project path there is noinstalled.jsonto read, under either name.PublicApiPolicyline 133: comparing the prefix with another string than''. An empty prefix cannot match a class either way.ReferenceCollectorline 60: the default of$docblocks. Every caller passes it.Same output as 0.4.0 when the config is unchanged. All 27 fixture apps were run through
verify --format=json,verify --format=text,graph --format=jsonandmoduleswith 0.4.0 and with 0.5. The 108 outputs and exit codes were identical byte for byte. The fixtures that use a new key differ only because 0.4.0 rejects that key. This was measured on the release candidate. Since then only the cache fingerprint (cacheis unset by default), the docblock ofArchitecture, the docs and the tests have changed.The branch was reviewed task by task and once more as a whole.
Not covered: the case studies were not run again with 0.5, so their figures stay those of 0.4.0. The
v0.5.0tag and the release are created after this is merged, so the@v0.5.0examples resolve only from then on.