Skip to content

TypeError in SPCException #852

@jkrzefski

Description

@jkrzefski

This piece of code tries to get the options property from a class within the stack trace.

$options = $reflection->getProperty('options')->getValue();

This code will always produce a TypeError with an error message like this:

Fatal error: Uncaught TypeError: ReflectionProperty::getValue(): Argument #1 ($object) must be provided for instance properties in ...

While the first parameter of ReflectionProperty::getValue() is technically optional, it can actually only be omitted, if the property is static. But \SPC\builder\BuilderBase::$options is in fact not static.

protected array $options = [];

As far as I know, the actual object of that class is not accessible from a stack trace. So, I suggest to make the property static. As I understand it, there will not be multiple instances of \SPC\builder\BuilderBase anyway, since the instance is determined once per execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingkind/frameworkIssues related to CLI app framework

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions