3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Event { /** * @var Boolean Whether no further event listeners should be triggered */ private $propagationStopped = false; /** * Returns whether further event listeners should be triggered. * * @see Event::stopPropagation * @return Boolean Whether propagation was already stopped for this event. * * @api */ public function isPropagationStopped() { return $this->propagationStopped; } /** * Stops the propagation of the event to further event listeners. * * If multiple event listeners are connected to the same event, no * further event listener will be triggered once any trigger calls * stopPropagation(). * * @api */ public function stopPropagation() { $this->propagationStopped = true; } } class AddFranchiseeEvent extends Event { /** * Event identifier */ const EVENT_ID = 'gtt.franchisee_my.event.add_franchisee'; /** * New franchisee * * @var Franchisee */ private $franchisee; /** * Franchisee prefix * * @var string */ private $prefix; /** * 1C code * * @var string */ private $code; /** * Franchisee client ID * * @var integer */ private $clientId; /** * Constructor * * @param Franchisee $franchisee new franchisee, must be already stored and have ID * @param string $prefix prefix * @param string $code 1C code * @param int $clientId client ID */ public function __construct(Franchisee $franchisee, $prefix, $code, $clientId) { $this->franchisee = $franchisee; $this->prefix = $prefix; $this->code = $code; $this->clientId = $clientId; } /** * Gets managed franchisee entity * * @return Franchisee */ public function getFranchisee() { return $this->franchisee; } /** * Gets prefix * * @return string */ public function getPrefix() { return $this->prefix; } /** * Gets 1C code * * @return string */ public function getCode() { return $this->code; } /** * Gets franchisee client ID * * @return int */ public function getClientId() { return $this->clientId; } } /** * Class Franchisee * @package Gtt\Module\FranchiseeMy\Entity * * @Map\Entity * * @Map\Table(name="franchisee") */ class Franchisee { /** * ID * * @var int * * @Map\Id * * @Map\Column(name="id", type="integer") * * @Map\GeneratedValue(strategy="AUTO") */ private $id; /** * Parent ID * * @var int * * @Map\Column(name="parent_id", type="integer") */ private $parentId; /** * Short name * * @var string * * @Map\Column(name="short_name", type="string") */ private $shortName; /** * Short name * * @var string * * @Map\Column(name="full_name", type="string") */ private $fullName; /** * Branch ID * * @var int * * @Map\Column(name="branch_id", type="integer") */ private $branchId; /** * Status * * @var int * * @Map\Column(name="status_id", type="integer") */ private $status; /** * Setter * * @param int $status * * @return void */ public function setStatus($status) { $this->status = $status; } /** * Getter * * @return int */ public function getStatus() { return $this->status; } /** * Sets full name * * @param string $fullName */ public function setFullName($fullName) { $this->fullName = $fullName; } /** * Gets full name * * @return string */ public function getFullName() { return $this->fullName; } /** * Sets ID * * @param int $id */ public function setId($id) { $this->id = $id; } /** * Gets ID * * @return int */ public function getId() { return $this->id; } /** * Sets parent ID * * @param int $parentId */ public function setParentId($parentId) { $this->parentId = $parentId; } /** * Gets parent ID * * @return int */ public function getParentId() { return $this->parentId; } /** * Sets short name * * @param string $shortName */ public function setShortName($shortName) { $this->shortName = $shortName; } /** * Gets short name * * @return string */ public function getShortName() { return $this->shortName; } /** * Gets branch ID * * @return int */ public function getBranchId() { return $this->branchId; } /** * Sets branch ID * * @param int $branchId branch ID * * @return void */ public function setBranchId($branchId) { $this->branchId = $branchId; } } $object = new AddFranchiseeEvent(new Franchisee(), 'pref', 121, 12323); echo json_encode($object);
Output for 5.2.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
{}
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/Y0HSi on line 328
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/Y0HSi on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Y0HSi on line 9
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/Y0HSi on line 9
Process exited with code 255.