Accessing owner on the interface Gitamin\Events\Owner\OwnerEventInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a
concrete implementation of the interface.
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
The property id does not exist on object<Gitamin\Models\Owner>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter _get, this function will be called for any read access on an
undefined variable. You can add the @property annotation to your class or interface to document
the existence of this variable.
<?php/** * @property int $x * @property int $y * @property string $text */classMyLabel{private$properties;private$allowedProperties=array('x','y','text');publicfunction__get($name){if(isset($properties[$name])&&in_array($name,$this->allowedProperties)){return$properties[$name];}else{returnnull;}}publicfunction__set($name,$value){if(in_array($name,$this->allowedProperties)){$properties[$name]=$value;}else{thrownew\LogicException("Property $name is not defined.");}}}
If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
The property user_id does not exist on object<Gitamin\Models\Owner>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter _get, this function will be called for any read access on an
undefined variable. You can add the @property annotation to your class or interface to document
the existence of this variable.
<?php/** * @property int $x * @property int $y * @property string $text */classMyLabel{private$properties;private$allowedProperties=array('x','y','text');publicfunction__get($name){if(isset($properties[$name])&&in_array($name,$this->allowedProperties)){return$properties[$name];}else{returnnull;}}publicfunction__set($name,$value){if(in_array($name,$this->allowedProperties)){$properties[$name]=$value;}else{thrownew\LogicException("Property $name is not defined.");}}}
If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
Both the $myVar assignment in line 1 and the $higher assignment in line 2
are dead. The first because $myVar is never used and the second because
$higher is always overwritten for every possible time line.
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: