From eca8d7b80e533ac904d06a74546116089dec9960 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sat, 10 Sep 2022 20:37:41 +0100 Subject: [PATCH] CS Fix --- .php-cs-fixer.dist.php | 3 +++ .../bootstrap/InfalliblePackerContext.php | 8 +++++-- features/bootstrap/PackerContext.php | 24 ++++++++++++++----- src/BoxList.php | 3 +-- src/ItemList.php | 16 ++++++------- src/LayerPacker.php | 7 +++--- src/NoBoxesAvailableException.php | 4 +++- src/OrientatedItem.php | 5 ++-- src/OrientatedItemFactory.php | 9 ++++--- src/OrientatedItemSorter.php | 6 +++-- src/PackedBox.php | 5 ++-- src/PackedBoxList.php | 7 +++--- src/PackedItem.php | 3 --- src/PackedItemList.php | 5 ++-- src/PackedLayer.php | 1 + src/Packer.php | 8 ++++--- src/VolumePacker.php | 7 +++--- src/WeightRedistributor.php | 11 +++++---- tests/BoxListTest.php | 3 ++- tests/EfficiencyTest.php | 3 ++- tests/InfalliblePackerTest.php | 3 ++- tests/ItemListTest.php | 3 ++- tests/OrientatedItemTest.php | 3 ++- tests/PackedBoxListTest.php | 3 ++- tests/PackedBoxTest.php | 3 ++- tests/PackedItemTest.php | 3 ++- tests/PackerTest.php | 4 +++- tests/PublishedTestCasesTest.php | 3 ++- .../ConstrainedPlacementByCountTestItem.php | 5 ++-- ...ConstrainedPlacementNoStackingTestItem.php | 3 ++- tests/Test/ConstrainedTestItem.php | 5 ++-- tests/VolumePackerTest.php | 3 ++- tests/WeightRedistributorTest.php | 3 ++- tests/WorkingVolumeTest.php | 3 ++- 34 files changed, 117 insertions(+), 68 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 2b35e905..9daa45ee 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -29,6 +29,9 @@ 'separate' => 'none', 'header' => "Box packing (3D bin packing, knapsack problem).\n\n@author Doug Wright", ], + 'phpdoc_line_span' => true, + 'phpdoc_to_comment' => false, + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'none'], ] ) ->setRiskyAllowed(true) diff --git a/features/bootstrap/InfalliblePackerContext.php b/features/bootstrap/InfalliblePackerContext.php index dd1d05a7..0b8a7361 100644 --- a/features/bootstrap/InfalliblePackerContext.php +++ b/features/bootstrap/InfalliblePackerContext.php @@ -16,10 +16,14 @@ */ class InfalliblePackerContext extends PackerContext { - /** @var string */ + /** + * @var string + */ protected $packerClass = InfalliblePacker::class; - /** @var ItemList */ + /** + * @var ItemList + */ protected $unpackedItemList; /** diff --git a/features/bootstrap/PackerContext.php b/features/bootstrap/PackerContext.php index 2f6290d9..051cd099 100644 --- a/features/bootstrap/PackerContext.php +++ b/features/bootstrap/PackerContext.php @@ -26,22 +26,34 @@ */ class PackerContext implements Context { - /** @var Box */ + /** + * @var Box + */ protected $box; - /** @var BoxList */ + /** + * @var BoxList + */ protected $boxList; - /** @var ItemList */ + /** + * @var ItemList + */ protected $itemList; - /** @var PackedBox */ + /** + * @var PackedBox + */ protected $packedBox; - /** @var PackedBoxList */ + /** + * @var PackedBoxList + */ protected $packedBoxList; - /** @var string */ + /** + * @var string + */ protected $packerClass = Packer::class; /** diff --git a/src/BoxList.php b/src/BoxList.php index af25d339..27cd52af 100644 --- a/src/BoxList.php +++ b/src/BoxList.php @@ -11,6 +11,7 @@ use ArrayIterator; use IteratorAggregate; use Traversable; + use function usort; /** @@ -48,8 +49,6 @@ public function __construct(?BoxSorter $sorter = null) * Do a bulk create. * * @param Box[] $boxes - * - * @return BoxList */ public static function fromArray(array $boxes, bool $preSorted = false): self { diff --git a/src/ItemList.php b/src/ItemList.php index 34a960bd..66c56fc3 100644 --- a/src/ItemList.php +++ b/src/ItemList.php @@ -8,22 +8,24 @@ namespace DVDoug\BoxPacker; +use ArrayIterator; +use Countable; +use IteratorAggregate; +use Traversable; + use function array_key_last; use function array_pop; use function array_reverse; use function array_slice; -use ArrayIterator; use function count; -use Countable; use function current; use function end; -use IteratorAggregate; use function key; -use const PHP_VERSION_ID; use function prev; -use Traversable; use function usort; +use const PHP_VERSION_ID; + /** * List of items to be packed, ordered by volume. * @@ -65,8 +67,7 @@ public function __construct(?ItemSorter $sorter = null) /** * Do a bulk create. * - * @param Item[] $items - * @return ItemList + * @param Item[] $items */ public static function fromArray(array $items, bool $preSorted = false): self { @@ -155,7 +156,6 @@ public function top(): Item /** * @internal - * @return ItemList */ public function topN(int $n): self { diff --git a/src/LayerPacker.php b/src/LayerPacker.php index 1ad62abc..9c823f3f 100644 --- a/src/LayerPacker.php +++ b/src/LayerPacker.php @@ -8,12 +8,13 @@ namespace DVDoug\BoxPacker; -use function array_merge; -use function iterator_to_array; -use function max; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; + +use function array_merge; +use function iterator_to_array; +use function max; use function sort; /** diff --git a/src/NoBoxesAvailableException.php b/src/NoBoxesAvailableException.php index ce178068..a8fb56a6 100644 --- a/src/NoBoxesAvailableException.php +++ b/src/NoBoxesAvailableException.php @@ -17,7 +17,9 @@ */ class NoBoxesAvailableException extends RuntimeException { - /** @var Item */ + /** + * @var Item + */ public $item; /** diff --git a/src/OrientatedItem.php b/src/OrientatedItem.php index 10f0ebcc..f3975ab7 100644 --- a/src/OrientatedItem.php +++ b/src/OrientatedItem.php @@ -8,10 +8,11 @@ namespace DVDoug\BoxPacker; -use function atan; use JsonSerializable; -use function min; use ReturnTypeWillChange; + +use function atan; +use function min; use function sort; /** diff --git a/src/OrientatedItemFactory.php b/src/OrientatedItemFactory.php index b3028919..74af9c3a 100644 --- a/src/OrientatedItemFactory.php +++ b/src/OrientatedItemFactory.php @@ -8,11 +8,12 @@ namespace DVDoug\BoxPacker; -use function array_filter; -use function count; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\NullLogger; + +use function array_filter; +use function count; use function usort; /** @@ -25,7 +26,9 @@ class OrientatedItemFactory implements LoggerAwareInterface { use LoggerAwareTrait; - /** @var Box */ + /** + * @var Box + */ protected $box; /** diff --git a/src/OrientatedItemSorter.php b/src/OrientatedItemSorter.php index 840da6d4..ba76f449 100644 --- a/src/OrientatedItemSorter.php +++ b/src/OrientatedItemSorter.php @@ -8,11 +8,13 @@ namespace DVDoug\BoxPacker; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; + use function max; use function min; + use const PHP_INT_MAX; -use Psr\Log\LoggerAwareInterface; -use Psr\Log\LoggerAwareTrait; /** * Figure out best choice of orientations for an item and a given context. diff --git a/src/PackedBox.php b/src/PackedBox.php index 7d1d40f0..edf1d7be 100644 --- a/src/PackedBox.php +++ b/src/PackedBox.php @@ -8,10 +8,11 @@ namespace DVDoug\BoxPacker; -use function iterator_to_array; use JsonSerializable; -use function max; use ReturnTypeWillChange; + +use function iterator_to_array; +use function max; use function round; /** diff --git a/src/PackedBoxList.php b/src/PackedBoxList.php index feff7cd2..69c6f78d 100644 --- a/src/PackedBoxList.php +++ b/src/PackedBoxList.php @@ -9,15 +9,16 @@ namespace DVDoug\BoxPacker; use ArrayIterator; -use function count; use Countable; use IteratorAggregate; use JsonSerializable; -use function reset; use ReturnTypeWillChange; -use function round; use Traversable; +use function count; +use function reset; +use function round; + /** * List of packed boxes. * diff --git a/src/PackedItem.php b/src/PackedItem.php index d563b4a8..3adde26d 100644 --- a/src/PackedItem.php +++ b/src/PackedItem.php @@ -107,9 +107,6 @@ public function getVolume(): int return $this->width * $this->length * $this->depth; } - /** - * @return PackedItem - */ public static function fromOrientatedItem(OrientatedItem $orientatedItem, int $x, int $y, int $z): self { return new static( diff --git a/src/PackedItemList.php b/src/PackedItemList.php index f161b7a1..2ca2adbe 100644 --- a/src/PackedItemList.php +++ b/src/PackedItemList.php @@ -8,12 +8,13 @@ namespace DVDoug\BoxPacker; -use function array_map; use ArrayIterator; -use function count; use Countable; use IteratorAggregate; use Traversable; + +use function array_map; +use function count; use function usort; /** diff --git a/src/PackedLayer.php b/src/PackedLayer.php index bfb50634..b07afc5e 100644 --- a/src/PackedLayer.php +++ b/src/PackedLayer.php @@ -10,6 +10,7 @@ use function max; use function min; + use const PHP_INT_MAX; /** diff --git a/src/Packer.php b/src/Packer.php index 342aa76e..9f3fc248 100644 --- a/src/Packer.php +++ b/src/Packer.php @@ -8,16 +8,18 @@ namespace DVDoug\BoxPacker; -use function array_merge; -use function count; -use const PHP_INT_MAX; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\LogLevel; use Psr\Log\NullLogger; use SplObjectStorage; + +use function array_merge; +use function count; use function usort; +use const PHP_INT_MAX; + /** * Actual packer. * diff --git a/src/VolumePacker.php b/src/VolumePacker.php index 7a660eb1..7e24c6c7 100644 --- a/src/VolumePacker.php +++ b/src/VolumePacker.php @@ -8,12 +8,13 @@ namespace DVDoug\BoxPacker; -use function array_map; -use function count; -use function max; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; + +use function array_map; +use function count; +use function max; use function reset; use function usort; diff --git a/src/WeightRedistributor.php b/src/WeightRedistributor.php index b76f46a8..87e43aa9 100644 --- a/src/WeightRedistributor.php +++ b/src/WeightRedistributor.php @@ -8,17 +8,18 @@ namespace DVDoug\BoxPacker; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; +use Psr\Log\LogLevel; +use Psr\Log\NullLogger; +use SplObjectStorage; + use function array_filter; use function array_map; use function array_merge; use function array_sum; use function count; use function iterator_to_array; -use Psr\Log\LoggerAwareInterface; -use Psr\Log\LoggerAwareTrait; -use Psr\Log\LogLevel; -use Psr\Log\NullLogger; -use SplObjectStorage; use function usort; /** diff --git a/tests/BoxListTest.php b/tests/BoxListTest.php index 64bfeff3..9abb2feb 100644 --- a/tests/BoxListTest.php +++ b/tests/BoxListTest.php @@ -9,9 +9,10 @@ namespace DVDoug\BoxPacker; use DVDoug\BoxPacker\Test\TestBox; -use function iterator_to_array; use PHPUnit\Framework\TestCase; +use function iterator_to_array; + /** * @covers \DVDoug\BoxPacker\BoxList */ diff --git a/tests/EfficiencyTest.php b/tests/EfficiencyTest.php index aaa2e135..83dd7873 100644 --- a/tests/EfficiencyTest.php +++ b/tests/EfficiencyTest.php @@ -10,10 +10,11 @@ use DVDoug\BoxPacker\Test\TestBox; use DVDoug\BoxPacker\Test\TestItem; +use PHPUnit\Framework\TestCase; + use function fclose; use function fgetcsv; use function fopen; -use PHPUnit\Framework\TestCase; /** * @coversNothing diff --git a/tests/InfalliblePackerTest.php b/tests/InfalliblePackerTest.php index b605719b..1a6d3493 100644 --- a/tests/InfalliblePackerTest.php +++ b/tests/InfalliblePackerTest.php @@ -11,9 +11,10 @@ use DVDoug\BoxPacker\Test\LimitedSupplyTestBox; use DVDoug\BoxPacker\Test\TestBox; use DVDoug\BoxPacker\Test\TestItem; -use function iterator_to_array; use PHPUnit\Framework\TestCase; +use function iterator_to_array; + class InfalliblePackerTest extends TestCase { public function testTooLargeItemsHandled(): void diff --git a/tests/ItemListTest.php b/tests/ItemListTest.php index 3bc0c53c..450e701b 100644 --- a/tests/ItemListTest.php +++ b/tests/ItemListTest.php @@ -9,9 +9,10 @@ namespace DVDoug\BoxPacker; use DVDoug\BoxPacker\Test\TestItem; -use function iterator_to_array; use PHPUnit\Framework\TestCase; +use function iterator_to_array; + /** * @covers \DVDoug\BoxPacker\ItemList */ diff --git a/tests/OrientatedItemTest.php b/tests/OrientatedItemTest.php index e482814f..9da2ea68 100644 --- a/tests/OrientatedItemTest.php +++ b/tests/OrientatedItemTest.php @@ -9,9 +9,10 @@ namespace DVDoug\BoxPacker; use DVDoug\BoxPacker\Test\TestItem; +use PHPUnit\Framework\TestCase; + use function json_decode; use function json_encode; -use PHPUnit\Framework\TestCase; /** * @covers \DVDoug\BoxPacker\OrientatedItem diff --git a/tests/PackedBoxListTest.php b/tests/PackedBoxListTest.php index d7a444db..d228203b 100644 --- a/tests/PackedBoxListTest.php +++ b/tests/PackedBoxListTest.php @@ -10,9 +10,10 @@ use DVDoug\BoxPacker\Test\TestBox; use DVDoug\BoxPacker\Test\TestItem; -use function json_encode; use PHPUnit\Framework\TestCase; +use function json_encode; + /** * @covers \DVDoug\BoxPacker\PackedBoxList */ diff --git a/tests/PackedBoxTest.php b/tests/PackedBoxTest.php index d4fea995..2e4a7c21 100644 --- a/tests/PackedBoxTest.php +++ b/tests/PackedBoxTest.php @@ -10,10 +10,11 @@ use DVDoug\BoxPacker\Test\TestBox; use DVDoug\BoxPacker\Test\TestItem; -use function json_encode; use PHPUnit\Framework\TestCase; use ReflectionProperty; +use function json_encode; + /** * @covers \DVDoug\BoxPacker\PackedBox */ diff --git a/tests/PackedItemTest.php b/tests/PackedItemTest.php index 6e0ae2f7..a7fba622 100644 --- a/tests/PackedItemTest.php +++ b/tests/PackedItemTest.php @@ -9,9 +9,10 @@ namespace DVDoug\BoxPacker; use DVDoug\BoxPacker\Test\TestItem; -use function json_encode; use PHPUnit\Framework\TestCase; +use function json_encode; + /** * @covers \DVDoug\BoxPacker\PackedItem */ diff --git a/tests/PackerTest.php b/tests/PackerTest.php index b72f9c70..e4e1958d 100644 --- a/tests/PackerTest.php +++ b/tests/PackerTest.php @@ -13,9 +13,11 @@ use DVDoug\BoxPacker\Test\PackedBoxByReferenceSorter; use DVDoug\BoxPacker\Test\TestBox; use DVDoug\BoxPacker\Test\TestItem; +use PHPUnit\Framework\TestCase; + use function iterator_to_array; + use const PHP_INT_MAX; -use PHPUnit\Framework\TestCase; class PackerTest extends TestCase { diff --git a/tests/PublishedTestCasesTest.php b/tests/PublishedTestCasesTest.php index 966eae25..6aafb275 100644 --- a/tests/PublishedTestCasesTest.php +++ b/tests/PublishedTestCasesTest.php @@ -10,6 +10,8 @@ use DVDoug\BoxPacker\Test\TestBox; use DVDoug\BoxPacker\Test\THPackTestItem; +use PHPUnit\Framework\TestCase; + use function explode; use function fclose; use function feof; @@ -18,7 +20,6 @@ use function fopen; use function ini_set; use function is_array; -use PHPUnit\Framework\TestCase; use function trim; /* diff --git a/tests/Test/ConstrainedPlacementByCountTestItem.php b/tests/Test/ConstrainedPlacementByCountTestItem.php index 06386580..c7d033b5 100644 --- a/tests/Test/ConstrainedPlacementByCountTestItem.php +++ b/tests/Test/ConstrainedPlacementByCountTestItem.php @@ -8,12 +8,13 @@ namespace DVDoug\BoxPacker\Test; -use function array_filter; -use function count; use DVDoug\BoxPacker\Box; use DVDoug\BoxPacker\ConstrainedPlacementItem; use DVDoug\BoxPacker\PackedItem; use DVDoug\BoxPacker\PackedItemList; + +use function array_filter; +use function count; use function iterator_to_array; class ConstrainedPlacementByCountTestItem extends TestItem implements ConstrainedPlacementItem diff --git a/tests/Test/ConstrainedPlacementNoStackingTestItem.php b/tests/Test/ConstrainedPlacementNoStackingTestItem.php index 3e36a1b1..55b125da 100644 --- a/tests/Test/ConstrainedPlacementNoStackingTestItem.php +++ b/tests/Test/ConstrainedPlacementNoStackingTestItem.php @@ -8,11 +8,12 @@ namespace DVDoug\BoxPacker\Test; -use function array_filter; use DVDoug\BoxPacker\Box; use DVDoug\BoxPacker\ConstrainedPlacementItem; use DVDoug\BoxPacker\PackedItem; use DVDoug\BoxPacker\PackedItemList; + +use function array_filter; use function iterator_to_array; class ConstrainedPlacementNoStackingTestItem extends TestItem implements ConstrainedPlacementItem diff --git a/tests/Test/ConstrainedTestItem.php b/tests/Test/ConstrainedTestItem.php index 05076781..588fadbd 100644 --- a/tests/Test/ConstrainedTestItem.php +++ b/tests/Test/ConstrainedTestItem.php @@ -8,12 +8,13 @@ namespace DVDoug\BoxPacker\Test; -use function array_filter; -use function count; use DVDoug\BoxPacker\Box; use DVDoug\BoxPacker\ConstrainedItem; use DVDoug\BoxPacker\PackedItem; use DVDoug\BoxPacker\PackedItemList; + +use function array_filter; +use function count; use function iterator_to_array; class ConstrainedTestItem extends TestItem implements ConstrainedItem diff --git a/tests/VolumePackerTest.php b/tests/VolumePackerTest.php index f84691fa..9b4b8850 100644 --- a/tests/VolumePackerTest.php +++ b/tests/VolumePackerTest.php @@ -8,7 +8,6 @@ namespace DVDoug\BoxPacker; -use function array_fill; use DVDoug\BoxPacker\Test\ConstrainedPlacementByCountTestItem; use DVDoug\BoxPacker\Test\ConstrainedPlacementNoStackingTestItem; use DVDoug\BoxPacker\Test\ConstrainedTestItem; @@ -16,6 +15,8 @@ use DVDoug\BoxPacker\Test\TestItem; use PHPUnit\Framework\TestCase; +use function array_fill; + class VolumePackerTest extends TestCase { /** diff --git a/tests/WeightRedistributorTest.php b/tests/WeightRedistributorTest.php index ff12b8fe..e97f3a0a 100644 --- a/tests/WeightRedistributorTest.php +++ b/tests/WeightRedistributorTest.php @@ -11,9 +11,10 @@ use DVDoug\BoxPacker\Test\ConstrainedPlacementNoStackingTestItem; use DVDoug\BoxPacker\Test\TestBox; use DVDoug\BoxPacker\Test\TestItem; -use function iterator_to_array; use PHPUnit\Framework\TestCase; +use function iterator_to_array; + /** * @covers \DVDoug\BoxPacker\WeightRedistributor */ diff --git a/tests/WorkingVolumeTest.php b/tests/WorkingVolumeTest.php index c3ab27b1..3ec07e42 100644 --- a/tests/WorkingVolumeTest.php +++ b/tests/WorkingVolumeTest.php @@ -8,9 +8,10 @@ namespace DVDoug\BoxPacker; +use PHPUnit\Framework\TestCase; + use function json_decode; use function json_encode; -use PHPUnit\Framework\TestCase; /** * @covers \DVDoug\BoxPacker\WorkingVolume