@@ -28,185 +28,93 @@ class Env
2828 const VAR_STRING = 16 ;
2929
3030 /**
31- * @var string
32- */
33- private static $ _binary ;
34-
35- /**
36- * Returns true when Xdebug is supported or
37- * the runtime used is PHPDBG (PHP >= 7.0).
38- *
39- * @return bool
40- */
41- public static function canCollectCodeCoverage ()
42- {
43- return self ::hasXdebug () || self ::hasPHPDBGCodeCoverage ();
44- }
45-
46- /**
47- * Returns the path to the binary of the current runtime.
48- * Appends ' --php' to the path when the runtime is HHVM.
49- *
5031 * @return string
51- *
52- * @SuppressWarnings(PHPMD.NPathComplexity)
53- * @SuppressWarnings(PHPMD.Superglobals)
54- * @codeCoverageIgnore
32+ * @deprecated
5533 */
5634 public static function getBinary ()
5735 {
58- // HHVM
59- if (self ::$ _binary === null && self ::isHHVM ()) {
60- if ((self ::$ _binary = getenv ('PHP_BINARY ' )) === false ) {
61- self ::$ _binary = PHP_BINARY ;
62- }
63- self ::$ _binary = escapeshellarg (self ::$ _binary ) . ' --php ' ;
64- }
65-
66- // PHP >= 5.4.0
67- if (self ::$ _binary === null && defined ('PHP_BINARY ' )) {
68- self ::$ _binary = escapeshellarg (PHP_BINARY );
69- }
70-
71- // PHP < 5.4.0
72- if (self ::$ _binary === null ) {
73- if (PHP_SAPI == 'cli ' && isset ($ _SERVER ['_ ' ])) {
74- if (strpos ($ _SERVER ['_ ' ], 'phpunit ' ) !== false ) {
75- $ file = file ($ _SERVER ['_ ' ]);
76-
77- if (strpos ($ file [0 ], ' ' ) !== false ) {
78- $ tmp = explode (' ' , $ file [0 ]);
79- self ::$ _binary = escapeshellarg (trim ($ tmp [1 ]));
80- } else {
81- self ::$ _binary = escapeshellarg (ltrim (trim ($ file [0 ]), '#! ' ));
82- }
83-
84- } elseif (strpos (basename ($ _SERVER ['_ ' ]), 'php ' ) !== false ) {
85- self ::$ _binary = escapeshellarg ($ _SERVER ['_ ' ]);
86- }
87- }
88- }
89-
90- if (self ::$ _binary === null ) {
91- $ binaryLocations = array (
92- PHP_BINDIR . '/php ' ,
93- PHP_BINDIR . '/php-cli.exe ' ,
94- PHP_BINDIR . '/php.exe ' ,
95- );
96-
97- foreach ($ binaryLocations as $ binary ) {
98- if (is_readable ($ binary )) {
99- self ::$ _binary = escapeshellarg ($ binary );
100- break ;
101- }
102- }
103- }
104-
105- if (self ::$ _binary === null ) {
106- self ::$ _binary = 'php ' ;
107- }
108-
109- return self ::$ _binary ;
36+ return Sys::getBinary ();
11037 }
11138
11239 /**
11340 * @return string
41+ * @deprecated
11442 */
11543 public static function getNameWithVersion ()
11644 {
117- return self :: getName () . ' ' . self :: getVersion ();
45+ return Sys:: getNameWithVersion ();
11846 }
11947
12048 /**
12149 * @return string
50+ * @deprecated
12251 */
12352 public static function getName ()
12453 {
125- if (self ::isHHVM ()) {
126- return 'HHVM ' ;
127-
128- } elseif (self ::isPHPDBG ()) {
129- return 'PHPDBG ' ;
130- }
131-
132- return 'PHP ' ;
54+ return Sys::getName ();
13355 }
13456
13557 /**
13658 * @return string
59+ * @deprecated
13760 */
13861 public static function getVendorUrl ()
13962 {
140- if (self ::isHHVM ()) {
141- return 'http://hhvm.com/ ' ;
142- } else {
143- return 'http://php.net/ ' ;
144- }
63+ return Sys::getVendorUrl ();
14564 }
14665
14766 /**
14867 * @return string
68+ * @deprecated
14969 */
15070 public static function getVersion ()
15171 {
152- if (self ::isHHVM ()) {
153- return HHVM_VERSION ;
154- } else {
155- return PHP_VERSION ;
156- }
72+ return Sys::getVersion ();
15773 }
15874
15975 /**
160- * Returns true when the runtime used is PHP and Xdebug is loaded.
161- *
16276 * @return bool
77+ * @deprecated
16378 */
16479 public static function hasXdebug ()
16580 {
166- return ( self :: isPHP () || self :: isHHVM ()) && extension_loaded ( ' xdebug ' );
81+ return Sys:: hasXdebug ( );
16782 }
16883
16984 /**
170- * Returns true when the runtime used is HHVM.
171- *
17285 * @return bool
86+ * @deprecated
17387 */
17488 public static function isHHVM ()
17589 {
176- return defined ( ' HHVM_VERSION ' );
90+ return Sys:: isHHVM ( );
17791 }
17892
17993 /**
180- * Returns true when the runtime used is PHP without the PHPDBG SAPI.
181- *
18294 * @return bool
95+ * @deprecated
18396 */
18497 public static function isPHP ()
18598 {
186- return ! self :: isHHVM () && ! self :: isPHPDBG ();
99+ return Sys:: isRealPHP ();
187100 }
188101
189102 /**
190- * Returns true when the runtime used is PHP with the PHPDBG SAPI.
191- *
192103 * @return bool
193- * @codeCoverageIgnore
104+ * @deprecated
194105 */
195106 public static function isPHPDBG ()
196107 {
197- return PHP_SAPI === ' phpdbg ' && ! self :: isHHVM ();
108+ return Sys:: isPHPDBG ();
198109 }
199110
200111 /**
201- * Returns true when the runtime used is PHP with the PHPDBG SAPI
202- * and the phpdbg_*_oplog() functions are available (PHP >= 7.0).
203- *
204112 * @return bool
205- * @codeCoverageIgnore
113+ * @deprecated
206114 */
207115 public static function hasPHPDBGCodeCoverage ()
208116 {
209- return self :: isPHPDBG () && function_exists ( ' phpdbg_start_oplog ' );
117+ return Sys:: hasPHPDBGCodeCoverage ( );
210118 }
211119
212120 /**
0 commit comments