trait Tlf\Lexer\Test\Directives\ClassIntegration

Constants

Properties

  • `protected $_class_integration_tests = [

      'Integration.Class.Methods.WithNestedBlock'=>[
          'is_bad_test''This test is pretty good & validates that we can handle nested blocks without messing up the ASTs. However, we don\'t currently capture the contents of a code block. We don\'t capture its statements. We just ignore it, which is okay, but not ',
          ''=>'',
          ''=>[''],
          ''=>
              <<<PHP
                  class A {
                      public function is_the_us_imperialist():bool {
                          if (\$you_buy_into_imperialist_propaganda){
                              if (true){
                                  return false;
                              }
                          } 
                          return true;
                      } 
                      public function is_the_us_nice():bool {
                          if (\$you_are_rich){
                              if (true){
                                  return true;
                              }
                          } 
                          return false;
                      } 
                  } //
              PHP,
          ''=>[
              ''=>[
                  0=>[
                      ''=>'',
                      ''=>'',
                      ''=>'class ',
                      ''=>[
                          0=>[
                              ''=>'',
                              ''=>[],
                              ''=>[''],
                              ''=>'',
                              ''=>[''],
                              ''=>[],
                              ''=>'public function ',
                          ],
                          1=>[
                              ''=>'',
                              ''=>[],
                              ''=>[''],
                              ''=>'',
                              ''=>[''],
                              ''=>[],
                              ''=>'public function ',
                          ],
                      ],
                  ]
              ]
          ],
      ],
    
      ''=>[
          ''=>'',
          ''=>[''],
          ''=>"final class Abc {\n"
                  ."    public function abc() {"
                  ."    }"
                  ."}",
          ''=>[
              ''=>[
                  0=>[
                  ''=>'',
                  ''=>'',
                  ''=>[''],
                  ''=> 'final class ',
                  ''=>[
                      0=>[
                          ''=>'',
                          ''=>[],
                          ''=>[''],
                          ''=>'',
                          ''=>[],
                          ''=>'public function ',
                      ],
                  ],
                  ],
              ],
          ],
      ],
    
      ''=>[
          ''=>'This test works as intended, and was implemented to help handle a bug where a 's methods were being added to its modifiers. This was caused by getTree() recursion with arrays & use of the passthrough feature.',
          'ast.type''namespace',
          'start''php_code'],
          'input'"abstract class Abc {\n"
              "    public function ",
          'expect'=>[
              'class'=>[
                  0=>[
                  'type''class',
                  'modifiers''abstract'],
                  'name''Abc',
                  'declaration'=> 'abstract class Abc',
                  'methods'=>[
                      0=>[
                          'type''method',
                          'args'=>[],
                          'modifiers''public'],
                      ],
                  ],
                  ],
              ],
          ],
      ],
    
      'Integration.Class.Method.2'=>[
          'ast.type''file',
          'start''php_code'],
          'input'"class Abc {\n"
                  "    public function abc() {"
                  "\n    }"
                  "    private function def() {"
                  "\n    }"
                  "\n}"
                  "final class Def {\n"
                  "    public function abc() {"
                  "\n    }"
                  "    protected function def() {"
                  "\n    }"
                  "\n}"
                  ,
          'expect'=>[
              'namespace''',
              'class'=>[
                  0=>[
                  'type''class',
                  'name''Abc',
                  'declaration'=> 'class Abc',
                  'methods'=>[
                          0=>[
                              'type''method',
                              'args'=>[],
                              'modifiers''public'],
                              'name''abc',
                              'body'=>[],
                              'declaration''public function abc()',
                          ],
                          1=>[
                              'type''method',
                              'args'=>[],
                              'modifiers''private'],
                              'name''def',
                              'body'=>[],
                              'declaration''private function def()',
                          ],
                      ],
                  ],
                  1=>[
                  'type''class',
                  'name''Def',
                  'modifiers''final'],
                  'declaration'=> 'final class Def',
                  'methods'=>[
                          0=>[
                              'type''method',
                              'args'=>[],
                              'modifiers''public'],
                              'name''abc',
                              'body'=>[],
                              'declaration''public function abc()',
                          ],
                          1=>[
                              'type''method',
                              'args'=>[],
                              'modifiers''protected'],
                              'name''def',
                              'body'=>[],
                              'declaration''protected function def()',
                          ],
                      ],
                  ],
              ],
          ],
      ],
    
      'Integration.Trait.Method'=>[
          'ast.type''namespace',
          'start''php_code'],
          'input'"trait Abc {\n"
                  "    public function abc() {"
                  "    }"
                  "}",
          'expect'=>[
              'trait'=>[
                  0=>[
                  'type''trait',
                  'name''Abc',
                  'declaration'=> 'trait Abc',
                  'methods'=>[
                      0=>[
                          'type''method',
                          'args'=>[],
                          'modifiers''public'],
                          'name''abc',
                          'body'=>[],
                          'declaration''public function abc()',
                      ],
                  ],
                  ],
              ],
          ],
      ],
    
      'Integration.Class.Method'=>[
          'ast.type''namespace',
          'start''php_code'],
          'input'"class Abc {\n"
                  "    public function abc() {"
                  "    }"
                  "}",
          'expect'=>[
              'class'=>[
                  0=>[
                  'type''class',
                  'name''Abc',
                  'declaration'=> 'class Abc',
                  'methods'=>[
                      0=>[
                          'type''method',
                          'args'=>[],
                          'modifiers''public'],
                          'name''abc',
                          'body'=>[],
                          'declaration''public function abc()',
                      ],
                  ],
                  ],
              ],
          ],
      ],
    

    ];`

Methods