- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2k
 
Closed
Labels
documentationPull requests for documentation onlyPull requests for documentation only
Description
CodeIgniter4 Version
4.1.9
What happened?
When using attributes, as the property/attribute name of the Entity class, the Entity::setAttributes() method is called as a setter.
Names collision.
Steps to Reproduce
$e = new CodeIgniter\Entity\Entity();
$e->a = 1;
$e->attributes = [1, 2, 3];  // called the setAttributes method as a setter.
dd($e->toRawArray());
//$e->toRawArray() array (3)
//   0 => integer 1
//   1 => integer 2
//   2 => integer 3Expected Output
//$e->toRawArray() array (2)
//    a => integer 1
//    attributes => array (3)
//        0 => integer 1
//        1 => integer 2
//        2 => integer 3
Anything else?
In Laravel prior to version 9, the custom setter and getter had the following format:
set/get + AttributeName + Attribute.
public function getFullNameAttribute()
{
    return "{$this->first_name} {$this->last_name}";
}Metadata
Metadata
Assignees
Labels
documentationPull requests for documentation onlyPull requests for documentation only