for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* For licensing information, please see the LICENSE file accompanied with this file.
*
* @author Gerard van Helden <[email protected]>
* @copyright 2012 Gerard van Helden <http://melp.nl>
*/
namespace Zicht\Tool\Script\Node\Expr\Op;
use Zicht\Tool\Script\Node\Branch;
use Zicht\Tool\Script\Node\Node;
use Zicht\Tool\Script\Buffer;
* Represents a ternary expression
class Ternary extends Branch
{
* Constructor.
* @param string $operator
* @param Node $condition
* @param Node $then
* @param Node $else
public function __construct($operator, $condition, $then, $else)
parent::__construct();
$this->operator = $operator;
operator
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$this->nodes[0] = $condition;
$this->nodes[1] = $then;
$this->nodes[2] = $else;
}
* @{inheritDoc}
public function compile(Buffer $buffer)
$this->nodes[0]->compile($buffer);
$buffer->raw('?');
if ($this->nodes[1]) {
$this->nodes[1]->compile($buffer);
$buffer->raw(':');
if ($this->nodes[2]) {
$this->nodes[2]->compile($buffer);
} else {
$buffer->raw('null');
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: