Complex classes like FileDBQueueTransport often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FileDBQueueTransport, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
7 | class FileDBQueueTransport extends AbstractQueueTransport { |
||
8 | const FILE_DB_INDEX_VERSION = 1; |
||
9 | const FILE_DB_CHUNK_VERSION = 1; |
||
10 | |||
11 | protected $_folder; |
||
12 | protected $_mutex_folder; |
||
13 | protected $_prefix; |
||
14 | protected $_name; |
||
15 | protected $_db_file_count = Queue::DefaultDBFileCount; |
||
16 | /** |
||
17 | * @var FileDBQueueConstructionSettings|object |
||
18 | */ |
||
19 | protected $_construction_settings; |
||
20 | |||
21 | /** |
||
22 | * @var FileMutex|null |
||
23 | */ |
||
24 | protected $_producer_mutex = null; |
||
25 | |||
26 | /** |
||
27 | * @var FileMutex|null |
||
28 | */ |
||
29 | protected $_index_mutex = null; |
||
30 | |||
31 | /** |
||
32 | * @var integer[][] Данные с индексом |
||
33 | */ |
||
34 | protected $_index_data = []; |
||
35 | |||
36 | /** |
||
37 | * @var FileDBIndexFile |
||
38 | */ |
||
39 | protected $_index_data_full = null; |
||
40 | |||
41 | /** |
||
42 | * @var boolean Эксклюзивный режим |
||
43 | */ |
||
44 | protected $_exclusive_mode = false; |
||
45 | |||
46 | /** |
||
47 | * @param FileDBQueueConstructionSettings|object $settings |
||
48 | * |
||
49 | * @throws QueueException |
||
50 | */ |
||
51 | 25 | function __construct($settings) { |
|
52 | 25 | if (!isset($settings->storage_type)) { |
|
53 | 24 | $settings->storage_type = Queue::StorageTemporary; |
|
54 | } |
||
55 | 25 | if (!isset($settings->name)) { |
|
56 | 1 | throw new QueueException('Settings don\'t have field name', 11); |
|
57 | } |
||
58 | 24 | $this->_name = $settings->name; |
|
59 | 24 | $this->_construction_settings = $settings; |
|
60 | |||
61 | 24 | $this->set_folder_settings($settings); |
|
62 | 23 | if (isset($settings->prefix)) { |
|
63 | 1 | $this->_prefix = $settings->prefix; |
|
64 | } else { |
||
65 | 22 | $this->_prefix = ''; |
|
66 | } |
||
67 | 23 | if (isset($settings->mutex_folder)) { |
|
68 | 6 | $this->_mutex_folder = $settings->mutex_folder; |
|
69 | } else { |
||
70 | 18 | $this->_mutex_folder = $this->_folder.'/mutex'; |
|
71 | } |
||
72 | 23 | if (isset($settings->db_file_count)) { |
|
73 | 1 | $this->_db_file_count = $settings->db_file_count; |
|
74 | } |
||
75 | 23 | $this->_index_data = array_fill(0, $this->_db_file_count, []); |
|
76 | 23 | } |
|
77 | |||
78 | 86 | function __destruct() { |
|
79 | 86 | if (!is_null($this->_producer_mutex)) { |
|
80 | 76 | $this->_producer_mutex->release_lock(); |
|
81 | } |
||
82 | 86 | if (!is_null($this->_index_mutex)) { |
|
83 | 76 | $this->_index_mutex->release_lock(); |
|
84 | } |
||
85 | 86 | } |
|
86 | |||
87 | 72 | function __clone() { |
|
88 | 72 | parent::__clone(); |
|
89 | 72 | $this->_construction_settings = clone $this->_construction_settings; |
|
90 | 72 | if (isset($this->_producer_mutex)) { |
|
91 | $this->_producer_mutex = clone $this->_producer_mutex; |
||
92 | } |
||
93 | 72 | if (isset($this->_index_mutex)) { |
|
94 | $this->_index_mutex = clone $this->_producer_mutex; |
||
95 | } |
||
96 | 72 | if (isset($this->_index_data_full)) { |
|
97 | $this->_index_data_full = clone $this->_index_data_full; |
||
98 | } |
||
99 | 72 | } |
|
100 | |||
101 | /** |
||
102 | * @param FileDBQueueConstructionSettings|object $settings |
||
103 | * |
||
104 | * @throws QueueException |
||
105 | */ |
||
106 | 24 | protected function set_folder_settings($settings) { |
|
107 | 24 | switch ($settings->storage_type) { |
|
108 | 24 | case Queue::StorageTemporary: |
|
109 | 23 | $this->_folder = sys_get_temp_dir(); |
|
110 | 23 | break; |
|
111 | 2 | case Queue::StoragePersistent: |
|
112 | 1 | $this->_folder = FileMutex::getDirectoryString(); |
|
113 | 1 | break; |
|
114 | default: |
||
115 | 1 | throw new QueueException( |
|
116 | 'Constructor settings is malformed. Storage type can not be equal '. |
||
117 | 1 | $settings->storage_type, 1 |
|
118 | ); |
||
119 | } |
||
120 | 23 | if (isset($settings->folder)) { |
|
121 | 23 | $this->_folder = $settings->folder; |
|
122 | } |
||
123 | 23 | } |
|
124 | |||
125 | /** |
||
126 | * Блокируем index mutex |
||
127 | * |
||
128 | * @param double|integer $time |
||
129 | * |
||
130 | * @return boolean |
||
131 | * @throws \NokitaKaze\Mutex\MutexException |
||
132 | */ |
||
133 | 75 | protected function index_mutex_lock($time = -1) { |
|
134 | 75 | if (!$this->_exclusive_mode) { |
|
135 | 75 | return $this->_index_mutex->get_lock($time); |
|
136 | } else { |
||
137 | 4 | return true; |
|
138 | } |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * Блокируем index mutex |
||
143 | */ |
||
144 | 75 | protected function index_mutex_release_lock() { |
|
149 | |||
150 | /** |
||
151 | * Устанавливаем или снимаем монопольный режим |
||
152 | * |
||
153 | * @param boolean $mode |
||
154 | * @throws \NokitaKaze\Mutex\MutexException |
||
155 | */ |
||
156 | 5 | function set_exclusive_mode($mode) { |
|
157 | 5 | $this->init_producer_mutex(); |
|
158 | 5 | $this->_exclusive_mode = $mode; |
|
159 | 5 | if ($mode) { |
|
160 | 5 | $this->_index_mutex->get_lock(); |
|
161 | } else { |
||
162 | 1 | $this->_index_mutex->release_lock(); |
|
163 | } |
||
164 | 5 | } |
|
165 | |||
166 | /** |
||
167 | * @return iMessage[]|object[] |
||
168 | */ |
||
169 | 71 | protected function get_used_keys_and_real_need_for_save() { |
|
170 | 71 | $real_need_save = []; |
|
171 | 71 | $used_keys = []; |
|
172 | 71 | foreach ($this->_pushed_for_save as &$message) { |
|
173 | 71 | if (is_null($message->name)) { |
|
174 | 69 | $real_need_save[] = $message; |
|
175 | 69 | continue; |
|
176 | } |
||
177 | 54 | if (in_array($message->name, $used_keys)) { |
|
178 | 1 | continue; |
|
179 | } |
||
180 | 54 | foreach ($this->_index_data as $sort_id => &$index_datum) { |
|
181 | 54 | if (array_key_exists($message->name, $index_datum)) { |
|
182 | 54 | continue 2; |
|
183 | } |
||
184 | } |
||
185 | 54 | $used_keys[] = $message->name; |
|
186 | 54 | $real_need_save[] = $message; |
|
187 | } |
||
188 | |||
189 | 71 | return $real_need_save; |
|
190 | } |
||
191 | |||
192 | /** |
||
193 | * Сохраняем все сообщения, подготовленные для сохранения, в файл сообщений |
||
194 | * |
||
195 | * @throws QueueException |
||
196 | * @throws \NokitaKaze\Mutex\MutexException |
||
197 | */ |
||
198 | 72 | function save() { |
|
199 | 72 | if (count($this->_pushed_for_save) == 0) { |
|
200 | 3 | return; |
|
201 | } |
||
202 | 72 | $this->init_producer_mutex(); |
|
203 | |||
204 | 72 | $this->index_mutex_lock(); |
|
205 | 72 | $this->index_data_load(); |
|
206 | 72 | $real_need_save = $this->get_used_keys_and_real_need_for_save(); |
|
207 | 72 | if (count($real_need_save) == 0) { |
|
208 | 1 | $this->index_mutex_release_lock(); |
|
209 | |||
210 | 1 | return; |
|
211 | } |
||
212 | |||
213 | 72 | $this->_producer_mutex->get_lock(); |
|
214 | 72 | $current_thread_id = static::get_current_producer_thread_id(); |
|
215 | 72 | $data_in = $this->get_data_for_thread($current_thread_id); |
|
216 | 72 | foreach ($real_need_save as &$message) { |
|
217 | 72 | if (!isset($message->sort)) { |
|
218 | 1 | $message->sort = 5; |
|
219 | } |
||
220 | // Копируем уже существующий message в data_in |
||
221 | 72 | $data_in[] = (object) [ |
|
222 | 72 | 'name' => $message->name, |
|
223 | 72 | 'data' => $message->data, |
|
224 | 72 | 'time_created' => $message->time_created, |
|
225 | 72 | 'time_last_update' => microtime(true), |
|
226 | 72 | 'time_rnd_postfix' => isset($message->time_rnd_postfix) ? $message->time_rnd_postfix : null, |
|
227 | 72 | 'sort' => $message->sort, |
|
228 | 'is_read' => false, |
||
229 | // @codeCoverageIgnoreStart |
||
230 | ]; |
||
231 | // @codeCoverageIgnoreEnd |
||
232 | 72 | $key = self::get_real_key_for_message($message); |
|
233 | 72 | $this->_index_data[$message->sort][$key] = $current_thread_id; |
|
234 | } |
||
235 | 72 | $this->write_full_data_to_file($current_thread_id, $data_in); |
|
236 | 72 | unset($data_in); |
|
237 | |||
238 | 72 | $this->_producer_mutex->release_lock(); |
|
239 | 72 | $this->index_data_save(); |
|
240 | 72 | $this->index_mutex_release_lock(); |
|
241 | 72 | $this->_pushed_for_save = []; |
|
242 | 72 | } |
|
243 | |||
244 | /** |
||
245 | * Берём данные для конкретного внутренного треда в очереди сообщений |
||
246 | * |
||
247 | * @param integer $thread_id |
||
248 | * |
||
249 | * @return iMessage[]|object[] |
||
250 | * @throws QueueException |
||
251 | */ |
||
252 | 75 | protected function get_data_for_thread($thread_id) { |
|
278 | |||
279 | /** |
||
280 | * Внутренний id треда |
||
281 | * |
||
282 | * @return integer |
||
283 | */ |
||
284 | 43 | protected static function get_current_producer_thread_id() { |
|
287 | |||
288 | /** |
||
289 | * Берём название файла с данными для конкретного внутренного треда в очереди сообщений |
||
290 | * |
||
291 | * @param integer $thread_id |
||
292 | * |
||
293 | * @return string |
||
294 | */ |
||
295 | 75 | protected function get_producer_filename_for_thread($thread_id) { |
|
298 | |||
299 | /** |
||
300 | * Инициализируем мьютекс для текущего треда |
||
301 | */ |
||
302 | 76 | protected function init_producer_mutex() { |
|
303 | 76 | if (is_null($this->_producer_mutex)) { |
|
304 | 76 | $this->_producer_mutex = $this->get_mutex_for_thread(static::get_current_producer_thread_id()); |
|
305 | 76 | $this->_index_mutex = $this->get_index_mutex(); |
|
306 | } |
||
307 | 76 | } |
|
308 | |||
309 | /** |
||
310 | * @return string |
||
311 | */ |
||
312 | 76 | function get_mutex_folder() { |
|
315 | |||
316 | /** |
||
317 | * Мьютекс для конкретного треда |
||
318 | * |
||
319 | * @param integer $thread_id |
||
320 | * |
||
321 | * @return FileMutex |
||
322 | * @throws \NokitaKaze\Mutex\MutexException |
||
323 | */ |
||
324 | 77 | protected function get_mutex_for_thread($thread_id) { |
|
336 | |||
337 | /** |
||
338 | * Создание мьютекса для файла с индексом на всю текущую очередь сообщений |
||
339 | * |
||
340 | * @return FileMutex |
||
341 | * @throws \NokitaKaze\Mutex\MutexException |
||
342 | */ |
||
343 | 77 | protected function get_index_mutex() { |
|
355 | |||
356 | /** |
||
357 | * Сохраняем данные в файл внутреннего треда (без индекса) |
||
358 | * |
||
359 | * @param integer $thread_id |
||
360 | * @param iMessage[]|object[] $data_in |
||
361 | * |
||
362 | * @throws QueueException |
||
363 | */ |
||
364 | 76 | protected function write_full_data_to_file($thread_id, $data_in) { |
|
400 | |||
401 | /** |
||
402 | * Получаем номера DB, в которых лежат сообщения, которые нам надо удалить |
||
403 | * |
||
404 | * @param iMessage[]|object[] $messages |
||
405 | * |
||
406 | * @return string[][]|integer[][] |
||
407 | */ |
||
408 | 40 | protected function get_keys_for_delete_group_by_thread($messages) { |
|
409 | 40 | $keys = []; |
|
410 | 40 | foreach ($messages as &$message) { |
|
411 | 40 | $keys[] = self::get_real_key_for_message($message); |
|
412 | } |
||
413 | 40 | unset($message); |
|
414 | |||
415 | 40 | $threads_keys = array_fill(0, Queue::ProducerThreadCount, []); |
|
416 | 40 | foreach ($this->_index_data as $sort_id => &$index_datum) { |
|
417 | 40 | if (empty($index_datum)) { |
|
418 | 40 | continue; |
|
419 | } |
||
420 | 40 | foreach ($index_datum as $key => &$thread_id) { |
|
421 | 40 | if (in_array($key, $keys)) { |
|
422 | 40 | $threads_keys[$thread_id][] = $key; |
|
423 | 40 | unset($index_datum[$key]); |
|
424 | } |
||
425 | } |
||
426 | } |
||
427 | |||
428 | 40 | return $threads_keys; |
|
429 | } |
||
430 | |||
431 | /** |
||
432 | * Удалить сообщения и сразу же записать это в БД |
||
433 | * |
||
434 | * @param iMessage[]|object[] $messages |
||
435 | * |
||
436 | * @return string[]|integer[] |
||
437 | * @throws \NokitaKaze\Mutex\MutexException |
||
438 | * @throws QueueException |
||
439 | */ |
||
440 | 72 | function delete_messages(array $messages) { |
|
441 | 72 | $this->init_producer_mutex(); |
|
442 | 72 | $this->index_mutex_lock(); |
|
443 | 72 | $this->index_data_load(); |
|
444 | |||
445 | 72 | $threads_keys = $this->get_keys_for_delete_group_by_thread($messages); |
|
446 | |||
447 | 72 | $deleted_keys = []; |
|
448 | 72 | foreach ($threads_keys as $thread_id => &$thread_keys) { |
|
449 | 72 | if (count($thread_keys) == 0) { |
|
450 | 72 | continue; |
|
451 | } |
||
452 | 57 | $mutex = $this->get_mutex_for_thread($thread_id); |
|
453 | 57 | $mutex->get_lock(); |
|
454 | 57 | $data_in = $this->get_data_for_thread($thread_id); |
|
455 | 57 | $u = false; |
|
456 | 57 | foreach ($data_in as $inner_id => &$inner_message) { |
|
457 | 57 | $real_key = self::get_real_key_for_message($inner_message); |
|
458 | 57 | if (in_array($real_key, $thread_keys)) { |
|
459 | 57 | unset($data_in[$inner_id]); |
|
460 | 57 | $deleted_keys[] = $real_key; |
|
461 | 57 | $u = true; |
|
462 | } |
||
463 | } |
||
464 | 57 | if ($u) { |
|
465 | // @hint Это always true condition. Иначе данные неконсистентны |
||
466 | 57 | if (count($data_in) > 0) { |
|
467 | 27 | $this->write_full_data_to_file($thread_id, $data_in); |
|
468 | } else { |
||
469 | 47 | unlink($this->get_producer_filename_for_thread($thread_id)); |
|
470 | } |
||
471 | } |
||
472 | |||
473 | 57 | $mutex->release_lock(); |
|
474 | 57 | $this->index_data_save(); |
|
475 | } |
||
476 | 72 | $this->index_mutex_release_lock(); |
|
477 | |||
478 | 72 | return $deleted_keys; |
|
479 | } |
||
480 | |||
481 | /** |
||
482 | * Обновляем сообщение и сразу же сохраняем всё |
||
483 | * |
||
484 | * Эта функция не рейзит ошибку, если сообщение не найдено |
||
485 | * |
||
486 | * @param iMessage|object $message |
||
487 | * @param string|null $key форсированно задаём ключ сообщения |
||
488 | * |
||
489 | * @return boolean |
||
490 | * @throws QueueException |
||
491 | * @throws \NokitaKaze\Mutex\MutexException |
||
492 | */ |
||
493 | 17 | function update_message($message, $key = null) { |
|
494 | 17 | $this->init_producer_mutex(); |
|
495 | 17 | $this->index_mutex_lock(); |
|
496 | 17 | $this->index_data_load(); |
|
497 | |||
498 | 17 | if (is_null($key)) { |
|
499 | 17 | $key = self::get_real_key_for_message($message); |
|
500 | } |
||
501 | 17 | $exists = false; |
|
502 | 17 | foreach ($this->_index_data as $index_id => &$index_datum) { |
|
503 | 17 | if (!array_key_exists($key, $index_datum)) { |
|
504 | 17 | continue; |
|
505 | } |
||
506 | 17 | $thread_id = $index_datum[$key]; |
|
507 | 17 | $mutex = $this->get_mutex_for_thread($thread_id); |
|
508 | 17 | $mutex->get_lock(); |
|
509 | 17 | $data_in = $this->get_data_for_thread($thread_id); |
|
510 | // Ищем то же сообщение и заменяем его |
||
511 | 17 | $u = $this->change_message_in_array($data_in, $message, $key); |
|
512 | 17 | if ($u) { |
|
513 | 17 | $exists = true; |
|
514 | } |
||
515 | 17 | $this->write_full_data_to_file($thread_id, $data_in); |
|
516 | 17 | $mutex->release_lock(); |
|
517 | 17 | $this->index_data_save(); |
|
518 | 17 | break; |
|
519 | } |
||
520 | 17 | $this->index_mutex_release_lock(); |
|
521 | |||
522 | 17 | return $exists; |
|
523 | } |
||
524 | |||
525 | /** |
||
526 | * @param double|integer $wait_time |
||
527 | * |
||
528 | * @return iMessage|object|null |
||
529 | * @throws \NokitaKaze\Mutex\MutexException |
||
530 | * @throws QueueException |
||
531 | */ |
||
532 | 76 | function consume_next_message($wait_time = -1) { |
|
533 | 76 | $this->set_same_time_flag(2); |
|
534 | 76 | $start = microtime(true); |
|
535 | 76 | $this->init_producer_mutex(); |
|
536 | 76 | $this->index_mutex_lock(); |
|
537 | 76 | $this->index_data_load(); |
|
538 | 76 | while (true) { |
|
539 | 76 | for ($sort_id = 0; $sort_id < $this->_db_file_count; $sort_id++) { |
|
540 | 76 | foreach ($this->_index_data[$sort_id] as $key => $thread_id) { |
|
541 | 72 | if (isset($this->_consumed_keys[$key])) { |
|
542 | 63 | continue; |
|
543 | } |
||
544 | 72 | $mutex = $this->get_mutex_for_thread($thread_id); |
|
545 | 72 | $mutex->get_lock(); |
|
546 | 72 | $data_in = $this->get_data_for_thread($thread_id); |
|
547 | 72 | $this->_consumed_keys[$key] = 1; |
|
548 | 72 | foreach ($data_in as $message) { |
|
549 | 71 | $this_key = self::get_real_key_for_message($message); |
|
550 | 71 | if ($this_key == $key) { |
|
551 | 71 | $message->time_consumed = microtime(true); |
|
552 | 71 | $message->thread_consumed = $thread_id; |
|
553 | 71 | $message->queue = $this; |
|
554 | 71 | $mutex->release_lock(); |
|
555 | 71 | $this->index_mutex_release_lock(); |
|
556 | |||
557 | 71 | return $message; |
|
558 | } |
||
559 | } |
||
560 | // @hint Сюда может передаться код только в случае неконсистентности БД, когда в |
||
561 | // index'е ключ есть, а в data его нет |
||
562 | 1 | unset($mutex); |
|
563 | } |
||
564 | } |
||
565 | 68 | $this->index_mutex_release_lock(); |
|
566 | 68 | if (($wait_time !== -1) and ($start + $wait_time < microtime(true))) { |
|
567 | 68 | return null; |
|
568 | } |
||
569 | 6 | $this->index_mutex_lock(); |
|
570 | 6 | $this->index_data_load(); |
|
571 | } |
||
572 | |||
573 | // @hint Это для IDE |
||
574 | // @codeCoverageIgnoreStart |
||
575 | return null; |
||
576 | // @codeCoverageIgnoreEnd |
||
577 | } |
||
578 | |||
579 | /** |
||
580 | * @return string |
||
581 | */ |
||
582 | 78 | function get_queue_name() { |
|
585 | |||
586 | /** |
||
587 | * Поддерживает ли очередь сортировку event'ов при вставке |
||
588 | * |
||
589 | * @return boolean |
||
590 | */ |
||
591 | 2 | static function is_support_sorted_events() { |
|
594 | |||
595 | /** |
||
596 | * Индексы |
||
597 | */ |
||
598 | |||
599 | /** |
||
600 | * Название файла для содержания даты |
||
601 | * |
||
602 | * @return string |
||
603 | */ |
||
604 | 76 | protected function get_index_filename() { |
|
607 | |||
608 | /** |
||
609 | * @throws QueueException |
||
610 | */ |
||
611 | 75 | protected function index_data_load() { |
|
637 | |||
638 | /** |
||
639 | * Сохраняем данные в индекс |
||
640 | * |
||
641 | * @throws QueueException |
||
642 | */ |
||
643 | 76 | protected function index_data_save() { |
|
644 | 76 | $filename = $this->get_index_filename(); |
|
645 | 76 | if (!file_exists(dirname($filename))) { |
|
646 | 1 | throw new QueueException('Folder "'.dirname($filename).'" does not exist', 4); |
|
647 | 76 | } elseif (!is_dir(dirname($filename))) { |
|
648 | 1 | throw new QueueException('Folder "'.dirname($filename).'" is not a folder', 13); |
|
649 | 76 | } elseif (!is_writable(dirname($filename))) { |
|
650 | 1 | throw new QueueException('Folder "'.dirname($filename).'" is not writable', 5); |
|
651 | 76 | } elseif (file_exists($filename) and !is_writable($filename)) { |
|
652 | 1 | throw new QueueException('File "'.$filename.'" is not writable', 6); |
|
653 | } |
||
654 | 75 | $filename_tmp = $filename.'-'.mt_rand(0, 50000).'.tmp'; |
|
655 | 75 | touch($filename_tmp); |
|
656 | 75 | chmod($filename_tmp, 6 << 6); |
|
657 | // @todo fileperms |
||
658 | |||
659 | 75 | if (is_null($this->_index_data_full)) { |
|
660 | 71 | $this->_index_data_full = (object) []; |
|
661 | 71 | $this->_index_data_full->time_create = microtime(true); |
|
662 | } |
||
663 | 75 | $this->_index_data_full->version = self::FILE_DB_INDEX_VERSION; |
|
664 | 75 | $this->_index_data_full->time_last_update = microtime(true); |
|
665 | 75 | $this->_index_data_full->queue_name = $this->get_queue_name(); |
|
666 | 75 | $temporary_data = clone $this->_index_data_full; |
|
667 | 75 | $temporary_data->data = $this->_index_data; |
|
668 | |||
669 | 75 | if (@file_put_contents($filename_tmp, Queue::serialize($temporary_data)) === false) { |
|
670 | // @codeCoverageIgnoreStart |
||
671 | throw new QueueException('Can not save index file: '.FileMutex::get_last_php_error_as_string(), 10); |
||
672 | // @codeCoverageIgnoreEnd |
||
673 | } |
||
674 | 75 | if (!rename($filename_tmp, $filename)) { |
|
675 | // @codeCoverageIgnoreStart |
||
676 | throw new QueueException('Can not rename temporary index file: '. |
||
677 | FileMutex::get_last_php_error_as_string(), 16); |
||
678 | // @codeCoverageIgnoreEnd |
||
679 | } |
||
680 | 75 | } |
|
681 | |||
682 | /** |
||
683 | * @param FileDBQueueTransport $queue |
||
684 | * |
||
685 | * @return boolean |
||
686 | */ |
||
687 | 15 | function is_equal_to($queue) { |
|
699 | } |
||
700 | |||
701 | ?> |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: