From 488e21db343b809833090484e28d768f2e350342 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Fri, 1 Aug 2025 11:39:24 +0200 Subject: [PATCH 1/2] Force usage of `Illuminate\Database\Eloquent\Relations\HasOneOrMany::chaperone()` over its alias `inverse()` via PHPStan rule --- CHANGELOG.md | 6 ++++++ rules.neon | 3 +++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc8a073..08f5d0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/laravel-utils/releases). ## Unreleased +## v10.9.0 + +### Added + +- Force usage of `Illuminate\Database\Eloquent\Relations\HasOneOrMany::chaperone()` over its alias `inverse()` via PHPStan rule + ## v10.8.0 ### Changed diff --git a/rules.neon b/rules.neon index dde992d..b0a0074 100644 --- a/rules.neon +++ b/rules.neon @@ -8,6 +8,9 @@ parameters: - method: 'Illuminate\Database\Eloquent\Model::update()' message: 'it assigns attributes through an array and is not type safe, without parameters it is like save().' errorTip: 'Assign attributes through property assignment, then call save(). If your intention was to not save new models, check $exists explicitly.' + - method: 'Illuminate\Database\Eloquent\Relations\HasOneOrMany::inverse()' + message: 'it is an alias for chaperone().' + errorTip: 'Use chaperone() instead.' - method: 'Illuminate\Database\Eloquent\Factories\Factory::createOne()' message: 'creating or filling models through arrays prevents static validation from working.' errorTip: 'Call createOne() without any parameters, use property assignment to fill the model.' From 53fd9304772ed1f5d0098ebfe29a7f89a53612d9 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Fri, 1 Aug 2025 11:42:17 +0200 Subject: [PATCH 2/2] link pr --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08f5d0c..f4c9652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ See [GitHub releases](https://github.com/mll-lab/laravel-utils/releases). ### Added -- Force usage of `Illuminate\Database\Eloquent\Relations\HasOneOrMany::chaperone()` over its alias `inverse()` via PHPStan rule +- Force usage of `Illuminate\Database\Eloquent\Relations\HasOneOrMany::chaperone()` over its alias `inverse()` via PHPStan rule https://github.com/mll-lab/laravel-utils/pull/39 ## v10.8.0