# Mago toolchain configuration — camelia/orm # Docs: https://mago.carthage.software # The library promises PHP >= 8.4. php-version = "8.4" [source] paths = ["src", "tests"] includes = ["vendor"] excludes = ["vendor", ".phpunit.cache", ".phpunit.cache.integration", ".mago.cache"] extensions = ["php"] [formatter] print-width = 100 tab-width = 4 use-tabs = false end-of-line = "lf" single-quote = true trailing-comma = true remove-trailing-close-tag = true function-brace-style = "next-line" method-brace-style = "next-line" classlike-brace-style = "always-next-line" # Disabled: this option rewrites `(new Foo())->bar()` into `new Foo()->bar()`, which is a PHP parse # error whenever the result is assigned or returned. Reproduced with mago 1.60.1 on every run, so the # key is turned off until the formatter is fixed upstream. Keep the parentheses: valid PHP. first-method-chain-on-new-line = false [analyzer] # Tests are excluded from the Mago analyzer: they extend PHPUnit\Framework\TestCase and Mago does # not load Composer's autoloader for external packages, so every test would report a false # "non-existent class". PHPStan covers tests with the Composer autoloader available. excludes = ["tests"] baseline = "mago-baseline.toml" find-unused-expressions = true find-unused-definitions = true find-unused-parameters = true strict-list-index-checks = true strict-array-index-existence = true check-missing-type-hints = true check-closure-missing-type-hints = true check-use-statements = true check-property-initialization = true check-dead-catch = true # Disabled: this library's contract is "every failure throws" (see README), so nearly every method # can throw DatabaseException, MetadataException or CriteriaException. Annotating @throws on all of # them would add hundreds of docblocks that restate the design instead of documenting it. Consumers # rely on the typed exception hierarchy, not on per-method annotations. check-throws = false # Metric thresholds are raised on purpose. # # Repository is the facade of the library: its method count mirrors the public API contract # (find*, count, exists, aggregations, page, query, save, create, update, delete, patch, remove and # eager loading). Splitting it would duplicate the metadata and connection plumbing, which is the # duplication this design deliberately removes. The same reasoning applies to Query, which mirrors # the builder surface, and to Model, which holds state plus serialization. [linter.rules.too-many-methods] threshold = 40 [linter.rules.too-many-properties] threshold = 20 [linter.rules.excessive-parameter-list] threshold = 8 [linter.rules.cyclomatic-complexity] threshold = 90 method-threshold = 20 [linter.rules.kan-defect] threshold = 80 # Disabled: the remaining boolean parameters are domain data, not control flow. # # Model::assign($data, bool $rejectGuarded) and TypeCaster::cast(..., bool $nullable) pass a fact # about the column (may it be null, must guarded keys be rejected), not a "do X or do Y" switch. # Splitting them would duplicate every call site for no readability gain. [linter.rules.no-boolean-flag-parameter] enabled = false # Disabled: this rule would turn every integer, bool and null literal argument into a named # argument. For PHP standard-library calls such as array_slice($a, 1) or strpos($s, 'x', 0) the # parameter name adds noise without adding clarity and makes the diff unreadable. [linter.rules.literal-named-argument] enabled = false # Disabled: every isset() here checks key existence in a map whose values are never null (metadata # properties, cached PDO statements, result rows). isset() is the idiomatic and faster form for # that exact case. [linter.rules.no-isset] enabled = false # Disabled: asserts in src/Repository.php are narrowing assertions for the type checker # (assert($relation !== null)), not test assertions. Mago offers no per-path rule scope. [linter.rules.assert-description] enabled = false # Disabled: readability proxies without an actionable change in this codebase. [linter.rules.inline-variable-return] enabled = false [linter.rules.no-multi-assignments] enabled = false # Disabled: Halstead volume/difficulty/effort. They flag TypeCaster::toBool (an explicit conversion # table) and Repository::loadBelongsToMany (a documented three-step pivot load) with no fix that # would improve either one. [linter.rules.halstead] enabled = false