Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $code = $input->getArgument('code');
     if (strpos('<?', $code) === false) {
         $code = '<?php ' . $code;
     }
     $walker = $this->getWalker();
     $nodes = $this->parse($code);
     $depth = $input->getOption('depth');
     $output->page(function (ShellOutput $output) use(&$walker, $nodes, $depth) {
         $out = Inspector::export($nodes, $depth);
         $walker($output, $out);
     });
 }
Exemplo n.º 2
0
 public function testExport()
 {
     $result = Inspector::export($this, 3);
     $this->assertEquals('Psy\\Test\\Util\\InspectorTest', $result->{'__CLASS__'});
     $this->assertEquals('FOO', $result->foo);
     $this->assertEquals('BAR', $result->bar);
     $this->assertEquals('BAZ', $result->baz);
     $this->assertEquals(array('a' => array('b' => 'Array(1)')), $result->qux);
     $result = Inspector::export(new \StdClass(), 0);
     $this->assertInternalType('string', $result);
     $this->assertRegExp('/<stdClass #[0-9a-f]+>/i', $result);
     $num = 13;
     $result = Inspector::export($num, 0);
     $this->assertInternalType('integer', $result);
     $this->assertEquals($num, $result);
 }