diff --git a/phpstan.neon b/phpstan.neon index d5581f7e..1b1ea08e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 2 + level: 3 reportUnmatchedIgnoredErrors: false bootstrapFiles: - src/flextype/defines.php diff --git a/src/flextype/core/Entries/Entries.php b/src/flextype/core/Entries/Entries.php index 9a65818c..9f536bf9 100755 --- a/src/flextype/core/Entries/Entries.php +++ b/src/flextype/core/Entries/Entries.php @@ -532,7 +532,7 @@ class Entries // to avoid it's running inside filterCollection() helper. if ($this->registry()->has('methods.fetch.params.options.filter.only')) { $data = []; - foreach ($this->registry()->get('methods.fetch.result') as $key => $value) { + foreach ($this->registry()->get('methods.fetch.result', []) as $key => $value) { $data[$key] = collection($value)->only($this->registry()->get('methods.fetch.params.options.filter.only'))->toArray(); } $this->registry()->delete('methods.fetch.params.options.filter.only'); @@ -544,7 +544,7 @@ class Entries // to avoid it's running inside filterCollection() helper. if ($this->registry()->has('methods.fetch.params.options.filter.except')) { $data = []; - foreach ($this->registry()->get('methods.fetch.result') as $key => $value) { + foreach ($this->registry()->get('methods.fetch.result', []) as $key => $value) { $data[$key] = collection($value)->except($this->registry()->get('methods.fetch.params.options.filter.except'))->toArray(); } $this->registry()->delete('methods.fetch.params.options.filter.except'); diff --git a/src/flextype/core/Flextype.php b/src/flextype/core/Flextype.php index 0c3c2c27..50af63c3 100644 --- a/src/flextype/core/Flextype.php +++ b/src/flextype/core/Flextype.php @@ -42,7 +42,7 @@ final class Flextype /** * The Flextype Application Container. */ - private static Container $container; + private static ContainerInterface $container; /** * Flextype should not be cloneable. @@ -87,11 +87,11 @@ final class Flextype /** * Get Flextype Application Container. * - * @return Container Returns Flextype Application Container. + * @return ContainerInterface Returns Flextype Application Container. * * @access public */ - public function container(): Container + public function container(): ContainerInterface { return self::$container; } diff --git a/src/flextype/core/Middlewares/CsrfMiddleware.php b/src/flextype/core/Middlewares/CsrfMiddleware.php index b318e993..40bf94b2 100644 --- a/src/flextype/core/Middlewares/CsrfMiddleware.php +++ b/src/flextype/core/Middlewares/CsrfMiddleware.php @@ -16,8 +16,9 @@ declare(strict_types=1); namespace Flextype\Middlewares; -use Psr\Http\Message\ServerRequestInterface as Request; -use Psr\Http\Server\RequestHandlerInterface as RequestHandler; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\RequestHandlerInterface; use Slim\Psr7\Response; use function Flextype\csrf; @@ -27,10 +28,10 @@ class CsrfMiddleware /** * Invoke * - * @param Request $request PSR-7 request - * @param RequestHandler $handler PSR-15 request handler + * @param ServerRequestInterface $request PSR-7 request + * @param RequestHandlerInterface $handler PSR-15 request handler */ - public function __invoke(Request $request, RequestHandler $handler): Response + public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $response = $handler->handle($request); $data = $request->getParsedBody(); diff --git a/src/flextype/helpers/image.php b/src/flextype/helpers/image.php index c4b945e9..e12d1fd4 100644 --- a/src/flextype/helpers/image.php +++ b/src/flextype/helpers/image.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Flextype; use Closure; -use Intervention\Image\ImageManagerStatic as Image; use function count; use function function_exists; @@ -16,11 +15,11 @@ if (! function_exists('imageFile')) { /** * Create a new image instance for image file. * - * @param string $file Image file. + * @param string $file Image file. */ - function imageFile(string $file): Image + function imageFile(string $file): \Intervention\Image\Image { - return Image::make($file); + return \Intervention\Image\ImageManagerStatic::make($file); } } @@ -31,9 +30,9 @@ if (! function_exists('imageProcessFile')) { * @param string $file Image file. * @param array $options Options array. */ - function imageProcessFile(string $file, array $options = []) + function imageProcessFile(string $file, array $options = []): mixed { - $image = Image::make($file); + $image = \Intervention\Image\ImageManagerStatic::make($file); if (count($options) === 0) { return $image; @@ -41,7 +40,7 @@ if (! function_exists('imageProcessFile')) { if (isset($options['driver'])) { if (in_array($options['driver'], ['imagick', 'gd'])) { - Image::configure(['driver' => $options['driver']]); + \Intervention\Image\ImageManagerStatic::configure(['driver' => $options['driver']]); } } @@ -167,6 +166,8 @@ if (! function_exists('imageProcessFile')) { $image->save($file, $options['quality'] ?? 70); $image->destroy(); + + return true; } } @@ -178,11 +179,11 @@ if (! function_exists('imageCanvas')) { * @param int $height Canvas height. * @param mixed $background Canvas background. * - * @return Image Image canvas instance. + * @return \Intervention\Image\Image Image canvas instance. */ - function imageCanvas(int $width, int $height, mixed $background = null): Image + function imageCanvas(int $width, int $height, mixed $background = null): \Intervention\Image\Image { - return Image::canvas($width, $height, $background); + return \Intervention\Image\ImageManagerStatic::canvas($width, $height, $background); } } @@ -198,6 +199,6 @@ if (! function_exists('imageCache')) { */ function imageCache(Closure $callback, int $lifetime = 5, bool $returnObj = false): mixed { - return Image::cache($callback, $lifetime, $returnObj); + return \Intervention\Image\ImageManagerStatic::cache($callback, $lifetime, $returnObj); } } diff --git a/src/flextype/helpers/upload.php b/src/flextype/helpers/upload.php index c8e98182..4d82261e 100644 --- a/src/flextype/helpers/upload.php +++ b/src/flextype/helpers/upload.php @@ -6,6 +6,7 @@ namespace Flextype; use Sirius\Upload\Handler as UploadHandler; use Sirius\Upload\Result\File as UploadResultFile; +use Sirius\Upload\Result\ResultInterface; use Throwable; use function function_exists; @@ -20,9 +21,9 @@ if (! function_exists('upload')) { * @param array $file Raw file data (multipart/form-data). * @param string $folder The folder you're targetting. * - * @return UploadResultFile Result file. + * @return \Sirius\Upload\Result\ResultInterface|array Result file or arrays with messages. */ - function upload(array $file, string $folder): UploadResultFile + function upload(array $file, string $folder): \Sirius\Upload\Result\ResultInterface|array { $settings = registry()->get('flextype.settings.upload');