From 77bba8364fcb23f0e9d78916ac46215024bf9d91 Mon Sep 17 00:00:00 2001 From: duncte123 <contact@duncte123.me> Date: Tue, 2 Jun 2020 09:28:46 +0200 Subject: [PATCH] Force consistency with an editorconfig --- .editorconfig | 15 +++++++++++++++ src/Color.php | 12 ++++++------ src/HorizontalAlignment.php | 2 +- src/Struct/Point.php | 6 +++--- src/Struct/Rectangle.php | 14 +++++++------- src/TextWrapping.php | 2 +- src/VerticalAlignment.php | 2 +- tests/TestCase.php | 2 +- 8 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6537ca4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/src/Color.php b/src/Color.php index 5efee50..1f2311e 100644 --- a/src/Color.php +++ b/src/Color.php @@ -47,7 +47,7 @@ public function __construct($red = 0, $green = 0, $blue = 0, $alpha = null) * @return Color * @todo Add parsing of CSS-like strings: rgb(), rgba(), hsl() */ - public static function parseString($str) + public static function parseString($str): Color { $str = str_replace('#', '', $str); if (strlen($str) == 6) { @@ -71,7 +71,7 @@ public static function parseString($str) * @param float $l Light * @return Color */ - public static function fromHsl($h, $s, $l) + public static function fromHsl($h, $s, $l): Color { $fromFloat = function (array $rgb) { foreach ($rgb as &$v) { @@ -110,7 +110,7 @@ public static function fromHsl($h, $s, $l) * @return int Returns the index of the specified color+alpha in the palette of the image, * or index of allocated color if the color does not exist in the image's palette. */ - public function getIndex($image) + public function getIndex($image): int { $index = $this->hasAlphaChannel() ? imagecolorexactalpha( @@ -132,7 +132,7 @@ public function getIndex($image) /** * @return bool TRUE when alpha channel is specified, FALSE otherwise */ - public function hasAlphaChannel() + public function hasAlphaChannel(): bool { return $this->alpha !== null; } @@ -142,6 +142,6 @@ public function hasAlphaChannel() */ public function toArray() { - return array($this->red, $this->green, $this->blue); + return [$this->red, $this->green, $this->blue]; } -} \ No newline at end of file +} diff --git a/src/HorizontalAlignment.php b/src/HorizontalAlignment.php index 3a4aee7..b658c68 100644 --- a/src/HorizontalAlignment.php +++ b/src/HorizontalAlignment.php @@ -6,4 +6,4 @@ abstract class HorizontalAlignment const Left = 'left'; const Right = 'right'; const Center = 'center'; -} \ No newline at end of file +} diff --git a/src/Struct/Point.php b/src/Struct/Point.php index 7060b30..bc28947 100644 --- a/src/Struct/Point.php +++ b/src/Struct/Point.php @@ -28,7 +28,7 @@ public function __construct($x, $y) /** * @return int */ - public function getX() + public function getX(): int { return $this->x; } @@ -36,8 +36,8 @@ public function getX() /** * @return int */ - public function getY() + public function getY(): int { return $this->y; } -} \ No newline at end of file +} diff --git a/src/Struct/Rectangle.php b/src/Struct/Rectangle.php index c24e708..0af79a4 100644 --- a/src/Struct/Rectangle.php +++ b/src/Struct/Rectangle.php @@ -31,7 +31,7 @@ public function __construct($x, $y, $width, $height) /** * @return int */ - public function getWidth() + public function getWidth(): int { return $this->width; } @@ -39,7 +39,7 @@ public function getWidth() /** * @return int */ - public function getHeight() + public function getHeight(): int { return $this->height; } @@ -47,7 +47,7 @@ public function getHeight() /** * @return int */ - public function getLeft() + public function getLeft(): int { return $this->getX(); } @@ -55,7 +55,7 @@ public function getLeft() /** * @return int */ - public function getTop() + public function getTop(): int { return $this->getY(); } @@ -63,7 +63,7 @@ public function getTop() /** * @return int */ - public function getRight() + public function getRight(): int { return $this->getX() + $this->width; } @@ -71,8 +71,8 @@ public function getRight() /** * @return int */ - public function getBottom() + public function getBottom(): int { return $this->getY() + $this->height; } -} \ No newline at end of file +} diff --git a/src/TextWrapping.php b/src/TextWrapping.php index a0b04bd..5aafc27 100644 --- a/src/TextWrapping.php +++ b/src/TextWrapping.php @@ -5,4 +5,4 @@ abstract class TextWrapping { const NoWrap = 1; const WrapWithOverflow = 2; -} \ No newline at end of file +} diff --git a/src/VerticalAlignment.php b/src/VerticalAlignment.php index 5e5b86d..161095b 100644 --- a/src/VerticalAlignment.php +++ b/src/VerticalAlignment.php @@ -6,4 +6,4 @@ abstract class VerticalAlignment const Top = 'top'; const Bottom = 'bottom'; const Center = 'center'; -} \ No newline at end of file +} diff --git a/tests/TestCase.php b/tests/TestCase.php index f687d70..2ee230a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -36,4 +36,4 @@ protected function assertImageEquals($name, $im) $this->assertEquals($this->sha1ImageResource($name), $sha1); } -} \ No newline at end of file +}