pax_global_header00006660000000000000000000000064135651766020014525gustar00rootroot0000000000000052 comment=464c90d7bdf5ad4e8a6aea15c091fec0603d4368 environment-4.2.3/000077500000000000000000000000001356517660200140775ustar00rootroot00000000000000environment-4.2.3/.github/000077500000000000000000000000001356517660200154375ustar00rootroot00000000000000environment-4.2.3/.github/FUNDING.yml000066400000000000000000000000321356517660200172470ustar00rootroot00000000000000github: sebastianbergmann environment-4.2.3/.gitignore000066400000000000000000000001231356517660200160630ustar00rootroot00000000000000/.idea /vendor /composer.lock /composer.phar /.php_cs.cache /.phpunit.result.cache environment-4.2.3/.php_cs.dist000066400000000000000000000175421356517660200163270ustar00rootroot00000000000000 For the full copyright and license information, please view the LICENSE file that was distributed with this source code. EOF; return PhpCsFixer\Config::create() ->setRiskyAllowed(true) ->setRules( [ 'align_multiline_comment' => true, 'array_indentation' => true, 'array_syntax' => ['syntax' => 'short'], 'binary_operator_spaces' => [ 'operators' => [ '=' => 'align', '=>' => 'align', ], ], 'blank_line_after_namespace' => true, 'blank_line_before_statement' => [ 'statements' => [ 'break', 'continue', 'declare', 'do', 'for', 'foreach', 'if', 'include', 'include_once', 'require', 'require_once', 'return', 'switch', 'throw', 'try', 'while', 'yield', ], ], 'braces' => true, 'cast_spaces' => true, 'class_attributes_separation' => ['elements' => ['const', 'method', 'property']], 'combine_consecutive_issets' => true, 'combine_consecutive_unsets' => true, 'combine_nested_dirname' => true, 'compact_nullable_typehint' => true, 'concat_space' => ['spacing' => 'one'], 'declare_equal_normalize' => ['space' => 'none'], 'declare_strict_types' => true, 'dir_constant' => true, 'elseif' => true, 'encoding' => true, 'full_opening_tag' => true, 'function_declaration' => true, 'header_comment' => ['header' => $header, 'separate' => 'none'], 'indentation_type' => true, 'is_null' => true, 'line_ending' => true, 'list_syntax' => ['syntax' => 'short'], 'logical_operators' => true, 'lowercase_cast' => true, 'lowercase_constants' => true, 'lowercase_keywords' => true, 'lowercase_static_reference' => true, 'magic_constant_casing' => true, 'method_argument_space' => ['ensure_fully_multiline' => true], 'modernize_types_casting' => true, 'multiline_comment_opening_closing' => true, 'multiline_whitespace_before_semicolons' => true, 'native_constant_invocation' => true, 'native_function_casing' => true, 'native_function_invocation' => true, 'new_with_braces' => false, 'no_alias_functions' => true, 'no_alternative_syntax' => true, 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, 'no_blank_lines_before_namespace' => true, 'no_closing_tag' => true, 'no_empty_comment' => true, 'no_empty_phpdoc' => true, 'no_empty_statement' => true, 'no_extra_blank_lines' => true, 'no_homoglyph_names' => true, 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, 'no_mixed_echo_print' => ['use' => 'print'], 'no_multiline_whitespace_around_double_arrow' => true, 'no_null_property_initialization' => true, 'no_php4_constructor' => true, 'no_short_bool_cast' => true, 'no_short_echo_tag' => true, 'no_singleline_whitespace_before_semicolons' => true, 'no_spaces_after_function_name' => true, 'no_spaces_inside_parenthesis' => true, 'no_superfluous_elseif' => true, 'no_superfluous_phpdoc_tags' => true, 'no_trailing_comma_in_list_call' => true, 'no_trailing_comma_in_singleline_array' => true, 'no_trailing_whitespace' => true, 'no_trailing_whitespace_in_comment' => true, 'no_unneeded_control_parentheses' => true, 'no_unneeded_curly_braces' => true, 'no_unneeded_final_method' => true, 'no_unreachable_default_argument_value' => true, 'no_unset_on_property' => true, 'no_unused_imports' => true, 'no_useless_else' => true, 'no_useless_return' => true, 'no_whitespace_before_comma_in_array' => true, 'no_whitespace_in_blank_line' => true, 'non_printable_character' => true, 'normalize_index_brace' => true, 'object_operator_without_whitespace' => true, 'ordered_class_elements' => [ 'order' => [ 'use_trait', 'constant_public', 'constant_protected', 'constant_private', 'property_public_static', 'property_protected_static', 'property_private_static', 'property_public', 'property_protected', 'property_private', 'method_public_static', 'construct', 'destruct', 'magic', 'phpunit', 'method_public', 'method_protected', 'method_private', 'method_protected_static', 'method_private_static', ], ], 'ordered_imports' => true, 'phpdoc_add_missing_param_annotation' => true, 'phpdoc_align' => true, 'phpdoc_annotation_without_dot' => true, 'phpdoc_indent' => true, 'phpdoc_no_access' => true, 'phpdoc_no_empty_return' => true, 'phpdoc_no_package' => true, 'phpdoc_order' => true, 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, 'phpdoc_separation' => true, 'phpdoc_single_line_var_spacing' => true, 'phpdoc_to_comment' => true, 'phpdoc_trim' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true, 'phpdoc_types' => true, 'phpdoc_types_order' => true, 'phpdoc_var_without_name' => true, 'pow_to_exponentiation' => true, 'protected_to_private' => true, 'random_api_migration' => true, 'return_assignment' => true, 'return_type_declaration' => ['space_before' => 'none'], 'self_accessor' => true, 'semicolon_after_instruction' => true, 'set_type_to_cast' => true, 'short_scalar_cast' => true, 'simplified_null_return' => true, 'single_blank_line_at_eof' => true, 'single_import_per_statement' => true, 'single_line_after_imports' => true, 'single_quote' => true, 'standardize_not_equals' => true, 'ternary_to_null_coalescing' => true, 'trailing_comma_in_multiline_array' => true, 'trim_array_spaces' => true, 'unary_operator_spaces' => true, 'visibility_required' => [ 'elements' => [ 'const', 'method', 'property', ], ], 'void_return' => true, 'whitespace_after_comma_in_array' => true, ] ) ->setFinder( PhpCsFixer\Finder::create() ->files() ->in(__DIR__ . '/src') ->in(__DIR__ . '/tests') ); environment-4.2.3/.travis.yml000066400000000000000000000010601356517660200162050ustar00rootroot00000000000000language: php php: - 7.1 - 7.2 - 7.3 - 7.4snapshot env: matrix: - DRIVER="phpdbg" - DRIVER="xdebug" before_install: - composer clear-cache install: - travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest script: - if [[ "$DRIVER" = 'phpdbg' ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi - if [[ "$DRIVER" != 'phpdbg' ]]; then vendor/bin/phpunit --coverage-clover=coverage.xml; fi after_success: - bash <(curl -s https://codecov.io/bash) notifications: email: false environment-4.2.3/ChangeLog.md000066400000000000000000000074741356517660200162640ustar00rootroot00000000000000# Changes in sebastianbergmann/environment All notable changes in `sebastianbergmann/environment` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. ## [4.2.3] - 2019-11-20 ### Changed * Implemented [#50](https://github.com/sebastianbergmann/environment/pull/50): Windows improvements to console capabilities ### Fixed * Fixed [#49](https://github.com/sebastianbergmann/environment/issues/49): Detection how OpCache handles docblocks does not work correctly when PHPDBG is used ## [4.2.2] - 2019-05-05 ### Fixed * Fixed [#44](https://github.com/sebastianbergmann/environment/pull/44): `TypeError` in `Console::getNumberOfColumnsInteractive()` ## [4.2.1] - 2019-04-25 ### Fixed * Fixed an issue in `Runtime::getCurrentSettings()` ## [4.2.0] - 2019-04-25 ### Added * Implemented [#36](https://github.com/sebastianbergmann/environment/pull/36): `Runtime::getCurrentSettings()` ## [4.1.0] - 2019-02-01 ### Added * Implemented `Runtime::getNameWithVersionAndCodeCoverageDriver()` method * Implemented [#34](https://github.com/sebastianbergmann/environment/pull/34): Support for PCOV extension ## [4.0.2] - 2019-01-28 ### Fixed * Fixed [#33](https://github.com/sebastianbergmann/environment/issues/33): `Runtime::discardsComments()` returns true too eagerly ### Removed * Removed support for Zend Optimizer+ in `Runtime::discardsComments()` ## [4.0.1] - 2018-11-25 ### Fixed * Fixed [#31](https://github.com/sebastianbergmann/environment/issues/31): Regressions in `Console` class ## [4.0.0] - 2018-10-23 [YANKED] ### Fixed * Fixed [#25](https://github.com/sebastianbergmann/environment/pull/25): `Console::hasColorSupport()` does not work on Windows ### Removed * This component is no longer supported on PHP 7.0 ## [3.1.0] - 2017-07-01 ### Added * Implemented [#21](https://github.com/sebastianbergmann/environment/issues/21): Equivalent of `PHP_OS_FAMILY` (for PHP < 7.2) ## [3.0.4] - 2017-06-20 ### Fixed * Fixed [#20](https://github.com/sebastianbergmann/environment/pull/20): PHP 7 mode of HHVM not forced ## [3.0.3] - 2017-05-18 ### Fixed * Fixed [#18](https://github.com/sebastianbergmann/environment/issues/18): `Uncaught TypeError: preg_match() expects parameter 2 to be string, null given` ## [3.0.2] - 2017-04-21 ### Fixed * Fixed [#17](https://github.com/sebastianbergmann/environment/issues/17): `Uncaught TypeError: trim() expects parameter 1 to be string, boolean given` ## [3.0.1] - 2017-04-21 ### Fixed * Fixed inverted logic in `Runtime::discardsComments()` ## [3.0.0] - 2017-04-21 ### Added * Implemented `Runtime::discardsComments()` for querying whether the PHP runtime discards annotations ### Removed * This component is no longer supported on PHP 5.6 [4.2.3]: https://github.com/sebastianbergmann/phpunit/compare/4.2.2...4.2.3 [4.2.2]: https://github.com/sebastianbergmann/phpunit/compare/4.2.1...4.2.2 [4.2.1]: https://github.com/sebastianbergmann/phpunit/compare/4.2.0...4.2.1 [4.2.0]: https://github.com/sebastianbergmann/phpunit/compare/4.1.0...4.2.0 [4.1.0]: https://github.com/sebastianbergmann/phpunit/compare/4.0.2...4.1.0 [4.0.2]: https://github.com/sebastianbergmann/phpunit/compare/4.0.1...4.0.2 [4.0.1]: https://github.com/sebastianbergmann/phpunit/compare/66691f8e2dc4641909166b275a9a4f45c0e89092...4.0.1 [4.0.0]: https://github.com/sebastianbergmann/phpunit/compare/3.1.0...66691f8e2dc4641909166b275a9a4f45c0e89092 [3.1.0]: https://github.com/sebastianbergmann/phpunit/compare/3.0...3.1.0 [3.0.4]: https://github.com/sebastianbergmann/phpunit/compare/3.0.3...3.0.4 [3.0.3]: https://github.com/sebastianbergmann/phpunit/compare/3.0.2...3.0.3 [3.0.2]: https://github.com/sebastianbergmann/phpunit/compare/3.0.1...3.0.2 [3.0.1]: https://github.com/sebastianbergmann/phpunit/compare/3.0.0...3.0.1 [3.0.0]: https://github.com/sebastianbergmann/phpunit/compare/2.0...3.0.0 environment-4.2.3/LICENSE000066400000000000000000000030241356517660200151030ustar00rootroot00000000000000sebastian/environment Copyright (c) 2014-2019, Sebastian Bergmann . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Sebastian Bergmann nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. environment-4.2.3/README.md000066400000000000000000000016751356517660200153670ustar00rootroot00000000000000# sebastian/environment This component provides functionality that helps writing PHP code that has runtime-specific (PHP / HHVM) execution paths. [![Latest Stable Version](https://img.shields.io/packagist/v/sebastian/environment.svg?style=flat-square)](https://packagist.org/packages/sebastian/environment) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net/) [![Build Status](https://travis-ci.org/sebastianbergmann/environment.svg?branch=master)](https://travis-ci.org/sebastianbergmann/environment) ## Installation You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/): composer require sebastian/environment If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency: composer require --dev sebastian/environment environment-4.2.3/build.xml000066400000000000000000000012701356517660200157200ustar00rootroot00000000000000 environment-4.2.3/composer.json000066400000000000000000000015121356517660200166200ustar00rootroot00000000000000{ "name": "sebastian/environment", "description": "Provides functionality to handle HHVM/PHP environments", "keywords": ["environment","hhvm","xdebug"], "homepage": "http://www.github.com/sebastianbergmann/environment", "license": "BSD-3-Clause", "authors": [ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" } ], "config": { "optimize-autoloader": true, "sort-packages": true }, "prefer-stable": true, "require": { "php": "^7.1" }, "require-dev": { "phpunit/phpunit": "^7.5" }, "suggest": { "ext-posix": "*" }, "autoload": { "classmap": [ "src/" ] }, "extra": { "branch-alias": { "dev-master": "4.2-dev" } } } environment-4.2.3/phpunit.xml000066400000000000000000000013031356517660200163050ustar00rootroot00000000000000 tests src environment-4.2.3/src/000077500000000000000000000000001356517660200146665ustar00rootroot00000000000000environment-4.2.3/src/Console.php000066400000000000000000000110251356517660200170000ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Environment; final class Console { /** * @var int */ public const STDIN = 0; /** * @var int */ public const STDOUT = 1; /** * @var int */ public const STDERR = 2; /** * Returns true if STDOUT supports colorization. * * This code has been copied and adapted from * Symfony\Component\Console\Output\StreamOutput. */ public function hasColorSupport(): bool { if ('Hyper' === \getenv('TERM_PROGRAM')) { return true; } if ($this->isWindows()) { // @codeCoverageIgnoreStart return (\defined('STDOUT') && \function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support(\STDOUT)) || false !== \getenv('ANSICON') || 'ON' === \getenv('ConEmuANSI') || 'xterm' === \getenv('TERM'); // @codeCoverageIgnoreEnd } if (!\defined('STDOUT')) { // @codeCoverageIgnoreStart return false; // @codeCoverageIgnoreEnd } return $this->isInteractive(\STDOUT); } /** * Returns the number of columns of the terminal. * * @codeCoverageIgnore */ public function getNumberOfColumns(): int { if (!$this->isInteractive(\defined('STDIN') ? \STDIN : self::STDIN)) { return 80; } if ($this->isWindows()) { return $this->getNumberOfColumnsWindows(); } return $this->getNumberOfColumnsInteractive(); } /** * Returns if the file descriptor is an interactive terminal or not. * * Normally, we want to use a resource as a parameter, yet sadly it's not always awailable, * eg when running code in interactive console (`php -a`), STDIN/STDOUT/STDERR constants are not defined. * * @param int|resource $fileDescriptor */ public function isInteractive($fileDescriptor = self::STDOUT): bool { if (\is_resource($fileDescriptor)) { // These functions require a descriptor that is a real resource, not a numeric ID of it if (\function_exists('stream_isatty') && @\stream_isatty($fileDescriptor)) { return true; } $stat = @\fstat(\STDOUT); // Check if formatted mode is S_IFCHR return $stat ? 0020000 === ($stat['mode'] & 0170000) : false; } return \function_exists('posix_isatty') && @\posix_isatty($fileDescriptor); } private function isWindows(): bool { return \DIRECTORY_SEPARATOR === '\\'; } /** * @codeCoverageIgnore */ private function getNumberOfColumnsInteractive(): int { if (\function_exists('shell_exec') && \preg_match('#\d+ (\d+)#', \shell_exec('stty size') ?: '', $match) === 1) { if ((int) $match[1] > 0) { return (int) $match[1]; } } if (\function_exists('shell_exec') && \preg_match('#columns = (\d+);#', \shell_exec('stty') ?: '', $match) === 1) { if ((int) $match[1] > 0) { return (int) $match[1]; } } return 80; } /** * @codeCoverageIgnore */ private function getNumberOfColumnsWindows(): int { $ansicon = \getenv('ANSICON'); $columns = 80; if (\is_string($ansicon) && \preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', \trim($ansicon), $matches)) { $columns = $matches[1]; } elseif (\function_exists('proc_open')) { $process = \proc_open( 'mode CON', [ 1 => ['pipe', 'w'], 2 => ['pipe', 'w'], ], $pipes, null, null, ['suppress_errors' => true] ); if (\is_resource($process)) { $info = \stream_get_contents($pipes[1]); \fclose($pipes[1]); \fclose($pipes[2]); \proc_close($process); if (\preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) { $columns = $matches[2]; } } } return $columns - 1; } } environment-4.2.3/src/OperatingSystem.php000066400000000000000000000022051356517660200205330ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Environment; final class OperatingSystem { /** * Returns PHP_OS_FAMILY (if defined (which it is on PHP >= 7.2)). * Returns a string (compatible with PHP_OS_FAMILY) derived from PHP_OS otherwise. */ public function getFamily(): string { if (\defined('PHP_OS_FAMILY')) { return \PHP_OS_FAMILY; } if (\DIRECTORY_SEPARATOR === '\\') { return 'Windows'; } switch (\PHP_OS) { case 'Darwin': return 'Darwin'; case 'DragonFly': case 'FreeBSD': case 'NetBSD': case 'OpenBSD': return 'BSD'; case 'Linux': return 'Linux'; case 'SunOS': return 'Solaris'; default: return 'Unknown'; } } } environment-4.2.3/src/Runtime.php000066400000000000000000000156321356517660200170310ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Environment; /** * Utility class for HHVM/PHP environment handling. */ final class Runtime { /** * @var string */ private static $binary; /** * Returns true when Xdebug or PCOV is available or * the runtime used is PHPDBG. */ public function canCollectCodeCoverage(): bool { return $this->hasXdebug() || $this->hasPCOV() || $this->hasPHPDBGCodeCoverage(); } /** * Returns true when Zend OPcache is loaded, enabled, and is configured to discard comments. */ public function discardsComments(): bool { if (!\extension_loaded('Zend OPcache')) { return false; } if (\ini_get('opcache.save_comments') !== '0') { return false; } if ((\PHP_SAPI === 'cli' || \PHP_SAPI === 'phpdbg') && \ini_get('opcache.enable_cli') === '1') { return true; } if (\PHP_SAPI !== 'cli' && \PHP_SAPI !== 'phpdbg' && \ini_get('opcache.enable') === '1') { return true; } return false; } /** * Returns the path to the binary of the current runtime. * Appends ' --php' to the path when the runtime is HHVM. */ public function getBinary(): string { // HHVM if (self::$binary === null && $this->isHHVM()) { // @codeCoverageIgnoreStart if ((self::$binary = \getenv('PHP_BINARY')) === false) { self::$binary = \PHP_BINARY; } self::$binary = \escapeshellarg(self::$binary) . ' --php' . ' -d hhvm.php7.all=1'; // @codeCoverageIgnoreEnd } if (self::$binary === null && \PHP_BINARY !== '') { self::$binary = \escapeshellarg(\PHP_BINARY); } if (self::$binary === null) { // @codeCoverageIgnoreStart $possibleBinaryLocations = [ \PHP_BINDIR . '/php', \PHP_BINDIR . '/php-cli.exe', \PHP_BINDIR . '/php.exe', ]; foreach ($possibleBinaryLocations as $binary) { if (\is_readable($binary)) { self::$binary = \escapeshellarg($binary); break; } } // @codeCoverageIgnoreEnd } if (self::$binary === null) { // @codeCoverageIgnoreStart self::$binary = 'php'; // @codeCoverageIgnoreEnd } return self::$binary; } public function getNameWithVersion(): string { return $this->getName() . ' ' . $this->getVersion(); } public function getNameWithVersionAndCodeCoverageDriver(): string { if (!$this->canCollectCodeCoverage() || $this->hasPHPDBGCodeCoverage()) { return $this->getNameWithVersion(); } if ($this->hasXdebug()) { return \sprintf( '%s with Xdebug %s', $this->getNameWithVersion(), \phpversion('xdebug') ); } if ($this->hasPCOV()) { return \sprintf( '%s with PCOV %s', $this->getNameWithVersion(), \phpversion('pcov') ); } } public function getName(): string { if ($this->isHHVM()) { // @codeCoverageIgnoreStart return 'HHVM'; // @codeCoverageIgnoreEnd } if ($this->isPHPDBG()) { // @codeCoverageIgnoreStart return 'PHPDBG'; // @codeCoverageIgnoreEnd } return 'PHP'; } public function getVendorUrl(): string { if ($this->isHHVM()) { // @codeCoverageIgnoreStart return 'http://hhvm.com/'; // @codeCoverageIgnoreEnd } return 'https://secure.php.net/'; } public function getVersion(): string { if ($this->isHHVM()) { // @codeCoverageIgnoreStart return HHVM_VERSION; // @codeCoverageIgnoreEnd } return \PHP_VERSION; } /** * Returns true when the runtime used is PHP and Xdebug is loaded. */ public function hasXdebug(): bool { return ($this->isPHP() || $this->isHHVM()) && \extension_loaded('xdebug'); } /** * Returns true when the runtime used is HHVM. */ public function isHHVM(): bool { return \defined('HHVM_VERSION'); } /** * Returns true when the runtime used is PHP without the PHPDBG SAPI. */ public function isPHP(): bool { return !$this->isHHVM() && !$this->isPHPDBG(); } /** * Returns true when the runtime used is PHP with the PHPDBG SAPI. */ public function isPHPDBG(): bool { return \PHP_SAPI === 'phpdbg' && !$this->isHHVM(); } /** * Returns true when the runtime used is PHP with the PHPDBG SAPI * and the phpdbg_*_oplog() functions are available (PHP >= 7.0). */ public function hasPHPDBGCodeCoverage(): bool { return $this->isPHPDBG(); } /** * Returns true when the runtime used is PHP with PCOV loaded and enabled */ public function hasPCOV(): bool { return $this->isPHP() && \extension_loaded('pcov') && \ini_get('pcov.enabled'); } /** * Parses the loaded php.ini file (if any) as well as all * additional php.ini files from the additional ini dir for * a list of all configuration settings loaded from files * at startup. Then checks for each php.ini setting passed * via the `$values` parameter whether this setting has * been changed at runtime. Returns an array of strings * where each string has the format `key=value` denoting * the name of a changed php.ini setting with its new value. * * @return string[] */ public function getCurrentSettings(array $values): array { $diff = []; $files = []; if ($file = \php_ini_loaded_file()) { $files[] = $file; } if ($scanned = \php_ini_scanned_files()) { $files = \array_merge( $files, \array_map( 'trim', \explode(",\n", $scanned) ) ); } foreach ($files as $ini) { $config = \parse_ini_file($ini, true); foreach ($values as $value) { $set = \ini_get($value); if (isset($config[$value]) && $set != $config[$value]) { $diff[] = \sprintf('%s=%s', $value, $set); } } } return $diff; } } environment-4.2.3/tests/000077500000000000000000000000001356517660200152415ustar00rootroot00000000000000environment-4.2.3/tests/ConsoleTest.php000066400000000000000000000034051356517660200202160ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Environment; use PHPUnit\Framework\TestCase; /** * @covers \SebastianBergmann\Environment\Console */ final class ConsoleTest extends TestCase { /** * @var \SebastianBergmann\Environment\Console */ private $console; protected function setUp(): void { $this->console = new Console; } /** * @todo Now that this component is PHP 7-only and uses return type declarations * this test makes even less sense than before */ public function testCanDetectIfStdoutIsInteractiveByDefault(): void { $this->assertIsBool($this->console->isInteractive()); } /** * @todo Now that this component is PHP 7-only and uses return type declarations * this test makes even less sense than before */ public function testCanDetectIfFileDescriptorIsInteractive(): void { $this->assertIsBool($this->console->isInteractive(\STDOUT)); } /** * @todo Now that this component is PHP 7-only and uses return type declarations * this test makes even less sense than before */ public function testCanDetectColorSupport(): void { $this->assertIsBool($this->console->hasColorSupport()); } /** * @todo Now that this component is PHP 7-only and uses return type declarations * this test makes even less sense than before */ public function testCanDetectNumberOfColumns(): void { $this->assertIsInt($this->console->getNumberOfColumns()); } } environment-4.2.3/tests/OperatingSystemTest.php000066400000000000000000000026021356517660200217470ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Environment; use PHPUnit\Framework\TestCase; /** * @covers \SebastianBergmann\Environment\OperatingSystem */ final class OperatingSystemTest extends TestCase { /** * @var \SebastianBergmann\Environment\OperatingSystem */ private $os; protected function setUp(): void { $this->os = new OperatingSystem; } /** * @requires OS Linux */ public function testFamilyCanBeRetrieved(): void { $this->assertEquals('Linux', $this->os->getFamily()); } /** * @requires OS Darwin */ public function testFamilyReturnsDarwinWhenRunningOnDarwin(): void { $this->assertEquals('Darwin', $this->os->getFamily()); } /** * @requires OS Windows */ public function testGetFamilyReturnsWindowsWhenRunningOnWindows(): void { $this->assertSame('Windows', $this->os->getFamily()); } /** * @requires PHP 7.2.0 */ public function testGetFamilyReturnsPhpOsFamilyWhenRunningOnPhp72AndGreater(): void { $this->assertSame(\PHP_OS_FAMILY, $this->os->getFamily()); } } environment-4.2.3/tests/RuntimeTest.php000066400000000000000000000076011356517660200202410ustar00rootroot00000000000000 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\Environment; use PHPUnit\Framework\TestCase; /** * @covers \SebastianBergmann\Environment\Runtime */ final class RuntimeTest extends TestCase { /** * @var \SebastianBergmann\Environment\Runtime */ private $env; protected function setUp(): void { $this->env = new Runtime; } /** * @requires extension xdebug */ public function testCanCollectCodeCoverageWhenXdebugExtensionIsEnabled(): void { $this->assertTrue($this->env->canCollectCodeCoverage()); } /** * @requires extension pcov */ public function testCanCollectCodeCoverageWhenPcovExtensionIsEnabled(): void { $this->assertTrue($this->env->canCollectCodeCoverage()); } public function testCanCollectCodeCoverageWhenRunningOnPhpdbg(): void { $this->markTestSkippedWhenNotRunningOnPhpdbg(); $this->assertTrue($this->env->canCollectCodeCoverage()); } public function testBinaryCanBeRetrieved(): void { $this->assertNotEmpty($this->env->getBinary()); } /** * @requires PHP */ public function testIsHhvmReturnsFalseWhenRunningOnPhp(): void { $this->assertFalse($this->env->isHHVM()); } /** * @requires PHP */ public function testIsPhpReturnsTrueWhenRunningOnPhp(): void { $this->markTestSkippedWhenRunningOnPhpdbg(); $this->assertTrue($this->env->isPHP()); } /** * @requires extension pcov */ public function testPCOVCanBeDetected(): void { $this->assertTrue($this->env->hasPCOV()); } public function testPhpdbgCanBeDetected(): void { $this->markTestSkippedWhenNotRunningOnPhpdbg(); $this->assertTrue($this->env->hasPHPDBGCodeCoverage()); } /** * @requires extension xdebug */ public function testXdebugCanBeDetected(): void { $this->markTestSkippedWhenRunningOnPhpdbg(); $this->assertTrue($this->env->hasXdebug()); } public function testNameAndVersionCanBeRetrieved(): void { $this->assertNotEmpty($this->env->getNameWithVersion()); } public function testGetNameReturnsPhpdbgWhenRunningOnPhpdbg(): void { $this->markTestSkippedWhenNotRunningOnPhpdbg(); $this->assertSame('PHPDBG', $this->env->getName()); } /** * @requires PHP */ public function testGetNameReturnsPhpdbgWhenRunningOnPhp(): void { $this->markTestSkippedWhenRunningOnPhpdbg(); $this->assertSame('PHP', $this->env->getName()); } public function testNameAndCodeCoverageDriverCanBeRetrieved(): void { $this->assertNotEmpty($this->env->getNameWithVersionAndCodeCoverageDriver()); } /** * @requires PHP */ public function testGetVersionReturnsPhpVersionWhenRunningPhp(): void { $this->assertSame(\PHP_VERSION, $this->env->getVersion()); } /** * @requires PHP */ public function testGetVendorUrlReturnsPhpDotNetWhenRunningPhp(): void { $this->assertSame('https://secure.php.net/', $this->env->getVendorUrl()); } private function markTestSkippedWhenNotRunningOnPhpdbg(): void { if ($this->isRunningOnPhpdbg()) { return; } $this->markTestSkipped('PHPDBG is required.'); } private function markTestSkippedWhenRunningOnPhpdbg(): void { if (!$this->isRunningOnPhpdbg()) { return; } $this->markTestSkipped('Cannot run on PHPDBG'); } private function isRunningOnPhpdbg(): bool { return \PHP_SAPI === 'phpdbg'; } }