/** * @test */ public function convertToBooleanProperlyConvertsObjects() { $this->assertFalse(BooleanNode::convertToBoolean(NULL)); $this->assertTrue(BooleanNode::convertToBoolean(new \stdClass())); }
/** * @param NodeInterface $node * @param RenderingContextInterface $renderingContext * @return boolean */ public static function createFromNodeAndEvaluate(NodeInterface $node, RenderingContextInterface $renderingContext) { $booleanNode = new BooleanNode($node); return $booleanNode->evaluate($renderingContext); }
/** * @param BooleanNode $node * @return array * @see convert() */ protected function convertBooleanNode(BooleanNode $node) { $stack = $this->convertArrayNode(new ArrayNode($node->getStack())); $initializationPhpCode = '// Rendering Boolean node' . chr(10); $initializationPhpCode = $stack['initialization'] . chr(10); return array('initialization' => $initializationPhpCode, 'execution' => sprintf('\\NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\BooleanNode::evaluateStack($renderingContext, %s)', $stack['execution'])); }