Skip to content

Commit

Permalink
Add more types to media controllers (sulu#7220)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamazu authored Apr 29, 2024
1 parent 66f66d7 commit 36e7667
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 186 deletions.
160 changes: 0 additions & 160 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2160,11 +2160,6 @@ parameters:
count: 2
path: src/Sulu/Bundle/AudienceTargetingBundle/Controller/TargetGroupController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseGetById\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/AudienceTargetingBundle/Controller/TargetGroupController.php

-
message: "#^Parameter \\#2 \\$fieldDescriptors of method Sulu\\\\Component\\\\Rest\\\\RestHelperInterface\\:\\:initializeListBuilder\\(\\) expects array\\<Sulu\\\\Component\\\\Rest\\\\ListBuilder\\\\FieldDescriptorInterface\\>, array\\<Sulu\\\\Component\\\\Rest\\\\ListBuilder\\\\FieldDescriptorInterface\\>\\|null given\\.$#"
count: 1
Expand Down Expand Up @@ -8205,16 +8200,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/AccountController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseDelete\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/AccountController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseGetById\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/AccountController.php

-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, mixed given\\.$#"
count: 2
Expand Down Expand Up @@ -8540,16 +8525,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/ContactController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseDelete\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/ContactController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseGetById\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/ContactController.php

-
message: "#^Parameter \\#1 \\$listBuilder of method Sulu\\\\Bundle\\\\ContactBundle\\\\Controller\\\\ContactController\\:\\:prepareListResponse\\(\\) expects Sulu\\\\Component\\\\Rest\\\\ListBuilder\\\\Doctrine\\\\DoctrineListBuilder, Sulu\\\\Component\\\\Rest\\\\ListBuilder\\\\ListBuilderInterface given\\.$#"
count: 1
Expand Down Expand Up @@ -8655,16 +8630,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/ContactTitleController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseDelete\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/ContactTitleController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseGetById\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/ContactTitleController.php

-
message: "#^Parameter \\#1 \\$item of method Sulu\\\\Bundle\\\\ContactBundle\\\\Controller\\\\ContactTitleController\\:\\:addAndUpdateTitles\\(\\) expects array, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -8705,16 +8670,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/PositionController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseDelete\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/PositionController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseGetById\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/ContactBundle/Controller/PositionController.php

-
message: "#^Parameter \\#1 \\$item of method Sulu\\\\Bundle\\\\ContactBundle\\\\Controller\\\\PositionController\\:\\:addAndUpdatePositions\\(\\) expects array, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -14545,21 +14500,11 @@ parameters:
count: 1
path: src/Sulu/Bundle/MediaBundle/Content/Types/SingleMediaSelection.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/AbstractMediaController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\AbstractMediaController\\:\\:getData\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/AbstractMediaController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\AbstractMediaController\\:\\:getUploadedFile\\(\\) should return Symfony\\\\Component\\\\HttpFoundation\\\\File\\\\UploadedFile but returns mixed\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/AbstractMediaController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Collection\\\\Manager\\\\CollectionManagerInterface\\:\\:getById\\(\\) invoked with 8 parameters, 2\\-6 required\\.$#"
count: 1
Expand All @@ -14580,36 +14525,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:checkSystemCollection\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:checkSystemCollection\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:checkSystemCollection\\(\\) has parameter \\$parent with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:deleteAction\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:getAction\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:getOffset\\(\\) has parameter \\$limit with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:getRequestParameter\\(\\) should return string but returns mixed\\.$#"
count: 1
Expand All @@ -14620,21 +14535,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:putAction\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\CollectionController\\:\\:saveEntity\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Parameter \\#2 \\$collections of class Sulu\\\\Bundle\\\\MediaBundle\\\\Api\\\\RootCollection constructor expects array, array\\<Sulu\\\\Bundle\\\\MediaBundle\\\\Api\\\\Collection\\>\\|Doctrine\\\\ORM\\\\Tools\\\\Pagination\\\\Paginator given\\.$#"
count: 1
Expand All @@ -14645,16 +14545,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Parameter \\#3 \\$limit of method Sulu\\\\Bundle\\\\MediaBundle\\\\Collection\\\\Manager\\\\CollectionManagerInterface\\:\\:get\\(\\) expects int\\|null, mixed given\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Parameter \\#3 \\$limit of method Sulu\\\\Bundle\\\\MediaBundle\\\\Collection\\\\Manager\\\\CollectionManagerInterface\\:\\:getTree\\(\\) expects int, mixed given\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Parameter \\#5 \\$depth of method Sulu\\\\Bundle\\\\MediaBundle\\\\Collection\\\\Manager\\\\CollectionManagerInterface\\:\\:getTree\\(\\) expects int, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -14690,11 +14580,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/CollectionController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\FormatController\\:\\:cgetAction\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/FormatController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\FormatController\\:\\:getRequestParameter\\(\\) should return string but returns mixed\\.$#"
count: 1
Expand All @@ -14720,11 +14605,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\MediaController\\:\\:deleteVersionAction\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\MediaController\\:\\:getListBuilder\\(\\) has parameter \\$types with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -14735,11 +14615,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\MediaController\\:\\:getListRepresentation\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\MediaController\\:\\:getRequestParameter\\(\\) should return string but returns mixed\\.$#"
count: 1
Expand All @@ -14765,16 +14640,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseDelete\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseGetById\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaController.php

-
message: "#^Parameter \\#2 \\$fieldDescriptors of method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\MediaController\\:\\:getListBuilder\\(\\) expects array\\<Sulu\\\\Component\\\\Rest\\\\ListBuilder\\\\FieldDescriptorInterface\\>, array\\<Sulu\\\\Component\\\\Rest\\\\ListBuilder\\\\FieldDescriptorInterface\\>\\|null given\\.$#"
count: 1
Expand Down Expand Up @@ -14820,16 +14685,6 @@ parameters:
count: 2
path: src/Sulu/Bundle/MediaBundle/Controller/MediaController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\MediaFormatController\\:\\:cpatchAction\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaFormatController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\MediaFormatController\\:\\:cpatchAction\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/Sulu/Bundle/MediaBundle/Controller/MediaFormatController.php

-
message: "#^Method Sulu\\\\Bundle\\\\MediaBundle\\\\Controller\\\\MediaFormatController\\:\\:getRequestParameter\\(\\) should return string but returns mixed\\.$#"
count: 1
Expand Down Expand Up @@ -18915,11 +18770,6 @@ parameters:
count: 2
path: src/Sulu/Bundle/MediaBundle/Tests/Unit/Media/Manager/MediaManagerTest.php

-
message: "#^Parameter \\#1 \\$uploadedFile of method Sulu\\\\Bundle\\\\MediaBundle\\\\Media\\\\Manager\\\\MediaManager\\:\\:save\\(\\) expects Symfony\\\\Component\\\\HttpFoundation\\\\File\\\\UploadedFile, null given\\.$#"
count: 2
path: src/Sulu/Bundle/MediaBundle/Tests/Unit/Media/Manager/MediaManagerTest.php

-
message: "#^Property Sulu\\\\Bundle\\\\MediaBundle\\\\Media\\\\Manager\\\\MediaManagerTest\\:\\:\\$categoryManager is never read, only written\\.$#"
count: 1
Expand Down Expand Up @@ -29080,16 +28930,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/SecurityBundle/Controller/UserController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseDelete\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/SecurityBundle/Controller/UserController.php

-
message: "#^Parameter \\#1 \\$id of method Sulu\\\\Component\\\\Rest\\\\AbstractRestController\\:\\:responseGetById\\(\\) expects string, int given\\.$#"
count: 1
path: src/Sulu/Bundle/SecurityBundle/Controller/UserController.php

-
message: "#^Property Sulu\\\\Bundle\\\\SecurityBundle\\\\Controller\\\\UserController\\:\\:\\$doctrineListBuilderFactory \\(Doctrine\\\\ORM\\\\EntityManagerInterface\\) does not accept Sulu\\\\Component\\\\Rest\\\\ListBuilder\\\\Doctrine\\\\DoctrineListBuilderFactoryInterface\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getTreeById($id, $locale);
*
* @param string $locale the locale which the collection should be return
* @param int $offset
* @param int $limit
* @param int|null $limit
* @param string $search
* @param int $depth maximum depth for query
* @param array $sortBy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function getData(Request $request, $fallback = true)
/**
* @param Request $request
*
* @return string
* @return string|null
*/
protected function getTitleFromUpload($request)
{
Expand All @@ -54,15 +54,20 @@ protected function getTitleFromUpload($request)

return \implode('.', \explode('.', $uploadedFile->getClientOriginalName(), -1));
}

return null;
}

/**
* @param string $name
*
* @return UploadedFile
* @return UploadedFile|null
*/
protected function getUploadedFile(Request $request, $name)
{
return $request->files->get($name);
/** @var UploadedFile|null $file */
$file = $request->files->get($name);

return $file;
}
}
Loading

0 comments on commit 36e7667

Please sign in to comment.