Skip to content

Commit

Permalink
CS Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Sep 10, 2022
1 parent 13079d4 commit eca8d7b
Show file tree
Hide file tree
Showing 34 changed files with 117 additions and 68 deletions.
3 changes: 3 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions features/bootstrap/InfalliblePackerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
*/
class InfalliblePackerContext extends PackerContext
{
/** @var string */
/**
* @var string
*/
protected $packerClass = InfalliblePacker::class;

/** @var ItemList */
/**
* @var ItemList
*/
protected $unpackedItemList;

/**
Expand Down
24 changes: 18 additions & 6 deletions features/bootstrap/PackerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/BoxList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use ArrayIterator;
use IteratorAggregate;
use Traversable;

use function usort;

/**
Expand Down Expand Up @@ -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
{
Expand Down
16 changes: 8 additions & 8 deletions src/ItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -155,7 +156,6 @@ public function top(): Item

/**
* @internal
* @return ItemList
*/
public function topN(int $n): self
{
Expand Down
7 changes: 4 additions & 3 deletions src/LayerPacker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
4 changes: 3 additions & 1 deletion src/NoBoxesAvailableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
*/
class NoBoxesAvailableException extends RuntimeException
{
/** @var Item */
/**
* @var Item
*/
public $item;

/**
Expand Down
5 changes: 3 additions & 2 deletions src/OrientatedItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
9 changes: 6 additions & 3 deletions src/OrientatedItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -25,7 +26,9 @@ class OrientatedItemFactory implements LoggerAwareInterface
{
use LoggerAwareTrait;

/** @var Box */
/**
* @var Box
*/
protected $box;

/**
Expand Down
6 changes: 4 additions & 2 deletions src/OrientatedItemSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/PackedBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
7 changes: 4 additions & 3 deletions src/PackedBoxList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
3 changes: 0 additions & 3 deletions src/PackedItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions src/PackedItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
1 change: 1 addition & 0 deletions src/PackedLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use function max;
use function min;

use const PHP_INT_MAX;

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Packer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
7 changes: 4 additions & 3 deletions src/VolumePacker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 6 additions & 5 deletions src/WeightRedistributor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/BoxListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/EfficiencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/InfalliblePackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/ItemListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Loading

0 comments on commit eca8d7b

Please sign in to comment.