Example #1
0
 public function shortenedExport($value)
 {
     if ($value instanceof CM_Debug_DebugInfoInterface) {
         return (new CM_Debug_VariableInspector())->getDebugInfo($value);
     }
     return parent::shortenedExport($value);
 }
 public function shortenedExport($value)
 {
     if ($value instanceof CallableInterface) {
         return (string) $value;
     }
     return parent::shortenedExport($value);
 }
 /**
  * @param  mixed   $data
  * @param  Context $context
  *
  * @return string
  */
 public function shortenedRecursiveExport(&$data, Context $context = null)
 {
     $result = array();
     $exporter = new Exporter();
     if (!$context) {
         $context = new Context();
     }
     $context->add($data);
     foreach ($data as $key => $value) {
         if (is_array($value)) {
             if ($context->contains($data[$key]) !== false) {
                 $result[] = '*RECURSION*';
             } else {
                 $result[] = sprintf('array(%s)', $this->shortenedRecursiveExport($data[$key], $context));
             }
         } else {
             $result[] = $exporter->shortenedExport($value);
         }
     }
     return join(', ', $result);
 }
Example #4
0
 /**
  * @param  mixed                                      $data       The data to export as a string
  * @param  SebastianBergmann\RecursionContext\Context $processed  Contains all objects and arrays that have previously been processed
  * @return string
  * @since  Method available since Release 3.2.1
  */
 protected function dataToString(&$data, $processed = null)
 {
     $result = array();
     $exporter = new Exporter();
     if (!$processed) {
         $processed = new Context();
     }
     $processed->add($data);
     foreach ($data as $key => $value) {
         if (is_array($value)) {
             if ($processed->contains($data[$key]) !== false) {
                 $result[] = '*RECURSION*';
             } else {
                 $result[] = sprintf('array(%s)', $this->dataToString($data[$key], $processed));
             }
         } else {
             $result[] = $exporter->shortenedExport($value);
         }
     }
     return join(', ', $result);
 }
 /**
  * @dataProvider readwritePropertiesProvider
  */
 public function testPropertiesWithFullAccessAreReadablesAndWritables(IStrictPropertiesContainer $obj = null, $property = null, $value = null, $expected = null)
 {
     if ($obj === null) {
         $this->markTestSkipped('Target class has not read-write properties to test.');
     }
     $exporter = new Exporter();
     $var = get_class($obj);
     $var = Inflector::variable(substr($var, strrpos($var, '\\') === false ? 0 : strrpos($var, '\\') + 1));
     $obj->{$property} = $value;
     $actual = $obj->{$property};
     $message = String::format('${var}->{property} = {value}; $actual = ${var}->{property}; // {actual}', ['var' => $var, 'property' => $property, 'actual' => $exporter->shortenedExport($actual), 'value' => $exporter->shortenedExport($value)]);
     $this->assertEquals($expected, $actual, $message);
 }