active-record
active-record copied to clipboard
BaseActiveRecordTrait allow attribute setter
| Q | A |
|---|---|
| Is bugfix? | ✔️ |
| New feature? | ❌ |
| Breaks BC? | ✔️❌ (maybe) |
| Fixed issues | comma-separated list of tickets # fixed by the PR, if any |
attribute setter not working, when canSetProperty('passwordRepeat') said true but,
when i do $model->passwordRepeat =$post['password_repeat'] it is throwing
Setting unknown property: app\models\User::passwordRepeat.
the code was using the same technique as Yii2 https://github.com/yiisoft/yii2/blob/97ca1f2b18a301d2e932f8eb4b07410d96a17edb/framework/base/Component.php#L178
PR Summary
-
Enhancing the Setter Method in BaseActiveRecordTrait The modification ensures that a certain method, designed to assign or "Set" a value, gets called if it exists when the core functionality of the program tries to set a value. This helps in enhancing the flexibility of the program as it will be able to handle a more diverse set of scenarios.
-
Check Before Setting Attribute Values This update adds a verification step before assigning a value to an attribute - it checks if the attribute exists in the first place. This significantly boosts the stability of the program as we prevent potential errors that might occur when trying to assign values to non-existent attributes.
Codecov Report
Attention: Patch coverage is 50.00000% with 2 lines in your changes are missing coverage. Please review.
Project coverage is 88.51%. Comparing base (
d2fa237) to head (a0af203). Report is 2 commits behind head on master.
| Files | Patch % | Lines |
|---|---|---|
| src/BaseActiveRecordTrait.php | 50.00% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #298 +/- ##
============================================
- Coverage 88.63% 88.51% -0.12%
- Complexity 575 576 +1
============================================
Files 7 7
Lines 1302 1306 +4
============================================
+ Hits 1154 1156 +2
- Misses 148 150 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Try it now, should work.