Skip to content

Commit

Permalink
Merge pull request #142 from Sybio/rector-refactoring
Browse files Browse the repository at this point in the history
Refactoring code using Rector
  • Loading branch information
jdecool authored May 15, 2022
2 parents 80d981e + 46d1cdf commit 4eb9bc9
Show file tree
Hide file tree
Showing 14 changed files with 336 additions and 623 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1']
php-version: ['8.0', '8.1']
name: 'PHPUnit - PHP/${{ matrix.php-version }} - OS/${{ matrix.os }}'
steps:
- name: Checkout
Expand Down
76 changes: 40 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
# ================================
# ImageWorkshop class
# ================================

[![Test status](https://secure.travis-ci.org/Sybio/ImageWorkshop.png?branch=master)](https://travis-ci.org/Sybio/ImageWorkshop)
[![Latest Stable Version](https://poser.pugx.org/sybio/image-workshop/v/stable)](https://packagist.org/packages/sybio/image-workshop)
[![Total Downloads](https://poser.pugx.org/sybio/image-workshop/downloads)](https://packagist.org/packages/sybio/image-workshop)
[![Monthly Downloads](https://poser.pugx.org/sybio/image-workshop/d/monthly)](https://packagist.org/packages/sybio/image-workshop)
[![License](https://poser.pugx.org/sybio/image-workshop/license)](https://packagist.org/packages/sybio/image-workshop)

### Summary and features
Really flexible and easy-to-use PHP class to work with images using the GD Library

http://phpimageworkshop.com/

### Installation

The class is designed for PHP 5.3+, but it can work with older PHP versions... Check how to install the class here: http://phpimageworkshop.com/installation.html

### Usage

- Learn how to use the class in 5 minutes: http://phpimageworkshop.com/quickstart.html
- The complete documentation: http://phpimageworkshop.com/documentation.html
- Usefull tutorials: http://phpimageworkshop.com/tutorials.html
- Changelog: [CHANGELOG.md](CHANGELOG.md)

**What's new in the doc' ?**

- Installation guide: http://phpimageworkshop.com/installation.html
- Adding the flip documentation: http://phpimageworkshop.com/doc/25/flip-vertical-horizontal-mirror.html
- Adding the opacity documentation which was omitted: http://phpimageworkshop.com/doc/24/opacity-transparency.html
- Tutorial "Manage animated GIF with ImageWorkshop (and GiFFrameExtractor & GifCreator)": http://phpimageworkshop.com/tutorial/5/manage-animated-gif-with-imageworkshop.html

### @todo
- Adding a method to add easily borders to a layer (external, inside and middle border)
- Check given hexa' color and remove # if exists.
# ================================
# ImageWorkshop class
# ================================

[![Test status](https://secure.travis-ci.org/Sybio/ImageWorkshop.png?branch=master)](https://travis-ci.org/Sybio/ImageWorkshop)
[![Latest Stable Version](https://poser.pugx.org/sybio/image-workshop/v/stable)](https://packagist.org/packages/sybio/image-workshop)
[![Total Downloads](https://poser.pugx.org/sybio/image-workshop/downloads)](https://packagist.org/packages/sybio/image-workshop)
[![Monthly Downloads](https://poser.pugx.org/sybio/image-workshop/d/monthly)](https://packagist.org/packages/sybio/image-workshop)
[![License](https://poser.pugx.org/sybio/image-workshop/license)](https://packagist.org/packages/sybio/image-workshop)

### Summary and features
Really flexible and easy-to-use PHP class to work with images using the GD Library

http://phpimageworkshop.com/

Current `master` branch correspond to the next major release (v3) which only support PHP 8.0+.

### Installation

The class is designed for PHP 8.0+... Check how to install the class here: http://phpimageworkshop.com/installation.html

For older PHP versions support, install the [2.x](https://github.com/Sybio/ImageWorkshop/tree/2.x) version branch.

### Usage

- Learn how to use the class in 5 minutes: http://phpimageworkshop.com/quickstart.html
- The complete documentation: http://phpimageworkshop.com/documentation.html
- Usefull tutorials: http://phpimageworkshop.com/tutorials.html
- Changelog: [CHANGELOG.md](CHANGELOG.md)

**What's new in the doc' ?**

- Installation guide: http://phpimageworkshop.com/installation.html
- Adding the flip documentation: http://phpimageworkshop.com/doc/25/flip-vertical-horizontal-mirror.html
- Adding the opacity documentation which was omitted: http://phpimageworkshop.com/doc/24/opacity-transparency.html
- Tutorial "Manage animated GIF with ImageWorkshop (and GiFFrameExtractor & GifCreator)": http://phpimageworkshop.com/tutorial/5/manage-animated-gif-with-imageworkshop.html

### @todo
- Adding a method to add easily borders to a layer (external, inside and middle border)
- Check given hexa' color and remove # if exists.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
}
],
"require": {
"php": ">=7.2.0",
"php": "^8.0",
"ext-fileinfo": "*",
"ext-gd": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"phpunit/phpunit": "^8.5.13",
"phpstan/phpstan": "^1.3"
"phpstan/phpstan": "^1.3",
"rector/rector": "^0.12.23"
},
"suggest": {
"ext-exif": "Allows to read and keep images EXIF data"
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ parameters:
level: 5
bootstrapFiles:
- %rootDir%/../../../vendor/autoload.php

ignoreErrors:
-
message: '#Left side of && is always true#'
path: src/Core/ImageWorkshopLayer.php
39 changes: 39 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php74\Rector\Assign\NullCoalescingOperatorRector;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;

return static function(RectorConfig $config): void {
$config->paths([
__DIR__ . '/src'
]);

$config->import(SetList::DEAD_CODE);
$config->import(SetList::TYPE_DECLARATION_STRICT);
$config->import(SetList::TYPE_DECLARATION);
$config->import(SetList::PHP_80);
$config->import(SetList::PHP_74);
$config->import(SetList::PHP_73);
$config->import(SetList::EARLY_RETURN);
$config->import(SetList::CODE_QUALITY);

// register a single rule
$config->rule(InlineConstructorDefaultToPropertyRector::class);
$config->rule(RemoveExtraParametersRector::class);

// define sets of rules
$config->sets([
LevelSetList::UP_TO_PHP_80
]);

$config->phpstanConfig(__DIR__ . '/phpstan.neon');
};
2 changes: 1 addition & 1 deletion src/Core/Exception/ImageWorkshopLayerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPImageWorkshop\Core\Exception;

use PHPImageWorkshop\Exception\ImageWorkshopBaseException as ImageWorkshopBaseException;
use PHPImageWorkshop\Exception\ImageWorkshopBaseException;

/**
* ImageWorkshopLayerException
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Exception/ImageWorkshopLibException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPImageWorkshop\Core\Exception;

use PHPImageWorkshop\Exception\ImageWorkshopBaseException as ImageWorkshopBaseException;
use PHPImageWorkshop\Exception\ImageWorkshopBaseException;

/**
* ImageWorkshopLibException
Expand Down
Loading

0 comments on commit 4eb9bc9

Please sign in to comment.