first commit

This commit is contained in:
root
2022-03-06 11:49:27 +00:00
commit 1984e55837
1387 changed files with 121949 additions and 0 deletions

View File

@ -0,0 +1,4 @@
/.idea
/vendor
/composer.lock
/composer.phar

View File

@ -0,0 +1,16 @@
language: php
sudo: false
before_install:
- composer self-update
install:
- travis_retry composer install --no-interaction --prefer-source
php:
- 5.6
- hhvm
notifications:
email: false

33
vendor/sebastian/environment/LICENSE vendored Normal file
View File

@ -0,0 +1,33 @@
Environment
Copyright (c) 2014-2015, Sebastian Bergmann <sebastian@phpunit.de>.
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.

72
vendor/sebastian/environment/README.md vendored Normal file
View File

@ -0,0 +1,72 @@
# Environment
This component provides functionality that helps writing PHP code that has runtime-specific (PHP / HHVM) execution paths.
[![Latest Stable Version](https://poser.pugx.org/sebastian/environment/v/stable.png)](https://packagist.org/packages/sebastian/environment)
[![Build Status](https://travis-ci.org/sebastianbergmann/environment.png?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
## Usage
```php
<?php
use SebastianBergmann\Environment\Runtime;
$runtime = new Runtime;
var_dump($runtime->getNameWithVersion());
var_dump($runtime->getName());
var_dump($runtime->getVersion());
var_dump($runtime->getBinary());
var_dump($runtime->isHHVM());
var_dump($runtime->isPHP());
var_dump($runtime->hasXdebug());
var_dump($runtime->canCollectCodeCoverage());
```
### Output on PHP
$ php --version
PHP 5.5.8 (cli) (built: Jan 9 2014 08:33:30)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
$ php example.php
string(9) "PHP 5.5.8"
string(3) "PHP"
string(5) "5.5.8"
string(14) "'/usr/bin/php'"
bool(false)
bool(true)
bool(true)
bool(true)
### Output on HHVM
$ hhvm --version
HipHop VM 2.4.0-dev (rel)
Compiler: heads/master-0-ga98e57cabee7e7f0d14493ab17d5c7ab0157eb98
Repo schema: 8d6e69287c41c1f09bb4d327421720d1922cfc67
$ hhvm example.php
string(14) "HHVM 2.4.0-dev"
string(4) "HHVM"
string(9) "2.4.0-dev"
string(42) "'/usr/local/src/hhvm/hphp/hhvm/hhvm' --php"
bool(true)
bool(false)
bool(false)
bool(true)

26
vendor/sebastian/environment/build.xml vendored Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="environment">
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/vendor"/>
<delete file="${basedir}/composer.lock"/>
</target>
<target name="composer" depends="clean" description="Install dependencies with Composer">
<tstamp>
<format property="thirty.days.ago" pattern="MM/dd/yyyy hh:mm aa" offset="-30" unit="day"/>
</tstamp>
<delete>
<fileset dir="${basedir}">
<include name="composer.phar" />
<date datetime="${thirty.days.ago}" when="before"/>
</fileset>
</delete>
<get src="https://getcomposer.org/composer.phar" dest="${basedir}/composer.phar" skipexisting="true"/>
<exec executable="php">
<arg value="composer.phar"/>
<arg value="install"/>
</exec>
</target>
</project>

View File

@ -0,0 +1,30 @@
{
"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"
}
],
"prefer-stable": true,
"require": {
"php": "^5.6 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0"
},
"autoload": {
"classmap": [
"src/"
]
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.4/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite>
<directory suffix="Test.php">tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -0,0 +1,113 @@
<?php
/*
* This file is part of the Environment package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Environment;
/**
*/
class Console
{
const STDIN = 0;
const STDOUT = 1;
const STDERR = 2;
/**
* Returns true if STDOUT supports colorization.
*
* This code has been copied and adapted from
* Symfony\Component\Console\Output\OutputStream.
*
* @return bool
*/
public function hasColorSupport()
{
if (DIRECTORY_SEPARATOR == '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
}
if (!defined('STDOUT')) {
return false;
}
return $this->isInteractive(STDOUT);
}
/**
* Returns the number of columns of the terminal.
*
* @return int
*/
public function getNumberOfColumns()
{
if (DIRECTORY_SEPARATOR == '\\') {
$columns = 80;
if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('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;
}
if (!$this->isInteractive(self::STDIN)) {
return 80;
}
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;
}
/**
* Returns if the file descriptor is an interactive terminal or not.
*
* @param int|resource $fileDescriptor
*
* @return bool
*/
public function isInteractive($fileDescriptor = self::STDOUT)
{
return function_exists('posix_isatty') && @posix_isatty($fileDescriptor);
}
}

View File

@ -0,0 +1,194 @@
<?php
/*
* This file is part of the Environment package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* 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.
*/
class Runtime
{
/**
* @var string
*/
private static $binary;
/**
* Returns true when Xdebug is supported or
* the runtime used is PHPDBG (PHP >= 7.0).
*
* @return bool
*/
public function canCollectCodeCoverage()
{
return $this->hasXdebug() || $this->hasPHPDBGCodeCoverage();
}
/**
* Returns the path to the binary of the current runtime.
* Appends ' --php' to the path when the runtime is HHVM.
*
* @return string
*/
public function getBinary()
{
// HHVM
if (self::$binary === null && $this->isHHVM()) {
if ((self::$binary = getenv('PHP_BINARY')) === false) {
self::$binary = PHP_BINARY;
}
self::$binary = escapeshellarg(self::$binary) . ' --php';
}
// PHP >= 5.4.0
if (self::$binary === null && defined('PHP_BINARY')) {
if (PHP_BINARY !== '') {
self::$binary = escapeshellarg(PHP_BINARY);
}
}
// PHP < 5.4.0
if (self::$binary === null) {
if (PHP_SAPI == 'cli' && isset($_SERVER['_'])) {
if (strpos($_SERVER['_'], 'phpunit') !== false) {
$file = file($_SERVER['_']);
if (strpos($file[0], ' ') !== false) {
$tmp = explode(' ', $file[0]);
self::$binary = escapeshellarg(trim($tmp[1]));
} else {
self::$binary = escapeshellarg(ltrim(trim($file[0]), '#!'));
}
} elseif (strpos(basename($_SERVER['_']), 'php') !== false) {
self::$binary = escapeshellarg($_SERVER['_']);
}
}
}
if (self::$binary === null) {
$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;
}
}
}
if (self::$binary === null) {
self::$binary = 'php';
}
return self::$binary;
}
/**
* @return string
*/
public function getNameWithVersion()
{
return $this->getName() . ' ' . $this->getVersion();
}
/**
* @return string
*/
public function getName()
{
if ($this->isHHVM()) {
return 'HHVM';
} elseif ($this->isPHPDBG()) {
return 'PHPDBG';
} else {
return 'PHP';
}
}
/**
* @return string
*/
public function getVendorUrl()
{
if ($this->isHHVM()) {
return 'http://hhvm.com/';
} else {
return 'https://secure.php.net/';
}
}
/**
* @return string
*/
public function getVersion()
{
if ($this->isHHVM()) {
return HHVM_VERSION;
} else {
return PHP_VERSION;
}
}
/**
* Returns true when the runtime used is PHP and Xdebug is loaded.
*
* @return bool
*/
public function hasXdebug()
{
return ($this->isPHP() || $this->isHHVM()) && extension_loaded('xdebug');
}
/**
* Returns true when the runtime used is HHVM.
*
* @return bool
*/
public function isHHVM()
{
return defined('HHVM_VERSION');
}
/**
* Returns true when the runtime used is PHP without the PHPDBG SAPI.
*
* @return bool
*/
public function isPHP()
{
return !$this->isHHVM() && !$this->isPHPDBG();
}
/**
* Returns true when the runtime used is PHP with the PHPDBG SAPI.
*
* @return bool
*/
public function isPHPDBG()
{
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).
*
* @return bool
*/
public function hasPHPDBGCodeCoverage()
{
return $this->isPHPDBG() && function_exists('phpdbg_start_oplog');
}
}

View File

@ -0,0 +1,62 @@
<?php
/*
* This file is part of the Environment package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* 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;
class ConsoleTest extends PHPUnit_Framework_TestCase
{
/**
* @var \SebastianBergmann\Environment\Console
*/
private $console;
protected function setUp()
{
$this->console = new Console;
}
/**
* @covers \SebastianBergmann\Environment\Console::isInteractive
*/
public function testCanDetectIfStdoutIsInteractiveByDefault()
{
$this->assertInternalType('boolean', $this->console->isInteractive());
}
/**
* @covers \SebastianBergmann\Environment\Console::isInteractive
*/
public function testCanDetectIfFileDescriptorIsInteractive()
{
$this->assertInternalType('boolean', $this->console->isInteractive(STDOUT));
}
/**
* @covers \SebastianBergmann\Environment\Console::hasColorSupport
*
* @uses \SebastianBergmann\Environment\Console::isInteractive
*/
public function testCanDetectColorSupport()
{
$this->assertInternalType('boolean', $this->console->hasColorSupport());
}
/**
* @covers \SebastianBergmann\Environment\Console::getNumberOfColumns
*
* @uses \SebastianBergmann\Environment\Console::isInteractive
*/
public function testCanDetectNumberOfColumns()
{
$this->assertInternalType('integer', $this->console->getNumberOfColumns());
}
}

View File

@ -0,0 +1,120 @@
<?php
/*
* This file is part of the Environment package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* 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;
class RuntimeTest extends PHPUnit_Framework_TestCase
{
/**
* @var \SebastianBergmann\Environment\Runtime
*/
private $env;
protected function setUp()
{
$this->env = new Runtime;
}
/**
* @covers \SebastianBergmann\Environment\Runtime::canCollectCodeCoverage
*
* @uses \SebastianBergmann\Environment\Runtime::hasXdebug
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
* @uses \SebastianBergmann\Environment\Runtime::isPHP
*/
public function testAbilityToCollectCodeCoverageCanBeAssessed()
{
$this->assertInternalType('boolean', $this->env->canCollectCodeCoverage());
}
/**
* @covers \SebastianBergmann\Environment\Runtime::getBinary
*
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
*/
public function testBinaryCanBeRetrieved()
{
$this->assertInternalType('string', $this->env->getBinary());
}
/**
* @covers \SebastianBergmann\Environment\Runtime::isHHVM
*/
public function testCanBeDetected()
{
$this->assertInternalType('boolean', $this->env->isHHVM());
}
/**
* @covers \SebastianBergmann\Environment\Runtime::isPHP
*
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
*/
public function testCanBeDetected2()
{
$this->assertInternalType('boolean', $this->env->isPHP());
}
/**
* @covers \SebastianBergmann\Environment\Runtime::hasXdebug
*
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
* @uses \SebastianBergmann\Environment\Runtime::isPHP
*/
public function testXdebugCanBeDetected()
{
$this->assertInternalType('boolean', $this->env->hasXdebug());
}
/**
* @covers \SebastianBergmann\Environment\Runtime::getNameWithVersion
*
* @uses \SebastianBergmann\Environment\Runtime::getName
* @uses \SebastianBergmann\Environment\Runtime::getVersion
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
* @uses \SebastianBergmann\Environment\Runtime::isPHP
*/
public function testNameAndVersionCanBeRetrieved()
{
$this->assertInternalType('string', $this->env->getNameWithVersion());
}
/**
* @covers \SebastianBergmann\Environment\Runtime::getName
*
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
*/
public function testNameCanBeRetrieved()
{
$this->assertInternalType('string', $this->env->getName());
}
/**
* @covers \SebastianBergmann\Environment\Runtime::getVersion
*
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
*/
public function testVersionCanBeRetrieved()
{
$this->assertInternalType('string', $this->env->getVersion());
}
/**
* @covers \SebastianBergmann\Environment\Runtime::getVendorUrl
*
* @uses \SebastianBergmann\Environment\Runtime::isHHVM
*/
public function testVendorUrlCanBeRetrieved()
{
$this->assertInternalType('string', $this->env->getVendorUrl());
}
}