From 42dd24b17b5053762d1e515810e62c1678cb9c26 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Tue, 8 Mar 2022 21:13:31 +0000 Subject: [PATCH 1/7] CS fixes --- composer.json | 2 +- license.txt | 2 +- src/LayerPacker.php | 8 ++++---- src/OrientatedItem.php | 2 +- src/OrientatedItemFactory.php | 8 ++++---- src/OrientatedItemSorter.php | 2 +- src/PackedBox.php | 2 +- src/PackedBoxList.php | 2 +- src/PackedItem.php | 2 +- src/Packer.php | 10 +++++----- src/VolumePacker.php | 4 ++-- src/WeightRedistributor.php | 14 +++++++------- src/WorkingVolume.php | 2 +- tests/PackedBoxTest.php | 2 +- tests/Test/TestBox.php | 2 +- tests/Test/TestItem.php | 2 +- 16 files changed, 33 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index b19cbf9a..5aa9d1e1 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "behat/behat": "^3.7", - "friendsofphp/php-cs-fixer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.7", "dvdoug/behat-code-coverage": "^5.0.1", "monolog/monolog": "^1.0||^2.0", "phpunit/phpunit": "^7.5.20||^8.5.21||^9.5.8" diff --git a/license.txt b/license.txt index d77c12c9..3f726a24 100644 --- a/license.txt +++ b/license.txt @@ -1,4 +1,4 @@ -Copyright (C) 2012-2021 Doug Wright +Copyright (C) 2012-2022 Doug Wright Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/LayerPacker.php b/src/LayerPacker.php index 75224cd7..1ad62abc 100644 --- a/src/LayerPacker.php +++ b/src/LayerPacker.php @@ -104,7 +104,7 @@ public function packLayer(ItemList &$items, PackedItemList $packedItemList, int while ($items->count() > 0) { $itemToPack = $items->extract(); - //skip items that will never fit e.g. too heavy + // skip items that will never fit e.g. too heavy if (!$this->checkNonDimensionalConstraints($itemToPack, $remainingWeightAllowed, $packedItemList)) { continue; } @@ -119,8 +119,8 @@ public function packLayer(ItemList &$items, PackedItemList $packedItemList, int $rowLength = max($rowLength, $packedItem->getLength()); $prevItem = $orientatedItem; - //Figure out if we can stack items on top of this rather than side by side - //e.g. when we've packed a tall item, and have just put a shorter one next to it. + // Figure out if we can stack items on top of this rather than side by side + // e.g. when we've packed a tall item, and have just put a shorter one next to it. $stackableDepth = ($guidelineLayerDepth ?: $layer->getDepth()) - $packedItem->getDepth(); if ($stackableDepth > 0) { $stackedLayer = $this->packLayer($items, $packedItemList, $x, $y, $z + $packedItem->getDepth(), $x + $packedItem->getWidth(), $y + $packedItem->getLength(), $stackableDepth, $stackableDepth, $considerStability); @@ -148,7 +148,7 @@ public function packLayer(ItemList &$items, PackedItemList $packedItemList, int } if ($x > $startX) { - //Having now placed items, there is space *within the same row* along the length. Pack into that. + // Having now placed items, there is space *within the same row* along the length. Pack into that. $this->logger->debug('No more fit in width wise, packing along remaining length'); $layer->merge($this->packLayer($items, $packedItemList, $x, $y + $rowLength, $z, $widthForLayer, $lengthForLayer - $rowLength, $depthForLayer, $layer->getDepth(), $considerStability)); diff --git a/src/OrientatedItem.php b/src/OrientatedItem.php index ac81cf1a..10f0ebcc 100644 --- a/src/OrientatedItem.php +++ b/src/OrientatedItem.php @@ -141,7 +141,7 @@ public function isSameDimensions(Item $item): bool } #[ReturnTypeWillChange] - public function jsonSerialize()/*: mixed*/ + public function jsonSerialize()/* : mixed */ { return [ 'item' => $this->item, diff --git a/src/OrientatedItemFactory.php b/src/OrientatedItemFactory.php index 6e8869e9..b3028919 100644 --- a/src/OrientatedItemFactory.php +++ b/src/OrientatedItemFactory.php @@ -114,7 +114,7 @@ public function getPossibleOrientations( ): array { $permutations = $this->generatePermutations($item, $prevItem); - //remove any that simply don't fit + // remove any that simply don't fit $orientations = []; foreach ($permutations as $dimensions) { if ($dimensions[0] <= $widthLeft && $dimensions[1] <= $lengthLeft && $dimensions[2] <= $depthLeft) { @@ -213,7 +213,7 @@ static function (OrientatedItem $orientation) { private function generatePermutations(Item $item, ?OrientatedItem $prevItem): array { - //Special case items that are the same as what we just packed - keep orientation + // Special case items that are the same as what we just packed - keep orientation if ($prevItem && $prevItem->isSameDimensions($item)) { return [[$prevItem->getWidth(), $prevItem->getLength(), $prevItem->getDepth()]]; } @@ -223,11 +223,11 @@ private function generatePermutations(Item $item, ?OrientatedItem $prevItem): ar $l = $item->getLength(); $d = $item->getDepth(); - //simple 2D rotation + // simple 2D rotation $permutations[$w . '|' . $l . '|' . $d] = [$w, $l, $d]; $permutations[$l . '|' . $w . '|' . $d] = [$l, $w, $d]; - //add 3D rotation if we're allowed + // add 3D rotation if we're allowed if (!$item->getKeepFlat()) { $permutations[$w . '|' . $d . '|' . $l] = [$w, $d, $l]; $permutations[$l . '|' . $d . '|' . $w] = [$l, $d, $w]; diff --git a/src/OrientatedItemSorter.php b/src/OrientatedItemSorter.php index c458daa4..840da6d4 100644 --- a/src/OrientatedItemSorter.php +++ b/src/OrientatedItemSorter.php @@ -101,7 +101,7 @@ public function __construct(OrientatedItemFactory $factory, bool $singlePassMode public function __invoke(OrientatedItem $a, OrientatedItem $b) { - //Prefer exact fits in width/length/depth order + // Prefer exact fits in width/length/depth order $orientationAWidthLeft = $this->widthLeft - $a->getWidth(); $orientationBWidthLeft = $this->widthLeft - $b->getWidth(); $widthDecider = $this->exactFitDecider($orientationAWidthLeft, $orientationBWidthLeft); diff --git a/src/PackedBox.php b/src/PackedBox.php index 12f8f89b..7d1d40f0 100644 --- a/src/PackedBox.php +++ b/src/PackedBox.php @@ -213,7 +213,7 @@ public function __construct(Box $box, PackedItemList $packedItemList) } #[ReturnTypeWillChange] - public function jsonSerialize()/*: mixed*/ + public function jsonSerialize()/* : mixed */ { return [ 'box' => [ diff --git a/src/PackedBoxList.php b/src/PackedBoxList.php index b1708ed2..feff7cd2 100644 --- a/src/PackedBoxList.php +++ b/src/PackedBoxList.php @@ -143,7 +143,7 @@ public function getVolumeUtilisation(): float } #[ReturnTypeWillChange] - public function jsonSerialize()/*: mixed*/ + public function jsonSerialize()/* : mixed */ { return $this->list; } diff --git a/src/PackedItem.php b/src/PackedItem.php index b04d47b4..d563b4a8 100644 --- a/src/PackedItem.php +++ b/src/PackedItem.php @@ -132,7 +132,7 @@ public function toOrientatedItem(): OrientatedItem } #[ReturnTypeWillChange] - public function jsonSerialize()/*: mixed*/ + public function jsonSerialize()/* : mixed */ { return [ 'x' => $this->x, diff --git a/src/Packer.php b/src/Packer.php index 04e86dab..342aa76e 100644 --- a/src/Packer.php +++ b/src/Packer.php @@ -162,7 +162,7 @@ public function pack(): PackedBoxList { $packedBoxes = $this->doVolumePacking(); - //If we have multiple boxes, try and optimise/even-out weight distribution + // If we have multiple boxes, try and optimise/even-out weight distribution if (!$this->beStrictAboutItemOrdering && $packedBoxes->count() > 1 && $packedBoxes->count() <= $this->maxBoxesToBalanceWeight) { $redistributor = new WeightRedistributor($this->boxes, $this->packedBoxSorter, $this->boxesQtyAvailable); $redistributor->setLogger($this->logger); @@ -183,11 +183,11 @@ public function doVolumePacking(bool $singlePassMode = false, bool $enforceSingl { $packedBoxes = new PackedBoxList(); - //Keep going until everything packed + // Keep going until everything packed while ($this->items->count()) { $packedBoxesIteration = []; - //Loop through boxes starting with smallest, see what happens + // Loop through boxes starting with smallest, see what happens foreach ($this->getBoxList($enforceSingleBox) as $box) { $volumePacker = new VolumePacker($box, $this->items); $volumePacker->setLogger($this->logger); @@ -197,7 +197,7 @@ public function doVolumePacking(bool $singlePassMode = false, bool $enforceSingl if ($packedBox->getItems()->count()) { $packedBoxesIteration[] = $packedBox; - //Have we found a single box that contains everything? + // Have we found a single box that contains everything? if ($packedBox->getItems()->count() === $this->items->count()) { break; } @@ -205,7 +205,7 @@ public function doVolumePacking(bool $singlePassMode = false, bool $enforceSingl } try { - //Find best box of iteration, and remove packed items from unpacked list + // Find best box of iteration, and remove packed items from unpacked list $bestBox = $this->findBestBoxFromIteration($packedBoxesIteration); } catch (NoBoxesAvailableException $e) { if ($enforceSingleBox) { diff --git a/src/VolumePacker.php b/src/VolumePacker.php index 7ff4e7fc..7a660eb1 100644 --- a/src/VolumePacker.php +++ b/src/VolumePacker.php @@ -178,7 +178,7 @@ private function packRotation(int $boxWidth, int $boxLength): PackedBox $layerStartDepth = static::getCurrentPackedDepth($layers); $packedItemList = $this->getPackedItemList($layers); - //do a preliminary layer pack to get the depth used + // do a preliminary layer pack to get the depth used $preliminaryItems = clone $items; $preliminaryLayer = $this->layerPacker->packLayer($preliminaryItems, clone $packedItemList, 0, 0, $layerStartDepth, $boxWidth, $boxLength, $this->box->getInnerDepth() - $layerStartDepth, 0, true); if (count($preliminaryLayer->getItems()) === 0) { @@ -188,7 +188,7 @@ private function packRotation(int $boxWidth, int $boxLength): PackedBox if ($preliminaryLayer->getDepth() === $preliminaryLayer->getItems()[0]->getDepth()) { // preliminary === final $layers[] = $preliminaryLayer; $items = $preliminaryItems; - } else { //redo with now-known-depth so that we can stack to that height from the first item + } else { // redo with now-known-depth so that we can stack to that height from the first item $layers[] = $this->layerPacker->packLayer($items, $packedItemList, 0, 0, $layerStartDepth, $boxWidth, $boxLength, $this->box->getInnerDepth() - $layerStartDepth, $preliminaryLayer->getDepth(), true); } } diff --git a/src/WeightRedistributor.php b/src/WeightRedistributor.php index 5e59ffdd..4e31cfa6 100644 --- a/src/WeightRedistributor.php +++ b/src/WeightRedistributor.php @@ -82,12 +82,12 @@ public function redistributeWeight(PackedBoxList $originalBoxes): PackedBoxList foreach ($boxes as $a => &$boxA) { foreach ($boxes as $b => &$boxB) { if ($b <= $a || $boxA->getWeight() === $boxB->getWeight()) { - continue; //no need to evaluate + continue; // no need to evaluate } $iterationSuccessful = $this->equaliseWeight($boxA, $boxB, $targetWeight); if ($iterationSuccessful) { - $boxes = array_filter($boxes, static function (?PackedBox $box) { //remove any now-empty boxes from the list + $boxes = array_filter($boxes, static function (?PackedBox $box) { // remove any now-empty boxes from the list return $box instanceof PackedBox; }); break 2; @@ -96,7 +96,7 @@ public function redistributeWeight(PackedBoxList $originalBoxes): PackedBoxList } } while ($iterationSuccessful); - //Combine back into a single list + // Combine back into a single list $packedBoxes = new PackedBoxList(); $packedBoxes->insertFromArray($boxes); @@ -130,12 +130,12 @@ private function equaliseWeight(PackedBox &$boxA, PackedBox &$boxB, float $targe $newLighterBoxes = $this->doVolumeRepack(array_merge($underWeightBoxItems, [$overWeightItem]), $underWeightBox->getBox()); if ($newLighterBoxes->count() !== 1) { - continue; //only want to move this item if it still fits in a single box + continue; // only want to move this item if it still fits in a single box } $underWeightBoxItems[] = $overWeightItem; - if (count($overWeightBoxItems) === 1) { //sometimes a repack can be efficient enough to eliminate a box + if (count($overWeightBoxItems) === 1) { // sometimes a repack can be efficient enough to eliminate a box $boxB = $newLighterBoxes->top(); $boxA = null; $this->boxesQtyAvailable[$underWeightBox->getBox()] = $this->boxesQtyAvailable[$underWeightBox->getBox()] - 1; @@ -147,7 +147,7 @@ private function equaliseWeight(PackedBox &$boxA, PackedBox &$boxB, float $targe unset($overWeightBoxItems[$key]); $newHeavierBoxes = $this->doVolumeRepack($overWeightBoxItems, $overWeightBox->getBox()); if (count($newHeavierBoxes) !== 1) { - continue; //this should never happen, if we can pack n+1 into the box, we should be able to pack n + continue; // this should never happen, if we can pack n+1 into the box, we should be able to pack n } $this->boxesQtyAvailable[$overWeightBox->getBox()] = $this->boxesQtyAvailable[$overWeightBox->getBox()] + 1; @@ -201,6 +201,6 @@ private static function wouldRepackActuallyHelp(array $overWeightBoxItems, Item private static function calculateVariance(int $boxAWeight, int $boxBWeight) { - return ($boxAWeight - (($boxAWeight + $boxBWeight) / 2)) ** 2; //don't need to calculate B and ÷ 2, for a 2-item population the difference from mean is the same for each box + return ($boxAWeight - (($boxAWeight + $boxBWeight) / 2)) ** 2; // don't need to calculate B and ÷ 2, for a 2-item population the difference from mean is the same for each box } } diff --git a/src/WorkingVolume.php b/src/WorkingVolume.php index 7d9d0be2..7b902016 100644 --- a/src/WorkingVolume.php +++ b/src/WorkingVolume.php @@ -98,7 +98,7 @@ public function getMaxWeight(): int } #[ReturnTypeWillChange] - public function jsonSerialize()/*: mixed*/ + public function jsonSerialize()/* : mixed */ { return [ 'reference' => $this->getReference(), diff --git a/tests/PackedBoxTest.php b/tests/PackedBoxTest.php index 0f194178..d4fea995 100644 --- a/tests/PackedBoxTest.php +++ b/tests/PackedBoxTest.php @@ -75,7 +75,7 @@ public function testWeightCalcCaching(): void self::assertEquals(10, $packedBox->getItemWeight()); - //inspect cache, then poke at the value and see if it's returned correctly + // inspect cache, then poke at the value and see if it's returned correctly $cachedValue = new ReflectionProperty($packedBox, 'itemWeight'); $cachedValue->setAccessible(true); self::assertEquals(10, $cachedValue->getValue($packedBox)); diff --git a/tests/Test/TestBox.php b/tests/Test/TestBox.php index cb49aa14..51c75a58 100644 --- a/tests/Test/TestBox.php +++ b/tests/Test/TestBox.php @@ -130,7 +130,7 @@ public function getMaxWeight(): int } #[ReturnTypeWillChange] - public function jsonSerialize()/*: mixed*/ + public function jsonSerialize()/* : mixed */ { return [ 'reference' => $this->reference, diff --git a/tests/Test/TestItem.php b/tests/Test/TestItem.php index 67d224f6..f684f968 100644 --- a/tests/Test/TestItem.php +++ b/tests/Test/TestItem.php @@ -115,7 +115,7 @@ public function getKeepFlat(): bool } #[ReturnTypeWillChange] - public function jsonSerialize()/*: mixed*/ + public function jsonSerialize()/* : mixed */ { return [ 'description' => $this->description, From af5bc60be43c47338eaf3106d059f2ce1d1d2569 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sun, 20 Mar 2022 18:19:29 +0000 Subject: [PATCH 2/7] Fix missing logger pass-through --- src/WeightRedistributor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WeightRedistributor.php b/src/WeightRedistributor.php index 4e31cfa6..b76f46a8 100644 --- a/src/WeightRedistributor.php +++ b/src/WeightRedistributor.php @@ -169,6 +169,7 @@ private function equaliseWeight(PackedBox &$boxA, PackedBox &$boxB, float $targe private function doVolumeRepack(iterable $items, Box $currentBox): PackedBoxList { $packer = new Packer(); + $packer->setLogger($this->logger); $packer->setBoxes($this->boxes); // use the full set of boxes to allow smaller/larger for full efficiency foreach ($this->boxes as $box) { $packer->setBoxQuantity($box, $this->boxesQtyAvailable[$box]); From 13079d45c3bd9f4ebee63f1eb99645e339ab4182 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sat, 3 Sep 2022 17:04:19 +0100 Subject: [PATCH 3/7] Test on PHP8.2 --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71e8ccdf..8dc1586a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: fail-fast: false matrix: php-version: + - "8.2" - "8.1" - "8.0" - "7.4" @@ -139,6 +140,7 @@ jobs: fail-fast: false matrix: php-version: + - "8.2" - "8.1" - "8.0" - "7.4" From eca8d7b80e533ac904d06a74546116089dec9960 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sat, 10 Sep 2022 20:37:41 +0100 Subject: [PATCH 4/7] 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 From 43a42412932404c2e3b2d15b85647486c3367464 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sat, 10 Sep 2022 20:37:50 +0100 Subject: [PATCH 5/7] Prep release --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cce6e6f5..3eb5aaee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog -## [3.x - Unreleased] - 2021-xx-xx +## [3.x - Unreleased] - 2022-xx-xx + +## [3.10.0] - 2022-09-10 ### Added - Added `ItemSorter`, `BoxSorter` and `PackedBoxSorter` to allow calling applications to have better control over sorting decisions @@ -485,8 +487,9 @@ Initial release - Experimental code to get a feel for how calculations can best be implemented - Only works if all items fit into a single box (so not production ready at all) -[3.x - Unreleased]: https://github.com/dvdoug/BoxPacker/compare/3.9.4...3.x +[3.x - Unreleased]: https://github.com/dvdoug/BoxPacker/compare/3.10.0...3.x +[3.10.0]: https://github.com/dvdoug/BoxPacker/compare/3.9.4...3.10.0 [3.9.4]: https://github.com/dvdoug/BoxPacker/compare/3.9.3...3.9.4 [3.9.3]: https://github.com/dvdoug/BoxPacker/compare/3.9.2...3.9.3 [3.9.2]: https://github.com/dvdoug/BoxPacker/compare/3.9.1...3.9.2 From 548f96ff37eba0e44607a956439906ae425ac31d Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Mon, 5 Dec 2022 19:33:15 +0000 Subject: [PATCH 6/7] Backport #356 to 3.x --- CHANGELOG.md | 5 +++++ src/PackedBox.php | 28 ++++++++++++++++++++++------ src/PackedItem.php | 31 ++++++++++++++++++++++++------- tests/PackedBoxListTest.php | 2 +- tests/PackedBoxTest.php | 2 +- tests/PackedItemTest.php | 2 +- 6 files changed, 54 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eb5aaee..652b995a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [3.x - Unreleased] - 2022-xx-xx +### Changed +- Calling `json_encode()` on a `PackedBox` or `PackedItem` now additionally serialises the entire underlying + `Box`/`Item` where those objects also implement `JsonSerializable`. Previously the serialisation only included the + key values from the `Box`/`Item` interfaces themselves. + ## [3.10.0] - 2022-09-10 ### Added - Added `ItemSorter`, `BoxSorter` and `PackedBoxSorter` to allow calling applications to have better control over diff --git a/src/PackedBox.php b/src/PackedBox.php index edf1d7be..03f53363 100644 --- a/src/PackedBox.php +++ b/src/PackedBox.php @@ -14,6 +14,8 @@ use function iterator_to_array; use function max; use function round; +use function array_merge; +use function is_array; /** * A "box" with items. @@ -216,13 +218,27 @@ public function __construct(Box $box, PackedItemList $packedItemList) #[ReturnTypeWillChange] public function jsonSerialize()/* : mixed */ { + $userValues = []; + + if ($this->box instanceof JsonSerializable) { + $userSerialisation = $this->box->jsonSerialize(); + if (is_array($userSerialisation)) { + $userValues = $userSerialisation; + } else { + $userValues = ['extra' => $userSerialisation]; + } + } + return [ - 'box' => [ - 'reference' => $this->box->getReference(), - 'innerWidth' => $this->box->getInnerWidth(), - 'innerLength' => $this->box->getInnerLength(), - 'innerDepth' => $this->box->getInnerDepth(), - ], + 'box' => array_merge( + $userValues, + [ + 'reference' => $this->box->getReference(), + 'innerWidth' => $this->box->getInnerWidth(), + 'innerLength' => $this->box->getInnerLength(), + 'innerDepth' => $this->box->getInnerDepth(), + ] + ), 'items' => iterator_to_array($this->items), ]; } diff --git a/src/PackedItem.php b/src/PackedItem.php index 3adde26d..b915145b 100644 --- a/src/PackedItem.php +++ b/src/PackedItem.php @@ -11,6 +11,9 @@ use JsonSerializable; use ReturnTypeWillChange; +use function array_merge; +use function is_array; + /** * A packed item. * @@ -131,6 +134,17 @@ public function toOrientatedItem(): OrientatedItem #[ReturnTypeWillChange] public function jsonSerialize()/* : mixed */ { + $userValues = []; + + if ($this->item instanceof JsonSerializable) { + $userSerialisation = $this->item->jsonSerialize(); + if (is_array($userSerialisation)) { + $userValues = $userSerialisation; + } else { + $userValues = ['extra' => $userSerialisation]; + } + } + return [ 'x' => $this->x, 'y' => $this->y, @@ -138,13 +152,16 @@ public function jsonSerialize()/* : mixed */ 'width' => $this->width, 'length' => $this->length, 'depth' => $this->depth, - 'item' => [ - 'description' => $this->item->getDescription(), - 'width' => $this->item->getWidth(), - 'length' => $this->item->getLength(), - 'depth' => $this->item->getDepth(), - 'keepFlat' => $this->item->getKeepFlat(), - ], + 'item' => array_merge( + $userValues, + [ + 'description' => $this->item->getDescription(), + 'width' => $this->item->getWidth(), + 'length' => $this->item->getLength(), + 'depth' => $this->item->getDepth(), + 'keepFlat' => $this->item->getKeepFlat(), + ] + ), ]; } } diff --git a/tests/PackedBoxListTest.php b/tests/PackedBoxListTest.php index d228203b..3e43cfd2 100644 --- a/tests/PackedBoxListTest.php +++ b/tests/PackedBoxListTest.php @@ -190,6 +190,6 @@ public function testJsonSerialize(): void $packedBoxList = new PackedBoxList(); $packedBoxList->insert($packedBox); - self::assertJsonStringEqualsJsonString('[{"box":{"reference":"Box","innerWidth":10,"innerLength":10,"innerDepth":20},"items":[{"x":0,"y":0,"z":0,"width":4,"length":10,"depth":10,"item":{"description":"Item","width":4,"length":10,"depth":10,"keepFlat":true}}]}]', json_encode($packedBoxList)); + self::assertJsonStringEqualsJsonString('[{"box":{"reference":"Box","innerWidth":10,"innerLength":10,"innerDepth":20,"maxWeight":10,"emptyWeight":10},"items":[{"x":0,"y":0,"z":0,"width":4,"length":10,"depth":10,"item":{"description":"Item","width":4,"length":10,"depth":10,"keepFlat":true,"weight":10}}]}]', json_encode($packedBoxList)); } } diff --git a/tests/PackedBoxTest.php b/tests/PackedBoxTest.php index 2e4a7c21..5278bf7d 100644 --- a/tests/PackedBoxTest.php +++ b/tests/PackedBoxTest.php @@ -98,6 +98,6 @@ public function testJsonSerialize(): void $packedBox = new PackedBox($box, $boxItems); - self::assertJsonStringEqualsJsonString('{"box":{"reference":"Box","innerWidth":10,"innerLength":10,"innerDepth":20},"items":[{"x":0,"y":0,"z":0,"width":4,"length":10,"depth":10,"item":{"description":"Item","width":4,"length":10,"depth":10,"keepFlat":true}}]}', json_encode($packedBox)); + self::assertJsonStringEqualsJsonString('{"box":{"reference":"Box","innerWidth":10,"innerLength":10,"innerDepth":20,"maxWeight":10,"emptyWeight":10},"items":[{"x":0,"y":0,"z":0,"width":4,"length":10,"depth":10,"item":{"description":"Item","width":4,"length":10,"depth":10,"keepFlat":true,"weight":10}}]}', json_encode($packedBox)); } } diff --git a/tests/PackedItemTest.php b/tests/PackedItemTest.php index a7fba622..e581cc77 100644 --- a/tests/PackedItemTest.php +++ b/tests/PackedItemTest.php @@ -33,6 +33,6 @@ public function testVolumeCalculation(): void public function testJsonSerialize(): void { $packedItem = new PackedItem(new TestItem('Item', 1, 2, 3, 10, false), 100, 20, 300, 3, 5, 7); - self::assertJsonStringEqualsJsonString('{"x":100,"y":20,"z":300,"width":3,"length":5,"depth":7,"item":{"description":"Item","width":1,"length":2,"depth":3,"keepFlat":false}}', json_encode($packedItem)); + self::assertJsonStringEqualsJsonString('{"x":100,"y":20,"z":300,"width":3,"length":5,"depth":7,"item":{"description":"Item","width":1,"length":2,"depth":3,"keepFlat":false, "weight":10}}', json_encode($packedItem)); } } From 0f93e476ad19cb01c7d89414df66df538362f8c2 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sat, 4 Feb 2023 17:55:13 +0000 Subject: [PATCH 7/7] Prep release --- CHANGELOG.md | 6 ++++-- docs/conf.py | 2 +- license.txt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 652b995a..eb9dd5ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Changelog -## [3.x - Unreleased] - 2022-xx-xx +## [3.x - Unreleased] - 2023-xx-xx +## [3.11.0] - 2023-02-04 ### Changed - Calling `json_encode()` on a `PackedBox` or `PackedItem` now additionally serialises the entire underlying `Box`/`Item` where those objects also implement `JsonSerializable`. Previously the serialisation only included the @@ -492,8 +493,9 @@ Initial release - Experimental code to get a feel for how calculations can best be implemented - Only works if all items fit into a single box (so not production ready at all) -[3.x - Unreleased]: https://github.com/dvdoug/BoxPacker/compare/3.10.0...3.x +[3.x - Unreleased]: https://github.com/dvdoug/BoxPacker/compare/3.11.0...3.x +[3.11.0]: https://github.com/dvdoug/BoxPacker/compare/3.10.0...3.11.0 [3.10.0]: https://github.com/dvdoug/BoxPacker/compare/3.9.4...3.10.0 [3.9.4]: https://github.com/dvdoug/BoxPacker/compare/3.9.3...3.9.4 [3.9.3]: https://github.com/dvdoug/BoxPacker/compare/3.9.2...3.9.3 diff --git a/docs/conf.py b/docs/conf.py index 8faf1ac9..8f43f5c8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,7 +46,7 @@ # General information about the project. project = u'BoxPacker' -copyright = u'2012-2021, Doug Wright' +copyright = u'2012-2023, Doug Wright' author = u'Doug Wright' # The version info for the project you're documenting, acts as replacement for diff --git a/license.txt b/license.txt index 3f726a24..e43ec5e2 100644 --- a/license.txt +++ b/license.txt @@ -1,4 +1,4 @@ -Copyright (C) 2012-2022 Doug Wright +Copyright (C) 2012-2023 Doug Wright Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal