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  | 
            ||
| 36 | class Ownnotev2ApiController extends ApiController { | 
            ||
| 37 | |||
| 38 | private $backend;  | 
            ||
| 39 | private $config;  | 
            ||
| 40 | private $noteService;  | 
            ||
| 41 | |||
| 42 | 	public function __construct($appName, IRequest $request, ILogger $logger, IConfig $config, OwnNoteService $noteService) { | 
            ||
| 48 | |||
| 49 | /**  | 
            ||
| 50 | * @NoAdminRequired  | 
            ||
| 51 | * @NoCSRFRequired  | 
            ||
| 52 | * @TODO Add etag / lastmodified  | 
            ||
| 53 | */  | 
            ||
| 54 | 	public function index() { | 
            ||
| 55 | $uid = \OC::$server->getUserSession()->getUser()->getUID();  | 
            ||
| 56 | $results = $this->noteService->findNotesFromUser($uid, false);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 57 | return new JSONResponse($results);  | 
            ||
| 58 | }  | 
            ||
| 59 | |||
| 60 | /**  | 
            ||
| 61 | * @NoAdminRequired  | 
            ||
| 62 | * @NoCSRFRequired  | 
            ||
| 63 | * @TODO Add etag / lastmodified  | 
            ||
| 64 | */  | 
            ||
| 65 | View Code Duplication | 	public function get($id) { | 
            |
| 72 | |||
| 73 | |||
| 74 | /**  | 
            ||
| 75 | * @NoAdminRequired  | 
            ||
| 76 | * @NoCSRFRequired  | 
            ||
| 77 | */  | 
            ||
| 78 | 	public function create($title, $group, $note) { | 
            ||
| 88 | |||
| 89 | /**  | 
            ||
| 90 | * @NoAdminRequired  | 
            ||
| 91 | * @NoCSRFRequired  | 
            ||
| 92 | */  | 
            ||
| 93 | 	public function update($id, $title, $group, $content) { | 
            ||
| 110 | |||
| 111 | /**  | 
            ||
| 112 | * @NoAdminRequired  | 
            ||
| 113 | * @NoCSRFRequired  | 
            ||
| 114 | */  | 
            ||
| 115 | View Code Duplication | 	public function delete($id) { | 
            |
| 124 | |||
| 125 | }  | 
            ||
| 126 | 
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: