<?php
class TiroNaCara extends Exception {
public function __construct($grito){
parent::__construct("Você levou tiro na cara: " . strtoupper($grito));
}
}
class LojaDeCrack {
private $pacotes = array();
private function checarPacotes($oQueFazer){
$pacotes = $this -> pacotes;
foreach($pacotes as $pedraDoPacote)
$oQueFazer($pedraDoPacote);
}
public function __construct($pacotes){
if(gettype($pacotes) == "array" && !empty($pacotes)){
checarPacotes(function($pedraDoPacote){
if(!is_numeric($pedraDoPacote))
throw new TiroNaCara("CLIENTE BURRO DO CARALHUDO DE UMAS ARÁBIAS! AFF");
});
$this -> pacotes = $pacotes;
}else
throw new TiroNaCara("TEM ALGO DE ERRADO COM OS MEUS PACOTES... SEU CRACKUDO FILHO DA PUTA!");
}
public function comprarPedra($pedras){
if(is_numeric($pedras)){
$pacotes = $this -> pacotes;
foreach($pacotes as $pedraDoPacote){
if($pedraDoPacote <= $pedras){
$resto = $pedras%$pedraDoPacote;
if($resto)
comprarPedra($resto);
}
}
}else
throw new TiroNaCara("TA ME TIRANDO, FILHO DA PUTA?!");
}
}
try{
$crack = new LojaDeCrack(array(20, 10, 7, ''));
}catch(Exception $e){
echo $e -> getMessage();
}
?>
Fatal error: Uncaught Error: Call to undefined function checarPacotes() in /in/SCdDG:18
Stack trace:
#0 /in/SCdDG(43): LojaDeCrack->__construct(Array)
#1 {main}
thrown in /in/SCdDG on line 18
Process exited with code 255.
Fatal error: Call to undefined function checarPacotes() in /in/SCdDG on line 18
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/SCdDG on line 18
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/SCdDG on line 18
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SCdDG on line 3
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SCdDG on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/SCdDG on line 3
Process exited with code 255.