From c0809880bf0ba6187c6ef15437005aa15ccd1832 Mon Sep 17 00:00:00 2001 From: Jake Jackson Date: Wed, 11 Mar 2026 14:58:12 +1100 Subject: [PATCH 1/2] Update to support PHP 8.3 to 8.5 --- .github/workflows/php-syntax.yml | 2 +- .github/workflows/phpunit.yml | 4 ++-- composer.json | 2 +- src/Upload/Exception.php | 2 +- src/Upload/FileInfo.php | 13 ++++++++----- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/php-syntax.yml b/.github/workflows/php-syntax.yml index 3695bd5..a7ba52c 100644 --- a/.github/workflows/php-syntax.yml +++ b/.github/workflows/php-syntax.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - php: [ '7.3', '7.4', '8.0', '8.1', '8.2' ] + php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] steps: - name: Checkout diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 2565b20..bbf6c1d 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - php: [ '7.3', '7.4', '8.0', '8.1', '8.2' ] + php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] include: - php: '7.3' os: ubuntu-latest @@ -70,4 +70,4 @@ jobs: if: ${{ matrix.report }} run: | vendor/bin/phpunit --verbose --coverage-clover=tmp/coverage/report-xml/php-coverage1.xml - bash <(curl -s https://codecov.io/bash); \ No newline at end of file + bash <(curl -s https://codecov.io/bash); diff --git a/composer.json b/composer.json index 80f4f88..edc87f9 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "source": "https://github.com/gravitypdf/upload" }, "require": { - "php": "^7.3 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "php": "^7.3 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", "ext-fileinfo": "*" }, "require-dev": { diff --git a/src/Upload/Exception.php b/src/Upload/Exception.php index 5354646..4675384 100644 --- a/src/Upload/Exception.php +++ b/src/Upload/Exception.php @@ -19,7 +19,7 @@ class Exception extends RuntimeException * @param string $message The Exception message * @param FileInfoInterface|null $fileInfo The related file instance */ - public function __construct($message, FileInfoInterface $fileInfo = null) + public function __construct($message, ?FileInfoInterface $fileInfo = null) { $this->fileInfo = $fileInfo; diff --git a/src/Upload/FileInfo.php b/src/Upload/FileInfo.php index f2cec4d..dadc7e3 100644 --- a/src/Upload/FileInfo.php +++ b/src/Upload/FileInfo.php @@ -77,7 +77,7 @@ class FileInfo extends SplFileInfo implements FileInfoInterface * @param string $filePathname Absolute path to uploaded file on disk * @param string|null $newName Desired file name (with extension) of uploaded file */ - final public function __construct(string $filePathname, string $newName = null) + final public function __construct(string $filePathname, ?string $newName = null) { $desiredName = is_null($newName) ? $filePathname : $newName; $this->setNameWithExtension($desiredName); @@ -90,7 +90,7 @@ public static function setFactory(callable $callable): void static::$factory = $callable; } - public static function createFromFactory(string $tmpName, string $name = null): FileInfoInterface + public static function createFromFactory(string $tmpName, ?string $name = null): FileInfoInterface { if (is_callable(static::$factory)) { $result = call_user_func(static::$factory, $tmpName, $name); @@ -336,11 +336,14 @@ public function getHash(string $algorithm = 'md5'): string */ public function getDimensions(): array { - [$width, $height] = (array)getimagesize($this->getPathname()); + $imageSize = getimagesize($this->getPathname()); + if (!$imageSize) { + $imageSize = [0,0]; + } return [ - 'width' => $width ?? 0, - 'height' => $height ?? 0, + 'width' => $imageSize[0], + 'height' => $imageSize[1], ]; } From 7789a91b15788addbe64e8760f1d1ad88da04e4f Mon Sep 17 00:00:00 2001 From: Jake Jackson Date: Wed, 11 Mar 2026 15:06:17 +1100 Subject: [PATCH 2/2] Update GitHub Action versions --- .github/workflows/php-syntax.yml | 4 ++-- .github/workflows/phpcs.yml | 6 +++--- .github/workflows/phpstan.yml | 6 +++--- .github/workflows/phpunit.yml | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/php-syntax.yml b/.github/workflows/php-syntax.yml index a7ba52c..119dd4d 100644 --- a/.github/workflows/php-syntax.yml +++ b/.github/workflows/php-syntax.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -49,7 +49,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer dependencies - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + uses: actions/cache@v5 env: cache-name: cache-composer-dependencies with: diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index ab85593..12b999b 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -44,7 +44,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer dependencies - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + uses: actions/cache@v5 env: cache-name: cache-composer-dependencies with: @@ -55,4 +55,4 @@ jobs: run: composer install - name: Run PHPUnit tests - run: composer run lint \ No newline at end of file + run: composer run lint diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 1ae8774..7fcbdfb 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -44,7 +44,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer dependencies - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + uses: actions/cache@v5 env: cache-name: cache-composer-dependencies with: @@ -55,4 +55,4 @@ jobs: run: composer install - name: Run PHPUnit tests - run: composer run phpstan \ No newline at end of file + run: composer run phpstan diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index bbf6c1d..ebc60a2 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Install PHP uses: shivammathur/setup-php@v2 @@ -53,7 +53,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer dependencies - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + uses: actions/cache@v5 env: cache-name: cache-composer-dependencies with: