Current Behavior
When Flarum\Extend\Model::cast is used to add a custom attribute cast inside a Flarum\Extend\Conditional extender, Static Code Analysis doesn't pick up on it
Steps to Reproduce
Add a cast in extend.php:
(new Extend\Conditional())
->whenExtensionEnabled('acme-foobar', fn () => [
(new Extend\Model(Foo::class))
->cast('bar', 'boolean'),
]),
And try to use it somewhere:
$foo->bar = true
// Access to an undefined property ACME\Foobar\Foo::$bar
Expected Behavior
Static code analysis should pick up on casts inside the conditional extender or cast() should throw an error when used inside a conditional extender to prevent it unexpectedly not working
Screenshots
No response
Environment
- Flarum version: 1.8.16
- Website URL: n.a.
- Webserver: n.a.
- Hosting environment: n.a.
- PHP version: 8.3.31
- Browser: n.a.
Output of php flarum info
No response
Possible Solution
No response
Additional Context
Workaround now is to just always add the casts outside of conditional extenders which has no negative sideffect on runtime logic, however the intent when reading code gets clouded.
I didn't confirm that the issue also happens on Flarum 2.x however I don't recall any changes being made in this area which could address this issue
Current Behavior
When
Flarum\Extend\Model::castis used to add a custom attribute cast inside aFlarum\Extend\Conditionalextender, Static Code Analysis doesn't pick up on itSteps to Reproduce
Add a cast in extend.php:
And try to use it somewhere:
Expected Behavior
Static code analysis should pick up on casts inside the conditional extender or
cast()should throw an error when used inside a conditional extender to prevent it unexpectedly not workingScreenshots
No response
Environment
Output of
php flarum infoNo response
Possible Solution
No response
Additional Context
Workaround now is to just always add the casts outside of conditional extenders which has no negative sideffect on runtime logic, however the intent when reading code gets clouded.
I didn't confirm that the issue also happens on Flarum 2.x however I don't recall any changes being made in this area which could address this issue