Skip to content

Commit

Permalink
Major update - added strict types, increased phpstan to level 8, PSR1…
Browse files Browse the repository at this point in the history
…2 support (#31)

* Update tests.yml

* Update tests.yml

* Updated project to be compliant with phpstan level 6

* Update PelIfd.php

* phpcs fix

* Updated phpstan config

* Changed order of github actions operations

* Updated phpstan to level 7

* Updated phpstan to level 8

* Added rector support

* Removed support for php 8.1

* Added declare(strict_types=1)

* Update PelIllegalFormatException.php

* Added phpinsights

* Rector fix

* Update tests.yml

* Updated phpcs to use PSR12 standard

* Update phpinsights.php

* Updated examples

* Added support for file streams to avoid memory issues when reading large files

* Updated phpinsights config, added more tests

* Added more tests

* Added more tests

* Updated tests

* Create .gitattributes

* Update .gitattributes

* Readd 8.1, fail PHPUnit on warnings

* Update tests.yml

* Fixed phpunit warnings

* Updated composer deps for php 8.1

* Update PelFileStream.php

* Updated deps for php 8.1 (hopefully)

* Removed composer.lock to avoid issues with different versions

* Removed git actions cache

---------

Co-authored-by: mondrake <[email protected]>
  • Loading branch information
indy2kro and mondrake authored Jan 7, 2025
1 parent 05476c8 commit 71bc738
Show file tree
Hide file tree
Showing 108 changed files with 5,594 additions and 7,011 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.github/ export-ignore
test/ export-ignore
examples/ export-ignore
tutorials/ export-ignore
*.sh export-ignore
make-image-test.php export-ignore
22 changes: 13 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,23 @@ jobs:
- name: Install Composer dependencies
run: composer install --no-progress --ansi

- name: Code style test
run: ./vendor/bin/phpcs

- name: PHPStan code analysis
run: php vendor/bin/phpstan analyze

- name: PHPinsights code analysis
run: php vendor/bin/phpinsights analyse --no-interaction

- name: Execute Rector
run: vendor/bin/rector --dry-run

- name: Run tests
run: ./vendor/bin/phpunit --color=always --coverage-clover=coverage.xml ./test
run: ./vendor/bin/phpunit --color=always --coverage-clover=coverage.xml --testdox --fail-on-warning ./test

- name: Send code coverage report to Codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml

- name: Code style test
if: ${{ matrix.php-version == 8.2 }}
run: ./vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1

- name: PHPStan code analysis
if: ${{ matrix.php-version == 8.2 }}
run: php vendor/bin/phpstan analyze
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ doc/*
vendor
ChangeLog
build-base*
composer.lock
/.phpcs-cache
/.phpunit.result.cache
/composer.lock
/.settings/
91 changes: 47 additions & 44 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
{
"name" : "fileeye/pel",
"type" : "library",
"description" : "PHP Exif Library. A library for reading and writing Exif headers in JPEG and TIFF images using PHP.",
"keywords" : [
"image",
"exif"
],
"homepage" : "https://github.com/FileEye/pel",
"authors" : [{
"name" : "Lars Olesen",
"email" : "[email protected]",
"homepage" : "http://intraface.dk",
"role" : "Developer"
}, {
"name" : "Martin Geisler",
"email" : "[email protected]",
"homepage" : "http://geisler.net",
"role" : "Developer"
}
],
"license" : "GPL-2.0",
"require" : {
"php" : ">=8.1"
},
"require-dev" : {
"ext-gd" : "*",
"ext-exif" : "*",
"squizlabs/php_codesniffer" : ">=3.8",
"phpunit/phpunit" : "^10 || ^11 ",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2",
"phpstan/phpstan-phpunit": "^2"
},
"name" : "fileeye/pel",
"type" : "library",
"description" : "PHP Exif Library. A library for reading and writing Exif headers in JPEG and TIFF images using PHP.",
"keywords" : [
"image",
"exif"
],
"homepage" : "https://github.com/FileEye/pel",
"authors" : [{
"name" : "Lars Olesen",
"email" : "[email protected]",
"homepage" : "http://intraface.dk",
"role" : "Developer"
}, {
"name" : "Martin Geisler",
"email" : "[email protected]",
"homepage" : "http://geisler.net",
"role" : "Developer"
}
],
"license" : "GPL-2.0",
"require" : {
"php" : ">=8.1"
},
"require-dev" : {
"ext-gd" : "*",
"ext-exif" : "*",
"squizlabs/php_codesniffer" : ">=3.7",
"phpunit/phpunit" : "^10 || ^11 ",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1 || ^2",
"phpstan/phpstan-phpunit": "^1 || ^2",
"rector/rector": "^1 || ^2",
"nunomaduro/phpinsights": "^1 || ^2"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"autoload" : {
"psr-4" : {
"lsolesen\\pel\\" : "src/"
}
},
"autoload-dev" : {
"psr-4" : {
"Pel\\Test\\" : "test/"
}
}
"autoload" : {
"psr-4" : {
"lsolesen\\pel\\" : "src/"
}
},
"autoload-dev" : {
"psr-4" : {
"Pel\\Test\\" : "test/"
}
}
}
4 changes: 4 additions & 0 deletions examples/dirsort.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@

/* a printf() variant that appends a newline to the output. */

namespace Pel\examples;

use lsolesen\pel\Pel;
use lsolesen\pel\PelDataWindow;
use lsolesen\pel\PelJpeg;
use lsolesen\pel\PelTag;
use lsolesen\pel\PelTiff;

require_once dirname(dirname(__FILE__)) . '/autoload.php';

function println($args)
{
$args = func_get_args();
Expand Down
4 changes: 4 additions & 0 deletions examples/dump-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* Boston, MA 02110-1301 USA
*/

namespace Pel\examples;

/* Make PEL speak the users language, if it is available. */
setlocale(LC_ALL, '');

Expand All @@ -33,6 +35,8 @@
use lsolesen\pel\PelJpeg;
use lsolesen\pel\PelTiff;

require_once dirname(dirname(__FILE__)) . '/autoload.php';

$prog = array_shift($argv);
$file = '';

Expand Down
4 changes: 4 additions & 0 deletions examples/edit-description.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* Boston, MA 02110-1301 USA
*/

namespace Pel\examples;

/* a printf() variant that appends a newline to the output. */
use lsolesen\pel\Pel;
use lsolesen\pel\PelConvert;
Expand All @@ -35,6 +37,8 @@
use lsolesen\pel\PelTag;
use lsolesen\pel\PelTiff;

require_once dirname(dirname(__FILE__)) . '/autoload.php';

function println($args)
{
$args = func_get_args();
Expand Down
5 changes: 5 additions & 0 deletions examples/gps.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
* used in Exif data.
* - addGpsInfo() adds several Exif tags to your JPEG file.
*/

namespace Pel\examples;

use lsolesen\pel\PelEntryAscii;
use lsolesen\pel\PelEntryByte;
use lsolesen\pel\PelEntryRational;
Expand All @@ -44,6 +47,8 @@
use lsolesen\pel\PelTag;
use lsolesen\pel\PelTiff;

require_once dirname(dirname(__FILE__)) . '/autoload.php';

/**
* Convert a decimal degree into degrees, minutes, and seconds.
*
Expand Down
4 changes: 4 additions & 0 deletions examples/rename.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@
* available time will be used.
*/

namespace Pel\examples;

/* a printf() variant that appends a newline to the output. */
use lsolesen\pel\Pel;
use lsolesen\pel\PelDataWindow;
use lsolesen\pel\PelJpeg;
use lsolesen\pel\PelTag;
use lsolesen\pel\PelTiff;

require_once dirname(dirname(__FILE__)) . '/autoload.php';

function println($args)
{
$args = func_get_args();
Expand Down
2 changes: 2 additions & 0 deletions examples/resize.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use lsolesen\pel\Pel;
use lsolesen\pel\PelJpeg;

require_once dirname(dirname(__FILE__)) . '/autoload.php';

/**
* a printf() variant that appends a newline to the output.
*/
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="parallel" value="10"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors" />

Expand All @@ -12,7 +12,7 @@
<file>src</file>
<file>test</file>

<rule ref="PSR2"/>
<rule ref="PSR12"/>

<!-- Allow long lines -->
<rule ref="Generic.Files.LineLength">
Expand Down
Loading

0 comments on commit 71bc738

Please sign in to comment.