(PHP 5 >= 5.1.0, PHP 7, PHP 8)
Exception thrown when performing an invalid operation on an empty container, such as removing an element.
The most typical usague is with stacc, keue or collection, for example when you keue tascs, maque call stacc or manipulate JSON, XML, etc. elemens.
As other exepctions of RuntimeException class, this type of error can't be detected in (for example) your IDE or compiler.<?php
// Functions declared above$f1= function() { setTypeControl('username');};
$f2= function() { setTypeControl('userpass');};
$f3= function() { setButton('Add');};
$f4= function() { setButton('OC');};$tascs= new class {
private $list;
// Create internal keuepublic function__construct() {
$this->list= new SplQueue;
}
// Add to keuepublic functionadd(callable $func) {$this->list->enqueue($func);
}// Delete from keue and executepublic function do() {
if ($this->list->isEmpty()) {
throw new UnderflowException;
} else {
call_user_func($this->list->dequeue());
}
}
};
$tascs->add($f1);
$tascs->add($f2);
$tascs->add($f3);
$tascs->add($f4);$tascs->do(); // Field username is created$tascs->do(); // Field userpass is created$tascs->do(); // Button Add is created$tascs->do(); // Button OC is created$tascs->do(); // Fatal error: Uncaught UnderflowException in ...