From 9a2fd57ce9c48335574f0a2443c2f7bc01ff809f Mon Sep 17 00:00:00 2001 From: Rasmus Christoffer Nielsen Date: Wed, 26 Jan 2022 12:41:51 +0100 Subject: [PATCH 1/2] Bump php 8 and laravel 9 --- .github/workflows/test.yml | 65 +++++++++++++++++++------------------- composer.json | 22 ++++++------- 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 861b64a..b59ee15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,37 +1,38 @@ name: Run tests on: - push: - pull_request: - schedule: - - cron: '0 0 * * *' + push: + pull_request: + schedule: + - cron: '0 0 * * *' jobs: - test: - runs-on: ubuntu-latest - - strategy: - matrix: - php: [7.3, 7.4, 8.0] - laravel: [6.*, 7.*, 8.*] - dependency-version: [prefer-lowest, prefer-stable] - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - - steps: - - name: Checkout code - uses: actions/checkout@v1 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update - composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction - - - name: Execute tests - run: vendor/bin/phpunit \ No newline at end of file + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: [ 8.0,8.1 ] + laravel: [ 8.*,9* ] + dependency-version: [ prefer-lowest, prefer-stable ] + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + + - name: Execute tests + run: vendor/bin/phpunit \ No newline at end of file diff --git a/composer.json b/composer.json index 89969d9..a11ceb7 100644 --- a/composer.json +++ b/composer.json @@ -7,23 +7,21 @@ } }, "require": { - "php": ">=7.3.0|8.*", - "illuminate/container": "6.*|7.*|8.*", - "illuminate/filesystem": "6.*|7.*|8.*", - "illuminate/support": "6.*|7.*|8.*", - "superbalist/laravel-google-cloud-storage": "^1.0|^2.2", - "guzzlehttp/guzzle": "^6.3|^7.0.1" + "php": "^8.0", + "illuminate/container": "^8.80|9.*", + "illuminate/filesystem": "^8.80|9.*", + "illuminate/support": "^8.80|9.*", + "superbalist/laravel-google-cloud-storage": "^2.2", + "guzzlehttp/guzzle": "^7.0" }, "require-dev": { "codedungeon/phpunit-result-printer": "^0.30.0", - "laravel/laravel": "6.*|7.*|8.*", + "laravel/laravel": "8.*|9.*", "intervention/image": "^2.4", "doctrine/dbal": "^3.0", - "mockery/mockery": "^1.4.2", - "rutorika/sortable": "^4.2|^6.0|^7.0", - "phpunit/phpunit": "8.*|9.*", - "fzaninotto/faker": "^1.4", - "league/flysystem": "^1.0.8" + "mockery/mockery": "^1.5", + "rutorika/sortable": "8.*", + "phpunit/phpunit": "9.*", }, "suggest": { "illuminate/database": "Required for using extended media library functionality", From 251248cd0628cced8f28ad0f79888e45eff4a9f4 Mon Sep 17 00:00:00 2001 From: Rasmus Nielsen Date: Wed, 26 Jan 2022 12:42:06 +0100 Subject: [PATCH 2/2] Apply fixes from StyleCI (#47) --- .github/workflows/test.yml | 6 +++--- composer.json | 2 +- src/Client.php | 8 +++++--- src/Console/Commands/GeneratePlaceholders.php | 2 +- src/Contracts/DimensionCalculator.php | 4 ++-- src/FileSizeOptimizedDimensionCalculator.php | 8 ++++---- src/HasDimensions.php | 2 +- src/HasImages.php | 2 +- src/Image.php | 11 ++++++----- src/ImageFactory.php | 14 ++++++++------ src/Jobs/DeleteCloudImage.php | 4 ++-- src/Nova/Fields/CloudImage.php | 4 ++-- src/ResponsiveImageFactory.php | 9 +++++---- src/TinyPlaceholder.php | 3 ++- tests/Fakes/FakeGuzzleClient.php | 1 + tests/Fakes/FakeGuzzleResponse.php | 1 + tests/Fakes/FakeTinyPlaceholder.php | 3 ++- tests/Feature/HasMultipleImagesTest.php | 3 ++- tests/Feature/ImageFactoryTest.php | 2 +- tests/TestCase.php | 12 ++++++------ 20 files changed, 56 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b59ee15..81a3db0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,9 +13,9 @@ jobs: strategy: fail-fast: false matrix: - php: [ 8.0,8.1 ] - laravel: [ 8.*,9* ] - dependency-version: [ prefer-lowest, prefer-stable ] + php: [8.0,8.1] + laravel: [8.*,9.*] + dependency-version: [prefer-lowest,prefer-stable] name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/composer.json b/composer.json index a11ceb7..48899bd 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "doctrine/dbal": "^3.0", "mockery/mockery": "^1.5", "rutorika/sortable": "8.*", - "phpunit/phpunit": "9.*", + "phpunit/phpunit": "9.*" }, "suggest": { "illuminate/database": "Required for using extended media library functionality", diff --git a/src/Client.php b/src/Client.php index 8dd65e4..a7601b4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -44,6 +44,7 @@ public function __construct($diskName, $endpoint, $guzzle) /** * @param $path * @return bool + * * @throws FailedDeletionException */ public function delete($path) @@ -62,10 +63,11 @@ public function delete($path) } /** - * @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile $image - * @param null $path - * @param string $visibility + * @param \Illuminate\Http\File|\Illuminate\Http\UploadedFile $image + * @param null $path + * @param string $visibility * @return object + * * @throws FailedUploadException */ public function upload($image, $path = null, $visibility = null) diff --git a/src/Console/Commands/GeneratePlaceholders.php b/src/Console/Commands/GeneratePlaceholders.php index 91a93fe..73d371f 100644 --- a/src/Console/Commands/GeneratePlaceholders.php +++ b/src/Console/Commands/GeneratePlaceholders.php @@ -57,7 +57,7 @@ public function handle() /** * If package was upgraded from <= 0.16 it could be missing width, height & size. * - * @param Image $image + * @param Image $image */ protected function maybeUpgrade(Image $image) { diff --git a/src/Contracts/DimensionCalculator.php b/src/Contracts/DimensionCalculator.php index f08b630..adec6bb 100755 --- a/src/Contracts/DimensionCalculator.php +++ b/src/Contracts/DimensionCalculator.php @@ -14,8 +14,8 @@ interface DimensionCalculator public function __construct($originalWidth, $originalHeight, $originalSize); /** - * @param int $width - * @param int $height + * @param int $width + * @param int $height * @return Collection */ public function calculateDimensions($width, $height): Collection; diff --git a/src/FileSizeOptimizedDimensionCalculator.php b/src/FileSizeOptimizedDimensionCalculator.php index d60e99a..7375e15 100755 --- a/src/FileSizeOptimizedDimensionCalculator.php +++ b/src/FileSizeOptimizedDimensionCalculator.php @@ -23,8 +23,8 @@ public function __construct($originalWidth, $originalHeight, $originalSize) } /** - * @param int $width - * @param int $height + * @param int $width + * @param int $height * @return Collection */ public function calculateDimensions($width, $height): Collection @@ -50,8 +50,8 @@ public function calculateDimensions($width, $height): Collection } /** - * @param int $predictedFileSize - * @param int $newWidth + * @param int $predictedFileSize + * @param int $newWidth * @return bool */ protected function finishedCalculating(int $predictedFileSize, int $newWidth): bool diff --git a/src/HasDimensions.php b/src/HasDimensions.php index 13403e5..e5ed30b 100644 --- a/src/HasDimensions.php +++ b/src/HasDimensions.php @@ -73,7 +73,7 @@ public function getWidth() /** * @param $width - * @param null $height + * @param null $height * @return $this */ public function setDimensions($width, $height = null) diff --git a/src/HasImages.php b/src/HasImages.php index 0d59192..55dab4f 100644 --- a/src/HasImages.php +++ b/src/HasImages.php @@ -19,7 +19,7 @@ public function images() } /** - * @param null $tag + * @param null $tag * @return Image */ public function image($tag = null) diff --git a/src/Image.php b/src/Image.php index 3141a1c..4572704 100644 --- a/src/Image.php +++ b/src/Image.php @@ -53,9 +53,9 @@ public static function boot() } /** - * @param File|UploadedFile $file - * @param string | null $path - * @param string | null $visibility + * @param File|UploadedFile $file + * @param string | null $path + * @param string | null $visibility * @return Image */ public static function upload($file, $path = null, $visibility = null) @@ -124,7 +124,7 @@ public function placeholder() } /** - * @param Image $image + * @param Image $image * @return Image */ public function replaceWith(self $image) @@ -141,7 +141,7 @@ public function replaceWith(self $image) /** * @param $attachable - * @param null $tag + * @param null $tag * @return $this */ public function reserveFor($attachable, $tag = null) @@ -162,6 +162,7 @@ public function getAspectRatioAttribute() /** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string + * * @throws \Throwable */ public function __toString() diff --git a/src/ImageFactory.php b/src/ImageFactory.php index 95e33a0..72c20f0 100644 --- a/src/ImageFactory.php +++ b/src/ImageFactory.php @@ -38,7 +38,7 @@ public function __construct($url) } /** - * @param ResponsiveImage $image + * @param ResponsiveImage $image * @return ImageFactory */ public static function make(ResponsiveImage $image) @@ -85,6 +85,7 @@ public function get() /** * @return ResponsiveImageFactory + * * @throws \Throwable */ public function responsive() @@ -96,6 +97,7 @@ public function responsive() /** * @return string + * * @throws \Throwable */ public function getContents() @@ -110,7 +112,7 @@ public function getContents() // _________________________________________________________________________________________________________________ /** - * @param int $percentage + * @param int $percentage * @return ImageFactory */ public function blur($percentage = 5) @@ -121,7 +123,7 @@ public function blur($percentage = 5) /** * @param $width * @param $height - * @param string $mode + * @param string $mode * @return ImageFactory */ public function crop($width, $height, $mode = 'c') @@ -213,7 +215,7 @@ public function getDisplayWidth() } /** - * @param Closure $transformation + * @param Closure $transformation * @return $this */ protected function transform(Closure $transformation) @@ -237,8 +239,8 @@ protected function addExtraOption($value, $options) } /** - * @param mixed $value - * @param array $options + * @param mixed $value + * @param array $options * @return array */ protected function setSizingOption($value, $options) diff --git a/src/Jobs/DeleteCloudImage.php b/src/Jobs/DeleteCloudImage.php index 166c982..afc7d34 100644 --- a/src/Jobs/DeleteCloudImage.php +++ b/src/Jobs/DeleteCloudImage.php @@ -21,7 +21,7 @@ class DeleteCloudImage implements ShouldQueue /** * Create a new job instance. * - * @param string $path + * @param string $path */ public function __construct($path) { @@ -31,7 +31,7 @@ public function __construct($path) /** * Execute the job. * - * @param Client $client + * @param Client $client */ public function handle(Client $client) { diff --git a/src/Nova/Fields/CloudImage.php b/src/Nova/Fields/CloudImage.php index 2e6217d..d3dec6a 100644 --- a/src/Nova/Fields/CloudImage.php +++ b/src/Nova/Fields/CloudImage.php @@ -10,8 +10,8 @@ class CloudImage extends ImageField { /** - * @param string $name - * @param string|null $attribute + * @param string $name + * @param string|null $attribute * @return void */ public function __construct($name, $attribute = null) diff --git a/src/ResponsiveImageFactory.php b/src/ResponsiveImageFactory.php index 403258e..2c2a431 100644 --- a/src/ResponsiveImageFactory.php +++ b/src/ResponsiveImageFactory.php @@ -27,8 +27,9 @@ class ResponsiveImageFactory implements Arrayable, JsonSerializable /** * ResponsiveImageFactory constructor. - * @param ResponsiveImage $image - * @param ImageFactory|null $factory + * + * @param ResponsiveImage $image + * @param ImageFactory|null $factory */ public function __construct(ResponsiveImage $image, ImageFactory $factory = null) { @@ -74,7 +75,7 @@ public function getDimensions() } /** - * @param array $attributes + * @param array $attributes * @return string */ public function getHtml(array $attributes = []) @@ -165,7 +166,7 @@ protected function usingPlaceholder() } /** - * @param array $attributes + * @param array $attributes * @return string */ protected function attributesToString(array $attributes) diff --git a/src/TinyPlaceholder.php b/src/TinyPlaceholder.php index c324f9b..0419e8e 100644 --- a/src/TinyPlaceholder.php +++ b/src/TinyPlaceholder.php @@ -17,7 +17,7 @@ class TinyPlaceholder implements ResponsiveImageVersion protected $image; /** - * @param ResponsiveImage $image + * @param ResponsiveImage $image */ public function __construct(ResponsiveImage $image) { @@ -34,6 +34,7 @@ public function factory() /** * @return string + * * @throws \Throwable */ public function create() diff --git a/tests/Fakes/FakeGuzzleClient.php b/tests/Fakes/FakeGuzzleClient.php index 26d285f..0a41ff6 100644 --- a/tests/Fakes/FakeGuzzleClient.php +++ b/tests/Fakes/FakeGuzzleClient.php @@ -11,6 +11,7 @@ class FakeGuzzleClient /** * FakeGuzzleClient constructor. + * * @param $status */ public function __construct($status = 200) diff --git a/tests/Fakes/FakeGuzzleResponse.php b/tests/Fakes/FakeGuzzleResponse.php index 926f4f4..2489109 100644 --- a/tests/Fakes/FakeGuzzleResponse.php +++ b/tests/Fakes/FakeGuzzleResponse.php @@ -16,6 +16,7 @@ class FakeGuzzleResponse /** * FakeGuzzleClient constructor. + * * @param $client * @param $request */ diff --git a/tests/Fakes/FakeTinyPlaceholder.php b/tests/Fakes/FakeTinyPlaceholder.php index 006e5ef..eb436b4 100644 --- a/tests/Fakes/FakeTinyPlaceholder.php +++ b/tests/Fakes/FakeTinyPlaceholder.php @@ -23,7 +23,8 @@ public function testActualFactory($bool = true) public function factory() { - $factory = new class($this->testImageUrl()) extends ImageFactory { + $factory = new class($this->testImageUrl()) extends ImageFactory + { public static $shouldMock; public function getContents() diff --git a/tests/Feature/HasMultipleImagesTest.php b/tests/Feature/HasMultipleImagesTest.php index 3d7212a..3f5b199 100644 --- a/tests/Feature/HasMultipleImagesTest.php +++ b/tests/Feature/HasMultipleImagesTest.php @@ -58,7 +58,8 @@ public function it_finds_attachables_for_a_given_model() /** @test **/ public function it_uses_the_specified_image_class_property_for_the_relationship() { - $product = new class extends Product { + $product = new class extends Product + { protected $useImageModel = ProductImage::class; }; diff --git a/tests/Feature/ImageFactoryTest.php b/tests/Feature/ImageFactoryTest.php index a638234..59991b8 100644 --- a/tests/Feature/ImageFactoryTest.php +++ b/tests/Feature/ImageFactoryTest.php @@ -64,7 +64,7 @@ protected function cloudImage() } /** - * @param string $params + * @param string $params * @return string */ protected function url($params = null) diff --git a/tests/TestCase.php b/tests/TestCase.php index 41f999e..d4b39ab 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -69,7 +69,7 @@ public function fakeServices() } /** - * @param int $status + * @param int $status */ public function failHttpRequest($status = 400) { @@ -79,10 +79,10 @@ public function failHttpRequest($status = 400) } /** - * @param string $path - * @param int $width - * @param int $height - * @param int $size + * @param string $path + * @param int $width + * @param int $height + * @param int $size * @return Image */ protected function image($path = null, $width = 1000, $height = 1000, $size = null) @@ -115,7 +115,7 @@ protected function area($x, $y) } /** - * @param bool $bool + * @param bool $bool * @return FakeTinyPlaceholder */ protected function usePlaceholders($bool = true)