for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Box packing (3D bin packing, knapsack problem)
* @package BoxPacker
* @author Doug Wright
*/
namespace DVDoug\BoxPacker;
* List of items to be packed, ordered by volume
class ItemList extends \SplMaxHeap
{
* Compare elements in order to place them correctly in the heap while sifting up.
*
* @see \SplMaxHeap::compare()
* @param mixed $itemA
* @param mixed $itemB
* @return int
integer|double
This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.
@return
public function compare($itemA, $itemB)
if ($itemA->getVolume() > $itemB->getVolume()) {
return 1;
} elseif ($itemA->getVolume() < $itemB->getVolume()) {
return -1;
} else {
return $itemA->getWeight() - $itemB->getWeight();
}
* Get copy of this list as a standard PHP array
* @return array
public function asArray()
$return = [];
foreach (clone $this as $item) {
$return[] = $item;
return $return;
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.