mirror of
https://github.com/Intervention/image.git
synced 2025-08-31 09:31:53 +02:00
Merge pull request #1276 from Intervention/oblakstudio-feat/phpcs
Oblakstudio feat/phpcs
This commit is contained in:
14
.editorconfig
Normal file
14
.editorconfig
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.php]
|
||||||
|
indent_size = 4
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,10 +1,12 @@
|
|||||||
* text=auto
|
* text=auto
|
||||||
|
|
||||||
|
/.editorconfig export-ignore
|
||||||
/.github export-ignore
|
/.github export-ignore
|
||||||
/tests export-ignore
|
/tests export-ignore
|
||||||
/.github export-ignore
|
/.github export-ignore
|
||||||
/.gitattributes export-ignore
|
/.gitattributes export-ignore
|
||||||
/.gitignore export-ignore
|
/.gitignore export-ignore
|
||||||
|
/phpcs.xml export-ignore
|
||||||
/phpunit.xml export-ignore
|
/phpunit.xml export-ignore
|
||||||
/phpunit.xml.dist export-ignore
|
/phpunit.xml.dist export-ignore
|
||||||
/docker-compose.yml export-ignore
|
/docker-compose.yml export-ignore
|
||||||
|
3
.github/workflows/run-tests.yml
vendored
3
.github/workflows/run-tests.yml
vendored
@@ -100,3 +100,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Run analyzer
|
- name: Run analyzer
|
||||||
run: vendor/bin/phpstan analyze --level=4 ./src
|
run: vendor/bin/phpstan analyze --level=4 ./src
|
||||||
|
|
||||||
|
- name: Validate coding standards
|
||||||
|
run: vendor/bin/phpcs
|
||||||
|
@@ -2,7 +2,14 @@
|
|||||||
"name": "intervention/image",
|
"name": "intervention/image",
|
||||||
"description": "PHP image manipulation",
|
"description": "PHP image manipulation",
|
||||||
"homepage": "https://image.intervention.io/",
|
"homepage": "https://image.intervention.io/",
|
||||||
"keywords": ["image", "gd", "imagick", "watermark", "thumbnail", "resize"],
|
"keywords": [
|
||||||
|
"image",
|
||||||
|
"gd",
|
||||||
|
"imagick",
|
||||||
|
"watermark",
|
||||||
|
"thumbnail",
|
||||||
|
"resize"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -19,11 +26,11 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9",
|
"phpunit/phpunit": "^9",
|
||||||
"mockery/mockery": "^1.6",
|
"mockery/mockery": "^1.6",
|
||||||
"phpstan/phpstan": "^1"
|
"phpstan/phpstan": "^1",
|
||||||
|
"squizlabs/php_codesniffer": "^3.8"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-exif": "Recommended to be able to read EXIF data properly."
|
"ext-exif": "Recommended to be able to read EXIF data properly."
|
||||||
|
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@@ -21,3 +21,9 @@ services:
|
|||||||
command: bash -c "composer install && ./vendor/bin/phpstan analyze --memory-limit=512M --level=4 ./src"
|
command: bash -c "composer install && ./vendor/bin/phpstan analyze --memory-limit=512M --level=4 ./src"
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/project
|
- ./:/project
|
||||||
|
standards:
|
||||||
|
build: ./
|
||||||
|
working_dir: /project
|
||||||
|
command: bash -c "composer install && ./vendor/bin/phpcs"
|
||||||
|
volumes:
|
||||||
|
- ./:/project
|
||||||
|
8
phpcs.xml
Normal file
8
phpcs.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="Intervention/image">
|
||||||
|
|
||||||
|
<rule ref="PSR12"/>
|
||||||
|
|
||||||
|
<file>src/</file>
|
||||||
|
<file>tests/</file>
|
||||||
|
</ruleset>
|
@@ -25,7 +25,8 @@ class StringColorDecoder extends AbstractDecoder implements DecoderInterface
|
|||||||
throw new DecoderException('Unable to decode input');
|
throw new DecoderException('Unable to decode input');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pattern = '/^s?rgba?\((?P<r>[0-9\.]+%?), ?(?P<g>[0-9\.]+%?), ?(?P<b>[0-9\.]+%?)(?:, ?(?P<a>(?:1)|(?:1\.0*)|(?:0)|(?:0?\.\d+%?)|(?:\d{1,3}%)))?\)$/i';
|
$pattern = '/^s?rgba?\((?P<r>[0-9\.]+%?), ?(?P<g>[0-9\.]+%?), ?(?P<b>[0-9\.]+%?)' .
|
||||||
|
'(?:, ?(?P<a>(?:1)|(?:1\.0*)|(?:0)|(?:0?\.\d+%?)|(?:\d{1,3}%)))?\)$/i';
|
||||||
if (preg_match($pattern, $input, $matches) != 1) {
|
if (preg_match($pattern, $input, $matches) != 1) {
|
||||||
throw new DecoderException('Unable to decode input');
|
throw new DecoderException('Unable to decode input');
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,8 @@ class GdInputHandlerTest extends TestCase
|
|||||||
public function testHandleDataUriImage(): void
|
public function testHandleDataUriImage(): void
|
||||||
{
|
{
|
||||||
$handler = new InputHandler();
|
$handler = new InputHandler();
|
||||||
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNb' .
|
||||||
|
'yblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
||||||
$result = $handler->handle($input);
|
$result = $handler->handle($input);
|
||||||
$this->assertInstanceOf(Image::class, $result);
|
$this->assertInstanceOf(Image::class, $result);
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,8 @@ class InputHandlerTest extends TestCase
|
|||||||
public function testHandleDataUriImage(): void
|
public function testHandleDataUriImage(): void
|
||||||
{
|
{
|
||||||
$handler = new InputHandler();
|
$handler = new InputHandler();
|
||||||
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
$input = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACN' .
|
||||||
|
'byblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
|
||||||
$result = $handler->handle($input);
|
$result = $handler->handle($input);
|
||||||
$this->assertInstanceOf(Image::class, $result);
|
$this->assertInstanceOf(Image::class, $result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user