Skip to content
This repository was archived by the owner on Jul 11, 2024. It is now read-only.
This repository was archived by the owner on Jul 11, 2024. It is now read-only.

PHP Fatal error #44

@Gorbov

Description

@Gorbov

Code:

class DBTest extends \morph\Object
{
    public function __construct($id = null)
    {
        parent::__construct($id);

        $this
            ->addProperty(new \morph\property\Enum('Type', array('Test1','Test2'), ''))
            ->addProperty(new \morph\property\Integer('TestID'))
            ;
    }
}

class DBObject extends \morph\Object
{
    public function __construct($id = null)
    {
        parent::__construct($id);

        $this->collection('Objects');

        $this
            ->addProperty(new \morph\property\Date('Date'))
            ->addProperty(new \morph\property\ComposeOne('Test', 'DBTest'))
            ;
    }
}

$Test = new DBTest();
$Test->Type     = 'Test1';
$Test->TestID   = 123;

$Obj = new DBObject();
$Obj->Date  = time();
$Obj->Test  = $Test;
$Obj->save();

$Temp = $Obj->__toArray(99);

PHP Fatal error: Call to undefined method DBTest::getName() in phar://morph.phar/Object.php on line 233

Error is in __toArray function.

If we will update code (add public function getName()):

class DBTest extends \morph\Object
{
    public function getName(){
        return 'Test';
    }
    public function __construct($id = null)
    {
        parent::__construct($id);

        $this
        ->addProperty(new \morph\property\Enum('Type', array('Test1','Test2'), ''))
        ->addProperty(new \morph\property\Integer('TestID'))
        ;
    }
}

Work fine!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions