Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 31 | abstract class AbstractUpdateFilesPermissionsSubscriber implements EventSubscriber |
||
| 32 | { |
||
| 33 | /** |
||
| 34 | * List of properties where embedded files can be retreived. |
||
| 35 | * |
||
| 36 | * Note: entries will be prepended with "get" |
||
| 37 | * |
||
| 38 | * @var string[] |
||
| 39 | */ |
||
| 40 | protected $filesProperties = []; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * The document class that should be watched. |
||
| 44 | * |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | protected $targetDocument; |
||
| 48 | |||
| 49 | |||
| 50 | public function getSubscribedEvents() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Updates permissions on embedded files. |
||
| 57 | * |
||
| 58 | * @param OnFlushEventArgs $args |
||
| 59 | */ |
||
| 60 | public function onFlush(OnFlushEventArgs $args) |
||
| 77 | |||
| 78 | /** |
||
| 79 | * |
||
| 80 | * |
||
| 81 | * @param PermissionsAwareInterface[] $documents |
||
| 82 | * @param null|DocumentManager $dm |
||
| 83 | * @param null|UnitOfWork $uow |
||
| 84 | */ |
||
| 85 | protected function process($documents, $dm = null, $uow = null) |
||
| 106 | |||
| 107 | /** |
||
| 108 | * |
||
| 109 | * |
||
| 110 | * @param \Core\Entity\EntityInterface $document |
||
| 111 | * |
||
| 112 | * @return PermissionsAwareInterface[] |
||
| 113 | */ |
||
| 114 | protected function getFiles($document) |
||
| 131 | } |
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: