1 | <?php |
||
8 | class RackTransformer extends TransformerAbstract |
||
9 | { |
||
10 | /** |
||
11 | * List of resources possible to include. |
||
12 | * |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $availableIncludes = ['warehouse', 'guitars']; |
||
16 | |||
17 | /** |
||
18 | * Turn this item object into a generic array. |
||
19 | * |
||
20 | * @param Rack $rack |
||
21 | * |
||
22 | * @return array |
||
23 | */ |
||
24 | public function transform(Rack $rack) |
||
25 | { |
||
26 | return [ |
||
27 | 'id' => (int) $rack->id, |
||
28 | 'name' => (string) $rack->name, |
||
29 | 'capacity' => (int) $rack->capacity, |
||
30 | 'used' => (int) $rack->used, |
||
31 | 'usage' => (float) $rack->usage, |
||
32 | 'make_id' => (int) $rack->make_id, |
||
33 | 'make' => [ |
||
34 | 'id' => (int) $rack->make->id, |
||
35 | 'name' => (string) $rack->make->name, |
||
36 | ], |
||
37 | ]; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Include warehouse. |
||
42 | * |
||
43 | * @param Rack $rack |
||
44 | * |
||
45 | * @return \League\Fractal\Resource\Collection |
||
46 | */ |
||
47 | public function includeWarehouse(Rack $rack) |
||
51 | |||
52 | /** |
||
53 | * Include guitars. |
||
54 | * |
||
55 | * @param Rack $rack |
||
56 | * |
||
57 | * @return \League\Fractal\Resource\Collection |
||
58 | */ |
||
59 | public function includeGuitars(Rack $rack) |
||
63 | } |
||
64 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: