Files
dgarcia 807992ecab
Tests / PHP 8.4 (push) Failing after 1m26s
refactor!: require PHP 8.4
Drop support for PHP 8.3 and lower. The package now declares >=8.4, and CI runs
only on 8.4.

- composer.json: require php >=8.4.
- mago.toml: php-version = "8.4", matching the minimum supported version.
- phpstan.neon: phpVersion 80400.
- Upgrade phpstan/phpstan to ^2.3: 1.x cannot parse `new Foo()->bar()`, which the
  8.4 formatter now emits.
- Narrow ArrayGateway::count() to int, matching what the fixture actually returns.
- CI: single PHP 8.4 job using the php:8.4-cli container instead of setup-php,
  which failed with a TLS handshake timeout on the runner.

BREAKING CHANGE: PHP 8.4 is now required.
2026-11-15 10:58:17 -03:00

97 lines
3.8 KiB
TOML

# Mago toolchain configuration — camelia/controllers
# 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", ".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"]
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: controllers are a thin translation layer whose contract is "every failure becomes a
# typed HTTP error". Annotating @throws on every handler would restate that design instead of
# documenting it. Consumers rely on the error-mapping table, not on per-method annotations.
check-throws = false
# Disabled: the boolean parameters left in the public API describe request data (whether a field is
# nullable, whether a route is the collection root), 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 substr($s, 0, 12) 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 (route
# params, parsed body fields, header maps). isset() is the idiomatic and faster form for that case.
[linter.rules.no-isset]
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
# Metric thresholds are raised on purpose, mirroring ../orm.
#
# Router, CrudController and the CrudController test mirror the public API contract: one method per
# route operation and one test per rule. Splitting them would duplicate the routing and metadata
# plumbing this design deliberately keeps in one place. The same reasoning applies to the request
# value objects, whose constructor parameters are the request parts (method, path, query, body,
# headers, attributes) rather than a control-flow switch.
[linter.rules.too-many-methods]
threshold = 20
[linter.rules.excessive-parameter-list]
threshold = 8
[linter.rules.cyclomatic-complexity]
threshold = 90
method-threshold = 20
# Disabled: every flagged parameter is the `$token` argument of a test closure built to exercise
# BearerAuth. The library marks its own sensitive parameters where they matter; repeating the
# attribute across test doubles adds noise without changing runtime behaviour.
[linter.rules.sensitive-parameter]
enabled = false