Beispiel #1
0
 /**
  * Test succeeds when no warnings are emitted externally, and original level is restored.
  */
 public function testSilencer()
 {
     $before = error_reporting();
     // Check warnings are suppressed correctly
     Silencer::suppress();
     @trigger_error('Test', E_USER_WARNING);
     Silencer::restore();
     // Check all parameters and return values are passed correctly in a silenced call.
     $result = Silencer::call(function ($a, $b, $c) {
         @trigger_error('Test', E_USER_WARNING);
         return $a * $b * $c;
     }, 2, 3, 4);
     $this->assertEquals(24, $result);
     // Check the error reporting setting was restored correctly
     $this->assertEquals($before, error_reporting());
 }
Beispiel #2
0
 /**
  * {@inheritDoc}
  */
 private function hintCommonErrors($exception)
 {
     $io = $this->getIO();
     Silencer::suppress();
     try {
         $composer = $this->getComposer(false, true);
         if ($composer) {
             $config = $composer->getConfig();
             $minSpaceFree = 1024 * 1024;
             if (($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree || ($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree || ($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree) {
                 $io->writeError('<error>The disk hosting ' . $dir . ' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
             }
         }
     } catch (\Exception $e) {
     }
     Silencer::restore();
     if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
         $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
         $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>', true, IOInterface::QUIET);
     }
     if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
         $io->writeError('<error>The following exception is caused by a lack of memory and not having swap configured</error>', true, IOInterface::QUIET);
         $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
     }
 }