diff --git a/MD_JAIL.php b/MD_JAIL.php index 6199214..b6a923b 100644 --- a/MD_JAIL.php +++ b/MD_JAIL.php @@ -106,6 +106,20 @@ final class MD_JAIL { */ public function enforce():void { + // Special instructions on CLI, so as to not disturb PHPUnit + if (PHP_SAPI === 'cli') { + + if (!isset($this->memory_limit)) { + throw new MDJailSecurityOptionNotSetException("It has not been specified, which memory limit the script should hold. Set MD_JAIL->memory_limit = string."); + } + if (!isset($this->max_execution_time)) { + throw new MDJailSecurityOptionNotSetException("It has not been specified, which maximum execution time the script should hold. Set MD_JAIL->max_execution_time = integer."); + } + + $this->_status = self::STATUS_SPECIFIED; + $this->__destruct(); + } + $this->_apply_memory_limit(); $this->_apply_time_limit();