Created
October 16, 2015 11:56
-
-
Save sgolemon/f65fafadd90ed26f05be to your computer and use it in GitHub Desktop.
My AstKit experimental branch. This is runkit levels of bad...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--TEST-- | |
Graft new value onto a statement list | |
--FILE-- | |
<?php | |
include('astkit-test.inc'); | |
$if = AstKit::parseString(<<<EOD | |
if (true) { | |
echo "This is a triumph.\n"; | |
} else { | |
echo "The cake is a lie.\n"; | |
} | |
EOD | |
); | |
$if->execute(); // First run, program is as-seen above | |
$const = $if->getChild(0)->getChild(0); | |
// Replace the "true" constant in the condition with false | |
$const->graft(0, false); | |
// Can also graft other AstKit nodes, instead of constants | |
$if->execute(); / Second run now takes the else path | |
--EXPECT-- | |
This is a triumph. | |
The cake is a lie. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment