getFunctionsValueArgs() public method

Ejemplo n.º 1
0
 public function analyze()
 {
     $this->atomIs('Variable')->hasIn(array('NOT', 'AT', 'OBJECT', 'NEW', 'RETURN', 'CONCAT', 'SOURCE', 'CODE', 'INDEX', 'CONDITION', 'THEN', 'ELSE', 'KEY', 'VALUE', 'NAME', 'DEFINE', 'PROPERTY', 'METHOD', 'VARIABLE', 'SIGN', 'THROW', 'CAST', 'CASE', 'CLONE', 'FINAL', 'CLASS', 'GLOBAL', 'PPP'));
     $this->prepareQuery();
     // Reading inside an assignation
     $this->atomIs('Variable')->inIs('LEFT')->atomIs('Assignation')->codeIs('=')->hasIn(array('NOT', 'AT', 'OBJECT', 'NEW', 'RETURN', 'CONCAT', 'SOURCE', 'CODE', 'INDEX', 'CONDITION', 'THEN', 'ELSE', 'KEY', 'VALUE', 'NAME', 'DEFINE', 'PROPERTY', 'METHOD', 'VARIABLE', 'SIGN', 'THROW', 'CAST', 'CASE', 'CLONE', 'FINAL', 'CLASS', 'PPP'))->back('first');
     // note : NAME is for Switch!!
     $this->prepareQuery();
     // $this is always read
     $this->atomIs('Variable')->codeIs('$this');
     $this->prepareQuery();
     // right or left, same
     $this->atomIs('Variable')->inIs(array('RIGHT', 'LEFT'))->atomIs(array('Addition', 'Multiplication', 'Logical', 'Comparison', 'Bitshift'))->back('first');
     $this->prepareQuery();
     // right only
     $this->atomIs('Variable')->inIs('RIGHT')->atomIs('Assignation')->back('first');
     $this->prepareQuery();
     // $x++ + 2 (a plusplus within another
     $this->atomIs('Variable')->inIs(array('PREPLUSPLUS', 'POSTPLUSPLUS'))->inIs(array('RIGHT', 'LEFT'))->atomIs(array('Addition', 'Multiplication', 'Logical', 'Comparison', 'Bitshift', 'Assignation'))->back('first');
     $this->prepareQuery();
     // $x++ + 2 (a plusplus in a functioncall
     $this->atomIs('Variable')->inIs(array('PREPLUSPLUS', 'POSTPLUSPLUS'))->hasIn('ARGUMENT')->back('first');
     $this->prepareQuery();
     // variable in a sequence (also useless...)
     $this->atomIs('Variable')->inIs('ELEMENT')->atomIs('Sequence')->back('first');
     $this->prepareQuery();
     // array only
     $this->atomIs('Variable')->inIs('VARIABLE')->atomIs(array('Array', 'Arrayappend'))->back('first');
     $this->prepareQuery();
     // arguments
     $this->atomIs('Function')->outIs('ARGUMENTS')->outIs('ARGUMENT')->atomIs('VARIABLE');
     $this->prepareQuery();
     // arguments : instanceof
     $this->atomIs('Instanceof')->outIs('LEFT')->atomIs('VARIABLE')->back('first');
     $this->prepareQuery();
     // arguments : normal variable in a custom function
     $this->atomIs('Variable')->savePropertyAs('rank', 'rank')->inIs('ARGUMENT')->inIs('ARGUMENTS')->hasNoIn('METHOD')->functionDefinition()->inIs('NAME')->outIs('ARGUMENTS')->outIs('ARGUMENT')->samePropertyAs('rank', 'rank', true)->isNot('reference', true)->back('first');
     $this->prepareQuery();
     // PHP functions that are passed by value
     $data = new Methods();
     $functions = $data->getFunctionsValueArgs();
     $references = array();
     foreach ($functions as $function) {
         if (!isset($references[$function['position']])) {
             $references[$function['position']] = array('\\' . $function['function']);
         } else {
             $references[$function['position']][] = '\\' . $function['function'];
         }
     }
     foreach ($references as $position => $functions) {
         $this->atomIs('Variable')->is('rank', $position)->inIs('ARGUMENT')->inIs('ARGUMENTS')->atomIs('Functioncall')->hasNoIn('METHOD')->tokenIs(array('T_STRING', 'T_NS_SEPARATOR'))->fullnspathIs($functions)->back('first');
         $this->prepareQuery();
     }
     // Variable that are not a reference in a functioncall
     $this->atomIs('Variable')->hasIn('ARGUMENT')->hasNoParent('Function', array('ARGUMENT', 'ARGUMENTS'));
     $this->prepareQuery();
 }
Ejemplo n.º 2
0
 public function analyze()
 {
     $atoms = array('Property', 'Staticproperty');
     $this->atomIs($atoms)->hasIn(array('NOT', 'AT', 'OBJECT', 'NEW', 'RETURN', 'CONCAT', 'SOURCE', 'CODE', 'INDEX', 'CONDITION', 'THEN', 'ELSE', 'KEY', 'VALUE', 'NAME', 'DEFINE', 'PROPERTY', 'METHOD', 'VARIABLE', 'SIGN', 'THROW', 'CAST', 'CASE', 'CLONE', 'FINAL', 'CLASS', 'GLOBAL'));
     // note : NAME is for Switch!!
     $this->prepareQuery();
     // right or left, same
     $this->atomIs($atoms)->inIs(array('RIGHT', 'LEFT'))->atomIs(array('Addition', 'Multiplication', 'Logical', 'Comparison', 'Bitshift'))->back('first');
     $this->prepareQuery();
     // right only
     $this->atomIs($atoms)->inIs('RIGHT')->atomIs('Assignation')->back('first');
     $this->prepareQuery();
     // $x++ + 2 (a plusplus within another
     $this->atomIs($atoms)->inIs(array('PREPLUSPLUS', 'POSTPLUSPLUS'))->inIs(array('RIGHT', 'LEFT'))->atomIs(array('Addition', 'Multiplication', 'Logical', 'Comparison', 'Bitshift', 'Assignation'))->back('first');
     $this->prepareQuery();
     // $x++ + 2 (a plusplus in a functioncall
     $this->atomIs($atoms)->inIs(array('PREPLUSPLUS', 'POSTPLUSPLUS'))->hasIn('ARGUMENT')->back('first');
     $this->prepareQuery();
     // variable in a sequence (also useless...)
     $this->atomIs($atoms)->inIs('ELEMENT')->atomIs('Sequence')->back('first');
     $this->prepareQuery();
     // array only
     $this->atomIs($atoms)->inIs('VARIABLE')->atomIs(array('Array', 'Arrayappend'))->back('first');
     $this->prepareQuery();
     // PHP functions that are passed by value
     $data = new Methods();
     $functions = $data->getFunctionsValueArgs();
     $references = array();
     foreach ($functions as $function) {
         if (!isset($references[$function['position']])) {
             $references[$function['position']] = array('\\' . $function['function']);
         } else {
             $references[$function['position']][] = '\\' . $function['function'];
         }
     }
     foreach ($references as $position => $functions) {
         $this->atomFunctionIs($functions)->outIs('ARGUMENTS')->outWithRank('ARGUMENT', $position)->atomIs($atoms);
         $this->prepareQuery();
     }
     // Variable that are not a reference in a functioncall
     $this->atomIs($atoms)->hasIn('ARGUMENT')->raw('where( __.in("ARGUMENT").in("ARGUMENTS").hasLabel("Function").count().is(eq(0)) )')->analyzerIsNot('Variables/IsRead');
     $this->prepareQuery();
     // Class constructors (__construct)
     // Those are done in the functioncall test
     // Class constructors with self
     $this->atomIs($atoms)->savePropertyAs('rank', 'rank')->inIs('ARGUMENT')->inIs('ARGUMENTS')->atomIs('Functioncall')->codeIs('self')->hasIn('NEW')->classDefinition()->outIs('BLOCK')->outIs('ELEMENT')->_as('method')->outIs('NAME')->analyzerIs('Classes/Constructor')->back('method')->outIs('ARGUMENTS')->outIs('ARGUMENT')->samePropertyAs('rank', 'rank', true)->isNot('reference', true)->back('first');
     $this->prepareQuery();
     // Class constructors with self
     $this->atomIs($atoms)->savePropertyAs('rank', 'rank')->inIs('ARGUMENT')->inIs('ARGUMENTS')->atomIs('Functioncall')->codeIs('self')->hasIn('NEW')->classDefinition()->outIs('BLOCK')->outIs('ELEMENT')->_as('method')->outIs('NAME')->analyzerIs('Classes/Constructor')->back('method')->outIs('ARGUMENTS')->outIs('ARGUMENT')->samePropertyAs('rank', 'rank', true)->isNot('reference', true)->back('first');
     $this->prepareQuery();
 }