From a09e3dfc275f32f9000c602a1b65fd0689007414 Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Thu, 27 Feb 2025 16:44:36 +0000 Subject: [PATCH 1/4] WIP --- .github/ISSUE_TEMPLATE/bug_report.yml | 17 ++++---- .github/workflows/dependency-review.yml | 20 ++++++++++ .../workflows/fix-php-code-style-issues.yml | 8 +--- .github/workflows/phpstan.yml | 8 ++-- .github/workflows/release.yml | 23 +++++++++++ .github/workflows/run-tests.yml | 15 +++++-- composer.json | 39 ++++++++++--------- 7 files changed, 89 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/dependency-review.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 7546b77..bc5e177 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,18 +1,18 @@ name: Bug Report description: Report an Issue or Bug with the Package title: "[Bug]: " -labels: ["bug"] +labels: [ "bug" ] body: - type: markdown attributes: - value: | - We're sorry to hear you have a problem. Can you help us solve it by providing the following details. + value: "| +We're sorry to hear you have a problem. Can you help us solve it by providing the following details." - type: textarea id: what-happened attributes: label: What happened? description: What did you expect to happen? - placeholder: I cannot currently do X thing because when I do, it breaks X thing. + placeholder: "I cannot currently do X thing because when I do, it breaks X thing." validations: required: true - type: input @@ -20,7 +20,8 @@ body: attributes: label: Package Version description: What version of our Package are you running? Please be as specific as possible - placeholder: 1.0.0 + placeholder: "12.0" + value: "12.0" validations: required: true - type: input @@ -28,7 +29,8 @@ body: attributes: label: PHP Version description: What version of PHP are you running? Please be as specific as possible - placeholder: 8.3.0 + placeholder: "8.4.0" + value: "8.4.0" validations: required: true - type: input @@ -36,7 +38,8 @@ body: attributes: label: Laravel Version description: What version of Laravel are you running? Please be as specific as possible - placeholder: 11.0.0 + placeholder: "12.0.0" + value: "12.0.0" validations: required: true - type: dropdown diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..0d4a013 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,20 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement +name: 'Dependency Review' +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: 'Checkout Repository' + uses: actions/checkout@v4 + - name: 'Dependency Review' + uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml index 0edbd38..ef2fadf 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -1,12 +1,6 @@ name: Fix PHP code style issues -on: - push: - paths: - - '**.php' - -permissions: - contents: write +on: [push] jobs: php-code-styling: diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index c6078f3..b0cde6a 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -2,9 +2,9 @@ name: PHPStan on: push: - branches: [ main ] - pull_request: - branches: [ main ] + paths: + - '**.php' + - 'phpstan.neon.dist' jobs: phpstan: @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.4' coverage: none - name: Install composer dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..afa28ff --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: release + +on: + pull_request: + types: + - closed + branches: + - main +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Bump version and push tag + uses: anothrNick/github-tag-action@master + env: + GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} + WITH_V: true + RELEASE_BRANCHES: main + DEFAULT_BUMP: minor diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 2798855..aaa34ea 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -11,11 +11,12 @@ jobs: runs-on: ${{ matrix.os }} strategy: fail-fast: true + max-parallel: 1 matrix: os: [ ubuntu-latest ] - php: [ 8.3 ] - laravel: [ 11.* ] - stability: [ prefer-stable ] + php: [ 8.2, 8.3, 8.4 ] + laravel: [ 12.* ] + stability: [ prefer-lowest, prefer-stable ] name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -40,7 +41,7 @@ jobs: composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - name: Set phpunit.xml + - name: Execute tests run: cp phpunit.xml.dist phpunit.xml - name: Execute tests @@ -50,3 +51,9 @@ jobs: CLOUDINARY_API_KEY: ${{ secrets.CLOUDINARY_API_KEY }} CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET }} + - name: Store Log Artifacts + if: failure() + uses: actions/upload-artifact@v4 + with: + name: Store report artifacts + path: ./vendor/orchestra/testbench-core/laravel/storage/logs diff --git a/composer.json b/composer.json index b2e544d..ba751b2 100644 --- a/composer.json +++ b/composer.json @@ -12,32 +12,33 @@ "license": "MIT", "authors": [ { - "name": "Sebastian Fix", - "email": "sebastian.fix@codebar.ch", + "name": "Sebastian Bürgin-Fix", + "email": "sebastian.buergin@buergin.ch", "homepage": "https://www.codebar.ch", - "role": "Software Engineer" + "role": "Sofware-Engineer" + }, + { + "name": "Rhys Lees", + "role": "Software-Engineer" } ], "require": { - "php": ">=8.2", + "php": "8.2.*|8.3.*|8.4.*", "guzzlehttp/guzzle": "^7.8", - "illuminate/contracts": "^11.0", - "spatie/laravel-package-tools": "^1.16", - "cloudinary/cloudinary_php": "^2.13", - "nesbot/carbon": "^2.72" + "illuminate/contracts": "^12.0", + "cloudinary/cloudinary_php": "^3.1", + "nesbot/carbon": "^3.8", + "spatie/laravel-package-tools": "^1.19" }, "require-dev": { - "laravel/pint": "^1.14", - "nunomaduro/collision": "^8.1", - "larastan/larastan": "^2.9", - "orchestra/testbench": "^9.0", - "pestphp/pest": "^2.34", - "pestphp/pest-plugin-arch": "^2.7", - "pestphp/pest-plugin-laravel": "^2.3", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "spatie/laravel-ray": "^1.35" + "laravel/pint": "^1.21", + "larastan/larastan": "^v3.1", + "orchestra/testbench": "^10.0", + "pestphp/pest": "^3.7", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "spatie/laravel-ray": "^1.39" }, "autoload": { "psr-4": { From 72893197b2b04064609abea182d7aeeb2b0af6b2 Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:38:05 +0000 Subject: [PATCH 2/4] WIP --- .gitattributes | 7 +++++- .gitignore | 10 +++------ .php-cs-fixer.dist.php | 48 ------------------------------------------ .php_cs.dist | 40 ----------------------------------- README.md | 20 ++++++++++-------- phpstan.neon.dist | 5 ++--- phpunit.xml.dist | 6 +++++- psalm.xml.dist | 16 -------------- 8 files changed, 27 insertions(+), 125 deletions(-) delete mode 100644 .php-cs-fixer.dist.php delete mode 100644 .php_cs.dist delete mode 100644 psalm.xml.dist diff --git a/.gitattributes b/.gitattributes index 886475c..9e9519b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,9 +6,14 @@ /.gitattributes export-ignore /.gitignore export-ignore /phpunit.xml.dist export-ignore +/art export-ignore +/docs export-ignore /tests export-ignore /.editorconfig export-ignore -/.php_cs.dist export-ignore +/.php_cs.dist.php export-ignore /psalm.xml export-ignore /psalm.xml.dist export-ignore /testbench.yaml export-ignore +/UPGRADING.md export-ignore +/phpstan.neon.dist export-ignore +/phpstan-baseline.neon export-ignore diff --git a/.gitignore b/.gitignore index 44fbb98..91b23b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,12 @@ .idea -.php_cs -.php_cs.cache -.php-cs-fixer.cache .phpunit.result.cache .phpunit.cache -build composer.lock coverage -docs phpunit.xml -psalm.xml +phpstan.neon testbench.yaml vendor node_modules -phpstan.neon +.phpactor.json +build diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php deleted file mode 100644 index 8f74534..0000000 --- a/.php-cs-fixer.dist.php +++ /dev/null @@ -1,48 +0,0 @@ - true, - 'array_indentation' => true, - 'array_syntax' => ['syntax' => 'short'], - 'binary_operator_spaces' => true, - 'blank_line_before_statement' => [ - 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], - ], - 'class_attributes_separation' => [ - 'elements' => ['const' => 'one','method' => 'one','property' => 'one'], - ], - 'concat_space' => ['spacing' => 'one'], - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'method_chaining_indentation' => true, - 'no_unused_imports' => true, - 'not_operator_with_successor_space' => false, - 'ordered_imports' => ['sort_algorithm' => 'alpha'], - 'phpdoc_scalar' => true, - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_var_without_name' => true, - 'return_type_declaration' => true, - 'single_quote' => true, - 'single_trait_insert_per_statement' => true, - 'trailing_comma_in_multiline' => true, - 'unary_operator_spaces' => true, -]; - -$finder = Finder::create() - ->in([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->name('*.php') - ->notName('*.blade.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return (new Config()) - ->setRules($rules) - ->setFinder($finder); diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index 0d8b89e..0000000 --- a/.php_cs.dist +++ /dev/null @@ -1,40 +0,0 @@ -in([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->name('*.php') - ->notName('*.blade.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return PhpCsFixer\Config::create() - ->setRules([ - '@PSR2' => true, - 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => ['sortAlgorithm' => 'alpha'], - 'no_unused_imports' => true, - 'not_operator_with_successor_space' => false, - 'trailing_comma_in_multiline_array' => true, - 'phpdoc_scalar' => true, - 'unary_operator_spaces' => true, - 'binary_operator_spaces' => true, - 'blank_line_before_statement' => [ - 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], - ], - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_var_without_name' => true, - 'class_attributes_separation' => [ - 'elements' => [ - 'method', - ], - ], - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'single_trait_insert_per_statement' => true, - ]) - ->setFinder($finder); diff --git a/README.md b/README.md index f59330f..6c2175b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ [![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/laravel-flysystem-cloudinary.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-flysystem-cloudinary) +[![GitHub-Tests](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/run-tests.yml) +[![GitHub Code Style](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/fix-php-code-style-issues.yml) [![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/laravel-flysystem-cloudinary.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-flysystem-cloudinary) -[![run-tests](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/run-tests.yml) -[![PHPStan](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/phpstan.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/phpstan.yml) -[![Fix PHP code style issues](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-flysystem-cloudinary/actions/workflows/fix-php-code-style-issues.yml) ## 💡 What is Cloudinary? @@ -17,12 +16,15 @@ additional parameters to your url 😉 - Cloudinary Account -| Package | PHP | Laravel | Flysystem | -|-----------|--------|---------------|-------------| -| >v4.0 | >8.3 | > Laravel 11 | > 3.0 | -| >v3.0 | >8.2 | > Laravel 10 | > 3.0 | -| >v2.0 | >8.1 | > Laravel 9 | > 3.0 | -| >v1.0 | >8.0 | > Laravel 8 | > 1.1 | +| Package | PHP | Laravel | Flysystem | +|-----------|-------------|-----------|-------------| +| v12.0 | ^8.2 - ^8.4 | 12.x | 3.25.1 | +| v11.0 | ^8.2 - ^8.3 | 11.x | 3.0 | +| v4.0 | ^8.2 - ^8.3 | 11.x | 3.0 | +| v3.0 | 8.2 | 10.x | 3.0 | +| v2.0 | 8.1 | 9.x | 3.0 | +| v1.0 | 8.0 | 8.x | 1.1 | + ## ⚙️ Installation diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e005ac7..0cc2d04 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,12 +2,11 @@ includes: - phpstan-baseline.neon parameters: - level: 4 + level: 5 paths: - src - config tmpDir: build/phpstan checkOctaneCompatibility: true checkModelProperties: true - checkMissingIterableValueType: false - + noEnvCallsOutsideOfConfig: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index da39c85..e36c338 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ @@ -16,7 +16,11 @@ + + + + diff --git a/psalm.xml.dist b/psalm.xml.dist deleted file mode 100644 index c6df33e..0000000 --- a/psalm.xml.dist +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - From 7d66371ea549219c2d1983d66fc50f6de7e00e4f Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:43:28 +0000 Subject: [PATCH 3/4] WIP --- src/FlysystemCloudinaryAdapter.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/FlysystemCloudinaryAdapter.php b/src/FlysystemCloudinaryAdapter.php index 1b26227..6896caa 100644 --- a/src/FlysystemCloudinaryAdapter.php +++ b/src/FlysystemCloudinaryAdapter.php @@ -341,7 +341,7 @@ public function read(string $path): string $path = $this->ensureFolderIsPrefixed(trim($path, '/')); try { - $contents = file_get_contents(Media::fromParams($path)); + $contents = file_get_contents(Media::fromParams($path, [])); } catch (Exception) { $contents = ''; } @@ -488,6 +488,7 @@ private function getMetadata(string $path, string $type): FileAttributes $attributes = $this->mapToFileAttributes($result); + // @phpstan-ignore-next-line if (! $attributes instanceof FileAttributes) { throw UnableToRetrieveMetadata::create($path, $type); } @@ -688,11 +689,11 @@ public function directoryExists(string $path): bool do { $response = (array) $this->cloudinary->adminApi()->subFolders($needle, [ 'max_results' => 4, - 'next_cursor' => isset($response['next_cursor']) ? $response['next_cursor'] : null, /** @phpstan-ignore-line */ + 'next_cursor' => $response['next_cursor'] ?? null, ]); - $folders = array_merge($folders, $response['folders']); /** @phpstan-ignore-line */ - } while (array_key_exists('next_cursor', $response) && ! is_null($response['next_cursor'])); /** @phpstan-ignore-line */ + $folders = array_merge($folders, $response['folders']); + } while (array_key_exists('next_cursor', $response) && ! is_null($response['next_cursor'])); $folders_found = array_filter( $folders, function ($e) use ($path) { From 18bcdf689ab7d485152c11a57fb1a22a69071b1e Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:40:01 +0000 Subject: [PATCH 4/4] WIP --- composer.json | 2 +- src/FlysystemCloudinaryAdapter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ba751b2..63bd82f 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "php": "8.2.*|8.3.*|8.4.*", "guzzlehttp/guzzle": "^7.8", "illuminate/contracts": "^12.0", - "cloudinary/cloudinary_php": "^3.1", + "cloudinary/cloudinary_php": "^2.13", "nesbot/carbon": "^3.8", "spatie/laravel-package-tools": "^1.19" }, diff --git a/src/FlysystemCloudinaryAdapter.php b/src/FlysystemCloudinaryAdapter.php index 6896caa..f7bb77c 100644 --- a/src/FlysystemCloudinaryAdapter.php +++ b/src/FlysystemCloudinaryAdapter.php @@ -341,7 +341,7 @@ public function read(string $path): string $path = $this->ensureFolderIsPrefixed(trim($path, '/')); try { - $contents = file_get_contents(Media::fromParams($path, [])); + $contents = file_get_contents(Media::fromParams($path)); } catch (Exception) { $contents = ''; }