public function analyze()
{
$functions = $this->loadJson('php_constant_arguments.json');
//alternative : one of the constants or nothing
$positions = range(0, count((array) $functions->alternative) - 1);
foreach ($positions as $position) {
$fullnspath = array();
foreach ($functions->alternative->{$position} as $function => $constants) {
$fullnspath[] = $function;
}
// Not a PHP constant
$this->atomFunctionIs($fullnspath)->outIs('ARGUMENTS')->outIs('ARGUMENT')->is('rank', $position)->atomIs(array('Identifier', 'Nsname'))->analyzerIsNot('Constants/IsPhpConstant')->back('first');
$this->prepareQuery();
// unwanted guests
$this->atomFunctionIs($fullnspath)->outIs('ARGUMENTS')->outIs('ARGUMENT')->is('rank', $position)->atomIs(array('Boolean', 'Null', 'Integer', 'Real', 'String', 'Concatenation', 'Logical'))->back('first');
$this->prepareQuery();
foreach ($functions->alternative->{$position} as $function => $constants) {
// PHP constant but wrong one
$this->atomFunctionIs($function)->outIs('ARGUMENTS')->outIs('ARGUMENT')->is('rank', $position)->atomIs(array('Identifier', 'Nsname'))->analyzerIs('Constants/IsPhpConstant')->outIsIE('SUBNAME')->codeIsNot($constants)->back('first');
$this->prepareQuery();
}
}
// combinaison : several constants may be combined with a logical operator
$positions = range(0, count((array) $functions->combinaison) - 1);
// First loop federate some queries
foreach ($positions as $position) {
$fullnspath = array();
foreach ($functions->combinaison->{$position} as $function => $constants) {
$fullnspath[] = $function;
}
// if it's a constant, but not a PHP one
$this->atomFunctionIs($fullnspath)->outIs('ARGUMENTS')->outIs('ARGUMENT')->is('rank', $position)->atomIs(array('Identifier', 'Nsname'))->analyzerIsNot('Constants/IsPhpConstant')->back('first');
$this->prepareQuery();
// in a logical combinaison, check that constants are at least PHP's one
$this->atomFunctionIs($fullnspath)->outIs('ARGUMENTS')->outIs('ARGUMENT')->is('rank', $position)->atomIs('Logical')->atomInside(array('Identifier', 'Nsname'))->analyzerIsNot('Constants/IsPhpConstant')->hasNoIn('SUBNAME')->back('first');
$this->prepareQuery();
// unwanted guests
$this->atomFunctionIs($fullnspath)->outIs('ARGUMENTS')->outIs('ARGUMENT')->is('rank', $position)->atomIs(array('Boolean', 'Null', 'Integer', 'Real'))->back('first');
$this->prepareQuery();
}
// Those must be run function by function
foreach ($positions as $position) {
foreach ($functions->combinaison->{$position} as $function => $constants) {
// if it's a PHP constant, but not a good one for the function
$this->atomFunctionIs($function)->outIs('ARGUMENTS')->outIs('ARGUMENT')->is('rank', $position)->atomIs(array('Identifier', 'Nsname'))->analyzerIs('Constants/IsPhpConstant')->outIsIE('SUBNAME')->codeIsNot($constants)->back('first');
$this->prepareQuery();
// in a logical combinaison, check that constants are the one for the function
$this->atomFunctionIs($function)->outIs('ARGUMENTS')->outIs('ARGUMENT')->is('rank', $position)->atomIs('Logical')->atomInside(array('Identifier', 'Nsname'))->analyzerIs('Constants/IsPhpConstant')->outIsIE('SUBNAME')->codeIsNot($constants)->back('first');
$this->prepareQuery();
}
}
}