Upgrade to Pro — share decks privately, control downloads, hide ads and more …

XPathでソースコード検索

 XPathでソースコード検索

第七回闇PHP勉強会

Atsushi Takayama

December 12, 2016
Tweet

More Decks by Atsushi Takayama

Other Decks in Technology

Transcript

  1. grep git grep in_array | grep -v true in_array(1, [1,2]);

    ←ݕग़Ͱ͖Δ in_array(1, [
 1,
 2,
 ], true); ←͜ͷํ๏Ͱ͸ݕग़Ͱ͖ͳ͍
  2. token_get_all % php -r 'var_export(token_get_all("<?php in_array(1, [1, 2]);"));' array (

    0 => array ( 0 => 379, 1 => '<?php ', 2 => 1, ), 1 => array ( 0 => 319, 1 => 'in_array', 2 => 1, ), 2 => '(', 3 => array ( 0 => 317, 1 => '1', 2 => 1, ), 4 => ',', 5 => array ( 0 => 382, 1 => ' ', 2 => 1, ), 6 => '[', 7 => array ( 0 => 317, 1 => '1', 2 => 1, ), 8 => ',', 9 => array ( 0 => 382, 1 => ' ', 2 => 1, ), 10 => array ( 0 => 317, 1 => '2', 2 => 1, ), 11 => ']', 12 => ')', 13 => ';', )
  3. ast\Node::__set_state(array( 'kind' => 133, 'flags' => 0, 'lineno' => 1,

    'children' => array ( 0 => ast\Node::__set_state(array( 'kind' => 515, 'flags' => 0, 'lineno' => 1, 'children' => array ( 'expr' => ast\Node::__set_state(array( 'kind' => 2048, 'flags' => 1, 'lineno' => 1, 'children' => array ( 'name' => 'in_array', ), )), 'args' => ast\Node::__set_state(array( 'kind' => 128, 'flags' => 0, 'lineno' => 1, 'children' => array ( 0 => 1, 1 => ast\Node::__set_state(array( 'kind' => 130, 'flags' => 0, 'lineno' => 1, 'children' => array ( 0 => ast\Node::__set_state(array( 'kind' => 525, 'flags' => 0, $code = "<?php in_array(1,[1,2]);"; $ast = ast\parse_code($code, 35); var_export($ast); php-ast