1 | <?php |
||
30 | class QueryObject extends Select implements QueryObjectInterface |
||
31 | { |
||
32 | |||
33 | /** |
||
34 | * @var RepositoryInterface |
||
35 | */ |
||
36 | protected $repository; |
||
37 | |||
38 | /** |
||
39 | * @var CollectionsMap |
||
40 | */ |
||
41 | protected $collectionsMap; |
||
42 | |||
43 | /** |
||
44 | * For triggering events |
||
45 | */ |
||
46 | use SelectEventTriggers; |
||
47 | |||
48 | /** |
||
49 | * QueryObject has a repository as a dependency. |
||
50 | * |
||
51 | * @param RepositoryInterface $repository |
||
52 | */ |
||
53 | 16 | public function __construct(RepositoryInterface $repository) |
|
62 | |||
63 | /** |
||
64 | * Retrieve all records matching this select query |
||
65 | * |
||
66 | * @return \Slick\Database\RecordList |
||
67 | */ |
||
68 | 8 | public function all() |
|
72 | |||
73 | /** |
||
74 | * Retrieve first record matching this select query |
||
75 | * |
||
76 | * @return EntityInterface|null |
||
77 | */ |
||
78 | 2 | public function first() |
|
85 | |||
86 | /** |
||
87 | * Handles collection add event and updates the cache |
||
88 | * |
||
89 | * @param EntityChangeEventInterface $event |
||
90 | */ |
||
91 | 4 | public function updateCollection(EntityChangeEventInterface $event) |
|
100 | |||
101 | /** |
||
102 | * Execute provided query |
||
103 | * |
||
104 | * @param Select $sql |
||
105 | * |
||
106 | * @return EntityCollection|EntityInterface|\Slick\Orm\EntityMapperInterface[] |
||
107 | */ |
||
108 | 10 | protected function query(Select $sql) |
|
121 | |||
122 | /** |
||
123 | * Executes the provided query |
||
124 | * |
||
125 | * @param Select $sql |
||
126 | * @param string $cid |
||
127 | * |
||
128 | * @return EntityCollection|EntityInterface|\Slick\Orm\EntityMapperInterface[] |
||
129 | */ |
||
130 | 8 | protected function getCollection(Select $sql, $cid) |
|
149 | |||
150 | /** |
||
151 | * Returns the collections map storage |
||
152 | * |
||
153 | * @return CollectionsMap|\Slick\Orm\Entity\CollectionsMapInterface |
||
154 | */ |
||
155 | 10 | protected function getCollectionsMap() |
|
162 | |||
163 | /** |
||
164 | * Register entity events listeners for the provided collection |
||
165 | * |
||
166 | * @param EntityCollection $collection |
||
167 | * @param string $cid |
||
168 | * |
||
169 | * @return self |
||
170 | */ |
||
171 | 8 | protected function registerEventsTo(EntityCollection $collection, $cid) |
|
195 | |||
196 | /** |
||
197 | * Gets the id for this query |
||
198 | * |
||
199 | * @param Select $query |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | 10 | protected function getId(Select $query) |
|
210 | |||
211 | /** |
||
212 | * Registers every entity in collection to the repository identity map |
||
213 | * |
||
214 | * @param EntityCollection $collection |
||
215 | * |
||
216 | * @return self |
||
217 | */ |
||
218 | 8 | protected function updateIdentityMap(EntityCollection $collection) |
|
230 | |||
231 | /** |
||
232 | * Returns the repository that is using this query object |
||
233 | * |
||
234 | * @return RepositoryInterface |
||
235 | */ |
||
236 | 14 | public function getRepository() |
|
240 | |||
241 | /** |
||
242 | * Gets current entity class name |
||
243 | * |
||
244 | * @return string |
||
245 | */ |
||
246 | 8 | public function getEntityClassName() |
|
250 | } |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: