updated packages

This commit is contained in:
2019-05-18 09:06:43 +00:00
parent 901d16349e
commit e9487fa58a
2025 changed files with 30366 additions and 49653 deletions

View File

@@ -2,4 +2,5 @@
/composer.lock
/vendor
/.php_cs.cache
/.phpunit.result.cache
/from.txt.orig

View File

@@ -3,6 +3,7 @@ language: php
php:
- 7.1
- 7.2
- 7.3
- master
sudo: false

View File

@@ -2,6 +2,12 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [3.0.2] - 2019-02-04
### Changed
* `Chunk::setLines()` now ensures that the `$lines` array only contains `Line` objects
## [3.0.1] - 2018-06-10
### Fixed
@@ -40,6 +46,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* This component is no longer supported on PHP 5.6
[3.0.2]: https://github.com/sebastianbergmann/diff/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/sebastianbergmann/diff/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/sebastianbergmann/diff/compare/2.0...3.0.0
[2.0.1]: https://github.com/sebastianbergmann/diff/compare/c341c98ce083db77f896a0aa64f5ee7652915970...2.0.1

View File

@@ -1,6 +1,6 @@
sebastian/diff
Copyright (c) 2002-2018, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2002-2019, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -18,7 +18,7 @@
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.5 || ^8.0",
"symfony/process": "^2 || ^3.3 || ^4"
},
"autoload": {

View File

@@ -33,7 +33,7 @@ final class Chunk
private $endRange;
/**
* @var array
* @var Line[]
*/
private $lines;
@@ -66,13 +66,25 @@ final class Chunk
return $this->endRange;
}
/**
* @return Line[]
*/
public function getLines(): array
{
return $this->lines;
}
/**
* @param Line[] $lines
*/
public function setLines(array $lines): void
{
foreach ($lines as $line) {
if (!$line instanceof Line) {
throw new InvalidArgumentException;
}
}
$this->lines = $lines;
}
}

View File

@@ -27,6 +27,11 @@ final class ChunkTest extends TestCase
$this->chunk = new Chunk;
}
public function testHasInitiallyNoLines(): void
{
$this->assertSame([], $this->chunk->getLines());
}
public function testCanBeCreatedWithoutArguments(): void
{
$this->assertInstanceOf(Chunk::class, $this->chunk);
@@ -59,10 +64,10 @@ final class ChunkTest extends TestCase
public function testLinesCanBeSet(): void
{
$this->assertSame([], $this->chunk->getLines());
$lines = [new Line(Line::ADDED, 'added'), new Line(Line::REMOVED, 'removed')];
$testValue = ['line0', 'line1'];
$this->chunk->setLines($testValue);
$this->assertSame($testValue, $this->chunk->getLines());
$this->chunk->setLines($lines);
$this->assertSame($lines, $this->chunk->getLines());
}
}

View File

@@ -426,24 +426,6 @@ EOF
];
}
public function testConstructorNull(): void
{
$this->assertAttributeInstanceOf(
UnifiedDiffOutputBuilder::class,
'outputBuilder',
new Differ(null)
);
}
public function testConstructorString(): void
{
$this->assertAttributeInstanceOf(
UnifiedDiffOutputBuilder::class,
'outputBuilder',
new Differ("--- Original\n+++ New\n")
);
}
public function testConstructorInvalidArgInt(): void
{
$this->expectException(InvalidArgumentException::class);

View File

@@ -190,7 +190,7 @@ abstract class LongestCommonSubsequenceTest extends TestCase
{
$diff = $this->implementation->calculate(['5'], ['05']);
$this->assertInternalType('array', $diff);
$this->assertIsArray($diff);
$this->assertCount(0, $diff);
}

View File

@@ -38,12 +38,10 @@ final class ParserTest extends TestCase
$diffs = $this->parser->parse($content);
$this->assertInternalType('array', $diffs);
$this->assertContainsOnlyInstancesOf(Diff::class, $diffs);
$this->assertCount(1, $diffs);
$chunks = $diffs[0]->getChunks();
$this->assertInternalType('array', $chunks);
$this->assertContainsOnlyInstancesOf(Chunk::class, $chunks);
$this->assertCount(1, $chunks);
@@ -85,13 +83,11 @@ index abcdefg..abcdefh 100644
-B
END;
$diffs = $this->parser->parse($content);
$this->assertInternalType('array', $diffs);
$this->assertContainsOnlyInstancesOf(Diff::class, $diffs);
$this->assertCount(1, $diffs);
$chunks = $diffs[0]->getChunks();
$this->assertInternalType('array', $chunks);
$this->assertContainsOnlyInstancesOf(Chunk::class, $chunks);
$this->assertCount(1, $chunks);
@@ -102,7 +98,6 @@ END;
$this->assertSame(8, $chunk->getEndRange());
$lines = $chunk->getLines();
$this->assertInternalType('array', $lines);
$this->assertContainsOnlyInstancesOf(Line::class, $lines);
$this->assertCount(2, $lines);

View File

@@ -4,19 +4,22 @@ php:
- 7.1
- 7.2
- 7.3
- master
- 7.4snapshot
sudo: false
env:
matrix:
- DRIVER="phpdbg"
- DRIVER="xdebug"
before_install:
- composer self-update
- composer clear-cache
install:
- travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest
script:
- ./vendor/bin/phpunit --coverage-clover=coverage.xml
- 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)

View File

@@ -2,6 +2,41 @@
All notable changes in `sebastianbergmann/environment` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [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
@@ -58,6 +93,11 @@ All notable changes in `sebastianbergmann/environment` are documented in this fi
* This component is no longer supported on PHP 5.6
[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

View File

@@ -1,6 +1,6 @@
sebastian/environment
Copyright (c) 2014-2018, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2014-2019, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -19,7 +19,10 @@
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.4"
"phpunit/phpunit": "^7.5"
},
"suggest": {
"ext-posix": "*"
},
"autoload": {
"classmap": [
@@ -28,7 +31,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "4.2-dev"
}
}
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"

View File

@@ -104,13 +104,13 @@ final class Console
*/
private function getNumberOfColumnsInteractive(): int
{
if (\function_exists('shell_exec') && \preg_match('#\d+ (\d+)#', \shell_exec('stty size') ?? '', $match) === 1) {
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 (\function_exists('shell_exec') && \preg_match('#columns = (\d+);#', \shell_exec('stty') ?: '', $match) === 1) {
if ((int) $match[1] > 0) {
return (int) $match[1];
}

View File

@@ -20,26 +20,32 @@ final class Runtime
private static $binary;
/**
* Returns true when Xdebug is supported or
* Returns true when Xdebug or PCOV is available or
* the runtime used is PHPDBG.
*/
public function canCollectCodeCoverage(): bool
{
return $this->hasXdebug() || $this->hasPHPDBGCodeCoverage();
return $this->hasXdebug() || $this->hasPCOV() || $this->hasPHPDBGCodeCoverage();
}
/**
* Returns true when OPcache is loaded and opcache.save_comments=0 is set.
*
* Code taken from Doctrine\Common\Annotations\AnnotationReader::__construct().
* Returns true when Zend OPcache is loaded, enabled, and is configured to discard comments.
*/
public function discardsComments(): bool
{
if (\extension_loaded('Zend Optimizer+') && (\ini_get('zend_optimizerplus.save_comments') === '0' || \ini_get('opcache.save_comments') === '0')) {
if (!\extension_loaded('Zend OPcache')) {
return false;
}
if (\ini_get('opcache.save_comments') !== '0') {
return false;
}
if (\PHP_SAPI === 'cli' && \ini_get('opcache.enable_cli') === '1') {
return true;
}
if (\extension_loaded('Zend OPcache') && \ini_get('opcache.save_comments') == 0) {
if (\PHP_SAPI !== 'cli' && \ini_get('opcache.enable') === '1') {
return true;
}
@@ -100,6 +106,29 @@ final class Runtime
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()) {
@@ -174,11 +203,63 @@ final class Runtime
/**
* Returns true when the runtime used is PHP with the PHPDBG SAPI
* and the phpdbg_*_oplog() functions are available (PHP >= 7.0).
*
* @codeCoverageIgnore
*/
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;
}
}

View File

@@ -32,7 +32,7 @@ final class ConsoleTest extends TestCase
*/
public function testCanDetectIfStdoutIsInteractiveByDefault(): void
{
$this->assertInternalType('boolean', $this->console->isInteractive());
$this->assertIsBool($this->console->isInteractive());
}
/**
@@ -41,7 +41,7 @@ final class ConsoleTest extends TestCase
*/
public function testCanDetectIfFileDescriptorIsInteractive(): void
{
$this->assertInternalType('boolean', $this->console->isInteractive(\STDOUT));
$this->assertIsBool($this->console->isInteractive(\STDOUT));
}
/**
@@ -50,7 +50,7 @@ final class ConsoleTest extends TestCase
*/
public function testCanDetectColorSupport(): void
{
$this->assertInternalType('boolean', $this->console->hasColorSupport());
$this->assertIsBool($this->console->hasColorSupport());
}
/**
@@ -59,6 +59,6 @@ final class ConsoleTest extends TestCase
*/
public function testCanDetectNumberOfColumns(): void
{
$this->assertInternalType('integer', $this->console->getNumberOfColumns());
$this->assertIsInt($this->console->getNumberOfColumns());
}
}

View File

@@ -33,4 +33,20 @@ final class OperatingSystemTest extends TestCase
{
$this->assertEquals('Linux', $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());
}
}

View File

@@ -27,83 +27,139 @@ final class RuntimeTest extends TestCase
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
* @requires extension xdebug
*/
public function testAbilityToCollectCodeCoverageCanBeAssessed(): void
public function testCanCollectCodeCoverageWhenXdebugExtensionIsEnabled(): void
{
$this->assertInternalType('boolean', $this->env->canCollectCodeCoverage());
$this->assertTrue($this->env->canCollectCodeCoverage());
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
* @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->assertInternalType('string', $this->env->getBinary());
$this->assertNotEmpty($this->env->getBinary());
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
* @requires PHP
*/
public function testCanBeDetected(): void
public function testIsHhvmReturnsFalseWhenRunningOnPhp(): void
{
$this->assertInternalType('boolean', $this->env->isHHVM());
$this->assertFalse($this->env->isHHVM());
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
* @requires PHP
*/
public function testCanBeDetected2(): void
public function testIsPhpReturnsTrueWhenRunningOnPhp(): void
{
$this->assertInternalType('boolean', $this->env->isPHP());
$this->markTestSkippedWhenRunningOnPhpdbg();
$this->assertTrue($this->env->isPHP());
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
* @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->assertInternalType('boolean', $this->env->hasXdebug());
$this->markTestSkippedWhenRunningOnPhpdbg();
$this->assertTrue($this->env->hasXdebug());
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
*/
public function testNameAndVersionCanBeRetrieved(): void
{
$this->assertInternalType('string', $this->env->getNameWithVersion());
$this->assertNotEmpty($this->env->getNameWithVersion());
}
public function testGetNameReturnsPhpdbgWhenRunningOnPhpdbg(): void
{
$this->markTestSkippedWhenNotRunningOnPhpdbg();
$this->assertSame('PHPDBG', $this->env->getName());
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
* @requires PHP
*/
public function testNameCanBeRetrieved(): void
public function testGetNameReturnsPhpdbgWhenRunningOnPhp(): void
{
$this->assertInternalType('string', $this->env->getName());
$this->markTestSkippedWhenRunningOnPhpdbg();
$this->assertSame('PHP', $this->env->getName());
}
public function testNameAndCodeCoverageDriverCanBeRetrieved(): void
{
$this->assertNotEmpty($this->env->getNameWithVersionAndCodeCoverageDriver());
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
* @requires PHP
*/
public function testVersionCanBeRetrieved(): void
public function testGetVersionReturnsPhpVersionWhenRunningPhp(): void
{
$this->assertInternalType('string', $this->env->getVersion());
$this->assertSame(\PHP_VERSION, $this->env->getVersion());
}
/**
* @todo Now that this component is PHP 7-only and uses return type declarations
* this test makes even less sense than before
* @requires PHP
*/
public function testVendorUrlCanBeRetrieved(): void
public function testGetVendorUrlReturnsPhpDotNetWhenRunningPhp(): void
{
$this->assertInternalType('string', $this->env->getVendorUrl());
$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';
}
}