Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Transformer #41

Open
rulzi opened this issue Mar 23, 2017 · 1 comment
Open

Error in Transformer #41

rulzi opened this issue Mar 23, 2017 · 1 comment

Comments

@rulzi
Copy link

rulzi commented Mar 23, 2017

Warning: Declaration of App\Transformers\DepartementTransformer::transform(App\Model\Departement $departement) should be compatible with PhalconRest\Transformers\ModelTransformer::transform($item) in C:\xampp\htdocs\MiC\app\library\App\Transformers\DepartementTransformer.php

`use App\Model\Departement;
use PhalconRest\Transformers\ModelTransformer;

class DepartementTransformer extends ModelTransformer
{

protected $modelClass = Departement::class;

public function transform(Departement $departement)
{
    return [
        'id' => $this->int($departement->id),
        'name' => $departement->name,
    ];
}

}`

@yemexx1
Copy link

yemexx1 commented Mar 23, 2017

@rulzi This is actually an expected behaviour. If you override a method in a parent class, the method signature has to be the same as it is in the parent class.
The ModelTransformer class already handles what you've done in your transform method.
See a sample usage here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants