From ba548b5b08f2d864ddaa9613f40fcee83b943a0a Mon Sep 17 00:00:00 2001 From: Florian Moser Date: Mon, 1 Jan 2024 18:50:20 +0100 Subject: [PATCH] maint: Apply readonly consistently --- composer.json | 2 +- composer.lock | 104 +++++++++--------- src/Backend/File/ObjectVisitor.php | 2 +- src/Backend/Structure/Document.php | 2 +- src/Frontend/Content/Paragraph.php | 5 +- src/Frontend/Content/Style/DrawingStyle.php | 9 +- src/Frontend/Content/Style/TextStyle.php | 8 +- .../Allocators/ParagraphAllocator.php | 4 +- .../Measure/Measurer/GridMeasurer.php | 2 +- .../Measure/Measurer/ParagraphMeasurer.php | 2 +- src/Utils/LUDecomposition3By3.php | 2 +- 11 files changed, 63 insertions(+), 79 deletions(-) diff --git a/composer.json b/composer.json index d5cb6fc9..4ff58458 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "friendsofphp/php-cs-fixer": "^3", "mockery/mockery": "^1.2", "phpunit/phpunit": "^9.5.4", - "rector/rector": "^0.17.0", + "rector/rector": "^0.18.0", "scrutinizer/ocular": "^1.9" }, "autoload": { diff --git a/composer.lock b/composer.lock index ba774ca9..6653d2c5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "21331210c029dbb39822598334152229", + "content-hash": "b5a709d464bc7e714ad51b6509cabb8f", "packages": [ { "name": "famoser/agnes", @@ -655,16 +655,16 @@ }, { "name": "symfony/console", - "version": "v5.4.32", + "version": "v5.4.34", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c70df1ffaf23a8d340bded3cfab1b86752ad6ed7" + "reference": "4b4d8cd118484aa604ec519062113dd87abde18c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c70df1ffaf23a8d340bded3cfab1b86752ad6ed7", - "reference": "c70df1ffaf23a8d340bded3cfab1b86752ad6ed7", + "url": "https://api.github.com/repos/symfony/console/zipball/4b4d8cd118484aa604ec519062113dd87abde18c", + "reference": "4b4d8cd118484aa604ec519062113dd87abde18c", "shasum": "" }, "require": { @@ -734,7 +734,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.32" + "source": "https://github.com/symfony/console/tree/v5.4.34" }, "funding": [ { @@ -750,7 +750,7 @@ "type": "tidelift" } ], - "time": "2023-11-18T18:23:04+00:00" + "time": "2023-12-08T13:33:03+00:00" }, { "name": "symfony/deprecation-contracts", @@ -821,16 +821,16 @@ }, { "name": "symfony/dotenv", - "version": "v6.4.0", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/dotenv.git", - "reference": "d0d584a91422ddaa2c94317200d4c4e5b935555f" + "reference": "835f8d2d1022934ac038519de40b88158798c96f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dotenv/zipball/d0d584a91422ddaa2c94317200d4c4e5b935555f", - "reference": "d0d584a91422ddaa2c94317200d4c4e5b935555f", + "url": "https://api.github.com/repos/symfony/dotenv/zipball/835f8d2d1022934ac038519de40b88158798c96f", + "reference": "835f8d2d1022934ac038519de40b88158798c96f", "shasum": "" }, "require": { @@ -875,7 +875,7 @@ "environment" ], "support": { - "source": "https://github.com/symfony/dotenv/tree/v6.4.0" + "source": "https://github.com/symfony/dotenv/tree/v6.4.2" }, "funding": [ { @@ -891,7 +891,7 @@ "type": "tidelift" } ], - "time": "2023-10-26T18:19:48+00:00" + "time": "2023-12-28T19:16:56+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1387,21 +1387,21 @@ }, { "name": "symfony/service-contracts", - "version": "v3.4.0", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838" + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/b3313c2dbffaf71c8de2934e2ea56ed2291a3838", - "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/fe07cbc8d837f60caf7018068e350cc5163681a0", + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^2.0" + "psr/container": "^1.1|^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -1449,7 +1449,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.4.1" }, "funding": [ { @@ -1465,20 +1465,20 @@ "type": "tidelift" } ], - "time": "2023-07-30T20:28:31+00:00" + "time": "2023-12-26T14:02:43+00:00" }, { "name": "symfony/string", - "version": "v6.4.0", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809" + "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/b45fcf399ea9c3af543a92edf7172ba21174d809", - "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809", + "url": "https://api.github.com/repos/symfony/string/zipball/7cb80bc10bfcdf6b5492741c0b9357dac66940bc", + "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc", "shasum": "" }, "require": { @@ -1535,7 +1535,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.0" + "source": "https://github.com/symfony/string/tree/v6.4.2" }, "funding": [ { @@ -1551,7 +1551,7 @@ "type": "tidelift" } ], - "time": "2023-11-28T20:41:49+00:00" + "time": "2023-12-10T16:15:48+00:00" }, { "name": "symfony/yaml", @@ -2143,16 +2143,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.42.0", + "version": "v3.45.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "632ef1be3447a9b890bef06147475facee535d0f" + "reference": "c0daa33cb2533cd73f48dde1c70c2afa3e7953b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/632ef1be3447a9b890bef06147475facee535d0f", - "reference": "632ef1be3447a9b890bef06147475facee535d0f", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c0daa33cb2533cd73f48dde1c70c2afa3e7953b5", + "reference": "c0daa33cb2533cd73f48dde1c70c2afa3e7953b5", "shasum": "" }, "require": { @@ -2182,7 +2182,7 @@ "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^9.6 || ^10.5.5", "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "suggest": { @@ -2221,7 +2221,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.42.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.45.0" }, "funding": [ { @@ -2229,7 +2229,7 @@ "type": "github" } ], - "time": "2023-12-24T14:38:51+00:00" + "time": "2023-12-30T02:07:07+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -3508,21 +3508,21 @@ }, { "name": "rector/rector", - "version": "0.17.13", + "version": "0.18.13", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "e2003ba7c5bda06d7bb419cf4be8dae5f8672132" + "reference": "f8011a76d36aa4f839f60f3b4f97707d97176618" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/e2003ba7c5bda06d7bb419cf4be8dae5f8672132", - "reference": "e2003ba7c5bda06d7bb419cf4be8dae5f8672132", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/f8011a76d36aa4f839f60f3b4f97707d97176618", + "reference": "f8011a76d36aa4f839f60f3b4f97707d97176618", "shasum": "" }, "require": { "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.10.26" + "phpstan/phpstan": "^1.10.35" }, "conflict": { "rector/rector-doctrine": "*", @@ -3552,7 +3552,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.17.13" + "source": "https://github.com/rectorphp/rector/tree/0.18.13" }, "funding": [ { @@ -3560,7 +3560,7 @@ "type": "github" } ], - "time": "2023-08-14T16:33:29+00:00" + "time": "2023-12-20T16:08:01+00:00" }, { "name": "scrutinizer/ocular", @@ -4573,16 +4573,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v7.0.0", + "version": "v7.0.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "c459b40ffe67c49af6fd392aac374c9edf8a027e" + "reference": "098b62ae81fdd6cbf941f355059f617db28f4f9a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/c459b40ffe67c49af6fd392aac374c9edf8a027e", - "reference": "c459b40ffe67c49af6fd392aac374c9edf8a027e", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/098b62ae81fdd6cbf941f355059f617db28f4f9a", + "reference": "098b62ae81fdd6cbf941f355059f617db28f4f9a", "shasum": "" }, "require": { @@ -4633,7 +4633,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v7.0.0" + "source": "https://github.com/symfony/event-dispatcher/tree/v7.0.2" }, "funding": [ { @@ -4649,7 +4649,7 @@ "type": "tidelift" } ], - "time": "2023-07-27T16:29:09+00:00" + "time": "2023-12-27T22:24:19+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -5002,16 +5002,16 @@ }, { "name": "symfony/process", - "version": "v6.4.0", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "191703b1566d97a5425dc969e4350d32b8ef17aa" + "reference": "c4b1ef0bc80533d87a2e969806172f1c2a980241" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/191703b1566d97a5425dc969e4350d32b8ef17aa", - "reference": "191703b1566d97a5425dc969e4350d32b8ef17aa", + "url": "https://api.github.com/repos/symfony/process/zipball/c4b1ef0bc80533d87a2e969806172f1c2a980241", + "reference": "c4b1ef0bc80533d87a2e969806172f1c2a980241", "shasum": "" }, "require": { @@ -5043,7 +5043,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.0" + "source": "https://github.com/symfony/process/tree/v6.4.2" }, "funding": [ { @@ -5059,7 +5059,7 @@ "type": "tidelift" } ], - "time": "2023-11-17T21:06:49+00:00" + "time": "2023-12-22T16:42:54+00:00" }, { "name": "symfony/stopwatch", diff --git a/src/Backend/File/ObjectVisitor.php b/src/Backend/File/ObjectVisitor.php index 811ace47..81bdfb5f 100644 --- a/src/Backend/File/ObjectVisitor.php +++ b/src/Backend/File/ObjectVisitor.php @@ -17,7 +17,7 @@ class ObjectVisitor { - private TokenVisitor $tokenVisitor; + private readonly TokenVisitor $tokenVisitor; public function __construct() { diff --git a/src/Backend/Structure/Document.php b/src/Backend/Structure/Document.php index 10377190..ba063ae6 100644 --- a/src/Backend/Structure/Document.php +++ b/src/Backend/Structure/Document.php @@ -25,7 +25,7 @@ class Document */ private array $pages = []; - private Configuration $configuration; + private readonly Configuration $configuration; public function __construct() { diff --git a/src/Frontend/Content/Paragraph.php b/src/Frontend/Content/Paragraph.php index e1328ba3..d5f6574c 100644 --- a/src/Frontend/Content/Paragraph.php +++ b/src/Frontend/Content/Paragraph.php @@ -20,16 +20,13 @@ class Paragraph extends AbstractContent { final public const ALIGNMENT_LEFT = 'ALIGNMENT_LEFT'; - private string $alignment; - /** * @var Phrase[] */ private array $phrases = []; - public function __construct(string $alignment = self::ALIGNMENT_LEFT) + public function __construct(private string $alignment = self::ALIGNMENT_LEFT) { - $this->alignment = $alignment; } public function setAlignment(string $alignment): self diff --git a/src/Frontend/Content/Style/DrawingStyle.php b/src/Frontend/Content/Style/DrawingStyle.php index 2595791c..91d114fd 100644 --- a/src/Frontend/Content/Style/DrawingStyle.php +++ b/src/Frontend/Content/Style/DrawingStyle.php @@ -16,15 +16,8 @@ class DrawingStyle { - private ?float $lineWidth; - private ?Color $lineColor; - private ?Color $fillColor; - - public function __construct(float $borderWidth = 1, ?Color $borderColor = new Color(0, 0, 0), Color $backgroundColor = null) + public function __construct(private ?float $lineWidth = 1, private ?Color $lineColor = new Color(0, 0, 0), private ?Color $fillColor = null) { - $this->lineWidth = $borderWidth; - $this->lineColor = $borderColor; - $this->fillColor = $backgroundColor; } public static function createFromBlockStyle(BlockStyle $blockStyle): self diff --git a/src/Frontend/Content/Style/TextStyle.php b/src/Frontend/Content/Style/TextStyle.php index e6537cd0..259698e5 100644 --- a/src/Frontend/Content/Style/TextStyle.php +++ b/src/Frontend/Content/Style/TextStyle.php @@ -16,16 +16,10 @@ class TextStyle { - private Font $font; - private float $fontSize; - private float $lineHeight; private Color $color; - public function __construct(Font $font, float $fontSize = 3.8, float $lineHeight = 1.2, Color $color = null) + public function __construct(private Font $font, private float $fontSize = 3.8, private float $lineHeight = 1.2, Color $color = null) { - $this->font = $font; - $this->fontSize = $fontSize; - $this->lineHeight = $lineHeight; $this->color = $color ?? new Color(0, 0, 0); } diff --git a/src/Frontend/LayoutEngine/Allocate/Allocators/ParagraphAllocator.php b/src/Frontend/LayoutEngine/Allocate/Allocators/ParagraphAllocator.php index 75a6cbe0..1654016e 100644 --- a/src/Frontend/LayoutEngine/Allocate/Allocators/ParagraphAllocator.php +++ b/src/Frontend/LayoutEngine/Allocate/Allocators/ParagraphAllocator.php @@ -17,7 +17,7 @@ class ParagraphAllocator { - private FontRepository $fontRepository; + private readonly FontRepository $fontRepository; public function __construct(private readonly float $width, private readonly float $height) { @@ -106,7 +106,7 @@ private static function allocatePhrase(FontMeasurement $fontMeasurement, array $ $lastLineOffset = $offset; while (count($pendingLines) > 0) { $pendingLine = array_shift($pendingLines); - $words = explode(' ', $pendingLine); + $words = explode(' ', (string) $pendingLine); $availableLineWidth = $availableWidth - $currentLineWidth; $pendingWords = []; diff --git a/src/Frontend/LayoutEngine/Measure/Measurer/GridMeasurer.php b/src/Frontend/LayoutEngine/Measure/Measurer/GridMeasurer.php index 0e64a76a..cdbc90c2 100644 --- a/src/Frontend/LayoutEngine/Measure/Measurer/GridMeasurer.php +++ b/src/Frontend/LayoutEngine/Measure/Measurer/GridMeasurer.php @@ -19,7 +19,7 @@ class GridMeasurer { - private BlockMeasurementVisitor $measurementVisitor; + private readonly BlockMeasurementVisitor $measurementVisitor; public function __construct() { diff --git a/src/Frontend/LayoutEngine/Measure/Measurer/ParagraphMeasurer.php b/src/Frontend/LayoutEngine/Measure/Measurer/ParagraphMeasurer.php index 1457604e..36ad0606 100644 --- a/src/Frontend/LayoutEngine/Measure/Measurer/ParagraphMeasurer.php +++ b/src/Frontend/LayoutEngine/Measure/Measurer/ParagraphMeasurer.php @@ -18,7 +18,7 @@ class ParagraphMeasurer { - private FontRepository $fontRepository; + private readonly FontRepository $fontRepository; public function __construct() { diff --git a/src/Utils/LUDecomposition3By3.php b/src/Utils/LUDecomposition3By3.php index 8782c52b..e795e569 100644 --- a/src/Utils/LUDecomposition3By3.php +++ b/src/Utils/LUDecomposition3By3.php @@ -13,5 +13,5 @@ class LUDecomposition3By3 { - public const DIMENSION = 3; + final public const DIMENSION = 3; }