[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\Finder\Shell; 13 14 @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); 15 16 /** 17 * @author Jean-François Simon <contact@jfsimon.fr> 18 * 19 * @deprecated since 2.8, to be removed in 3.0. 20 */ 21 class Shell 22 { 23 const TYPE_UNIX = 1; 24 const TYPE_DARWIN = 2; 25 const TYPE_CYGWIN = 3; 26 const TYPE_WINDOWS = 4; 27 const TYPE_BSD = 5; 28 29 /** 30 * @var string|null 31 */ 32 private $type; 33 34 /** 35 * Returns guessed OS type. 36 * 37 * @return int 38 */ 39 public function getType() 40 { 41 if (null === $this->type) { 42 $this->type = $this->guessType(); 43 } 44 45 return $this->type; 46 } 47 48 /** 49 * Tests if a command is available. 50 * 51 * @param string $command 52 * 53 * @return bool 54 */ 55 public function testCommand($command) 56 { 57 if (!\function_exists('exec')) { 58 return false; 59 } 60 61 // todo: find a better way (command could not be available) 62 $testCommand = 'which '; 63 if (self::TYPE_WINDOWS === $this->type) { 64 $testCommand = 'where '; 65 } 66 67 $command = escapeshellcmd($command); 68 69 exec($testCommand.$command, $output, $code); 70 71 return 0 === $code && \count($output) > 0; 72 } 73 74 /** 75 * Guesses OS type. 76 * 77 * @return int 78 */ 79 private function guessType() 80 { 81 $os = strtolower(PHP_OS); 82 83 if (false !== strpos($os, 'cygwin')) { 84 return self::TYPE_CYGWIN; 85 } 86 87 if (false !== strpos($os, 'darwin')) { 88 return self::TYPE_DARWIN; 89 } 90 91 if (false !== strpos($os, 'bsd')) { 92 return self::TYPE_BSD; 93 } 94 95 if (0 === strpos($os, 'win')) { 96 return self::TYPE_WINDOWS; 97 } 98 99 return self::TYPE_UNIX; 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |