protected function tryAndStackItemsIntoSpace(
        PackedLayer $layer,
        ?PackedItem $prevItem,
        ItemList $nextItems,
        int $maxWidth,
        int $maxLength,
        int $maxDepth,
        int $x,
        int $y,
        int $z,
        int $rowLength
    ): void {
        while (count($this->items) > 0 && $this->checkNonDimensionalConstraints($this->items->top())) {
            $stackedItem = $this->getOrientationForItem(
                $this->items->top(),
                $prevItem,
                $nextItems,
                $this->items->count() === 1,
                $maxWidth,
                $maxLength,
                $maxDepth,
                $rowLength
            );
            if ($stackedItem) {
                $this->remainingWeight -= $this->items->top()->getWeight();
                $layer->insert(PackedItem::fromOrientatedItem($stackedItem, $x, $y, $z));
                $this->items->extract();
                $maxDepth -= $stackedItem->getDepth();
                $z += $stackedItem->getDepth();
            } else {
                break;
            }
        }
    }
protected function tryAndStackItemsIntoSpace(
        PackedLayer $layer,
        ?PackedItem $prevItem,
        ItemList $nextItems,
        int $maxWidth,
        int $maxLength,
        int $maxDepth,
        int $x,
        int $y,
        int $z,
        int $rowLength
    ): void {
        while (count($this->items) > 0 && $this->checkNonDimensionalConstraints($this->items->top())) {
            $stackedItem = $this->getOrientationForItem(
                $this->items->top(),
                $prevItem,
                $nextItems,
                $this->items->count() === 1,
                $maxWidth,
                $maxLength,
                $maxDepth,
                $rowLength
            );
            if ($stackedItem) {
                $this->remainingWeight -= $this->items->top()->getWeight();
                $layer->insert(PackedItem::fromOrientatedItem($stackedItem, $x, $y, $z));
                $this->items->extract();
                $maxDepth -= $stackedItem->getDepth();
                $z += $stackedItem->getDepth();
            } else {
                break;
            }
        }
    }
protected function tryAndStackItemsIntoSpace ( PackedLayer $ layer , ? PackedItem $ prevItem , ItemList $ nextItems , int $ maxWidth , int $ maxLength , int $ maxDepth , int $ x , int $ y , int $ z , int $ rowLength ) : void { while ( count ( $ this -> items ) > 0 && $ this -> checkNonDimensionalConstraints ( $ this -> items -> top ( ) ) ) { $ stackedItem = $ this -> getOrientationForItem ( $ this -> items -> top ( ) , $ prevItem , $ nextItems , $ this -> items -> count ( ) === 1 , $ maxWidth , $ maxLength , $ maxDepth , $ rowLength ) ; if ( $ stackedItem ) { $ this -> remainingWeight -= $ this -> items -> top ( ) -> getWeight ( ) ; $ layer -> insert ( PackedItem :: fromOrientatedItem ( $ stackedItem , $ x , $ y , $ z ) ) ; $ this -> items -> extract ( ) ; $ maxDepth -= $ stackedItem -> getDepth ( ) ; $ z += $ stackedItem -> getDepth ( ) ; } else { break ; } } }
Figure out if we can stack the next item vertically on top of this rather than side by side
Used when we've packed a tall item, and have just put a shorter one next to it.

@param PackedLayer     $layer
@param PackedItem|null $prevItem
@param ItemList        $nextItems
@param int             $maxWidth
@param int             $maxLength
@param int             $maxDepth
@param int             $x
@param int             $y
@param int             $z
Figure out if we can stack the next item vertically on top of this rather than side by side Used when we ve packed a tall item and have just put a shorter one next to it .