Doctrine\Common\Util\Debug::toString PHP Méthode

toString() public static méthode

Returns a string representation of an object.
public static toString ( object $obj ) : string
$obj object
Résultat string
    public static function toString($obj)
    {
        return method_exists($obj, '__toString') ? (string) $obj : get_class($obj) . '@' . spl_object_hash($obj);
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $basePath = 'app/jarves/';
     $fs = new Filesystem();
     if (!$fs->exists($basePath)) {
         $output->writeln(sprintf('<error>No website data in %s</error>', $basePath));
         return;
     }
     $files = $this->import($input, $output);
     if (!$input->getOption('watch')) {
         $output->writeln("<info>Done.</info>");
     } else {
         do {
             $output->writeln("<info>Done. Wait for changes ...</info>");
             while (true) {
                 sleep(1);
                 clearstatcache();
                 foreach ($files as $path => $mtime) {
                     if ($mtime !== filemtime($path)) {
                         $output->writeln(sprintf("<info>%s changed. Reimport</info>", $path));
                         break 2;
                     }
                 }
             }
             try {
                 $files = $this->import($input, $output);
             } catch (\Exception $e) {
                 foreach ($files as $path => $mtime) {
                     $files[$path] = filemtime($path);
                 }
                 $output->writeln("<error>Failed</error>");
                 echo Debug::toString($e);
                 $output->writeln("<info>Waiting for changes ...</info>");
             }
         } while (true);
     }
 }