Skip to content
Snippets Groups Projects
Commit 3e671ae3 authored by David Prévot's avatar David Prévot
Browse files

New upstream version 7.1.0

parents d67ecd0d 4eb3a442
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ on: ...@@ -7,7 +7,7 @@ on:
name: "CI" name: "CI"
env: env:
COMPOSER_ROOT_VERSION: "7.0-dev" COMPOSER_ROOT_VERSION: "7.1-dev"
permissions: permissions:
contents: read contents: read
......
# https://docs.github.com/en/actions
on:
push:
tags:
- "**"
name: Release
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
extensions: none
tools: none
- name: Determine tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Parse ChangeLog
run: build/scripts/extract-release-notes.php ${{ env.RELEASE_TAG }} > release-notes.md
- name: Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.RELEASE_TAG }}
name: sebastian/environment ${{ env.RELEASE_TAG }}
bodyFile: release-notes.md
...@@ -2,12 +2,24 @@ ...@@ -2,12 +2,24 @@
All notable changes in `sebastianbergmann/environment` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. All notable changes in `sebastianbergmann/environment` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [7.1.0] - 2024-03-23
### Added
* [#72](https://github.com/sebastianbergmann/environment/pull/72): `Runtime::getRawBinary()`
## [7.0.0] - 2024-02-02 ## [7.0.0] - 2024-02-02
### Removed ### Removed
* This component is no longer supported on PHP 8.1 * This component is no longer supported on PHP 8.1
## [6.1.0] - 2024-03-23
### Added
* [#72](https://github.com/sebastianbergmann/environment/pull/72): `Runtime::getRawBinary()`
## [6.0.1] - 2023-04-11 ## [6.0.1] - 2023-04-11
### Fixed ### Fixed
...@@ -178,7 +190,9 @@ All notable changes in `sebastianbergmann/environment` are documented in this fi ...@@ -178,7 +190,9 @@ All notable changes in `sebastianbergmann/environment` are documented in this fi
* This component is no longer supported on PHP 5.6 * This component is no longer supported on PHP 5.6
[7.0.0]: https://github.com/sebastianbergmann/environment/compare/6.0...7.0.0 [7.1.0]: https://github.com/sebastianbergmann/environment/compare/7.0.0...7.1.0
[7.0.0]: https://github.com/sebastianbergmann/environment/compare/6.1...7.0.0
[6.1.0]: https://github.com/sebastianbergmann/environment/compare/6.0.1...6.1.0
[6.0.1]: https://github.com/sebastianbergmann/environment/compare/6.0.0...6.0.1 [6.0.1]: https://github.com/sebastianbergmann/environment/compare/6.0.0...6.0.1
[6.0.0]: https://github.com/sebastianbergmann/environment/compare/5.1.5...6.0.0 [6.0.0]: https://github.com/sebastianbergmann/environment/compare/5.1.5...6.0.0
[5.1.5]: https://github.com/sebastianbergmann/environment/compare/5.1.4...5.1.5 [5.1.5]: https://github.com/sebastianbergmann/environment/compare/5.1.4...5.1.5
......
#!/usr/bin/env php
<?php declare(strict_types=1);
if ($argc !== 2) {
print $argv[0] . ' <tag>' . PHP_EOL;
exit(1);
}
$version = $argv[1];
$file = __DIR__ . '/../../ChangeLog.md';
if (!is_file($file) || !is_readable($file)) {
print $file . ' cannot be read' . PHP_EOL;
exit(1);
}
$buffer = '';
$append = false;
foreach (file($file) as $line) {
if (str_starts_with($line, '## [' . $version . ']')) {
$append = true;
continue;
}
if ($append && (str_starts_with($line, '## ') || str_starts_with($line, '['))) {
break;
}
if ($append) {
$buffer .= $line;
}
}
$buffer = trim($buffer);
if ($buffer === '') {
print 'Unable to extract release notes' . PHP_EOL;
exit(1);
}
print $buffer . PHP_EOL;
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "7.0-dev" "dev-main": "7.1-dev"
} }
} }
} }
...@@ -97,7 +97,7 @@ final class Console ...@@ -97,7 +97,7 @@ final class Console
/** /**
* Returns if the file descriptor is an interactive terminal or not. * 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, * Normally, we want to use a resource as a parameter, yet sadly it's not always available,
* eg when running code in interactive console (`php -a`), STDIN/STDOUT/STDERR constants are not defined. * eg when running code in interactive console (`php -a`), STDIN/STDOUT/STDERR constants are not defined.
* *
* @param int|resource $fileDescriptor * @param int|resource $fileDescriptor
......
...@@ -30,7 +30,7 @@ use function strrpos; ...@@ -30,7 +30,7 @@ use function strrpos;
final class Runtime final class Runtime
{ {
private static string $binary; private static string $rawBinary;
private static bool $initialized = false; private static bool $initialized = false;
/** /**
...@@ -91,19 +91,19 @@ final class Runtime ...@@ -91,19 +91,19 @@ final class Runtime
} }
/** /**
* Returns the path to the binary of the current runtime. * Returns the raw path to the binary of the current runtime.
*/ */
public function getBinary(): string public function getRawBinary(): string
{ {
if (self::$initialized) { if (self::$initialized) {
return self::$binary; return self::$rawBinary;
} }
if (PHP_BINARY !== '') { if (PHP_BINARY !== '') {
self::$binary = escapeshellarg(PHP_BINARY); self::$rawBinary = PHP_BINARY;
self::$initialized = true; self::$initialized = true;
return self::$binary; return self::$rawBinary;
} }
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
...@@ -115,19 +115,26 @@ final class Runtime ...@@ -115,19 +115,26 @@ final class Runtime
foreach ($possibleBinaryLocations as $binary) { foreach ($possibleBinaryLocations as $binary) {
if (is_readable($binary)) { if (is_readable($binary)) {
self::$binary = escapeshellarg($binary); self::$rawBinary = $binary;
self::$initialized = true; self::$initialized = true;
return self::$binary; return self::$rawBinary;
} }
} }
// @codeCoverageIgnoreStart self::$rawBinary = 'php';
self::$binary = 'php';
self::$initialized = true; self::$initialized = true;
return self::$rawBinary;
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
}
return self::$binary; /**
* Returns the escaped path to the binary of the current runtime.
*/
public function getBinary(): string
{
return escapeshellarg($this->getRawBinary());
} }
public function getNameWithVersion(): string public function getNameWithVersion(): string
......
...@@ -11,6 +11,7 @@ namespace SebastianBergmann\Environment; ...@@ -11,6 +11,7 @@ namespace SebastianBergmann\Environment;
use const PHP_SAPI; use const PHP_SAPI;
use const PHP_VERSION; use const PHP_VERSION;
use function ini_get;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
...@@ -42,6 +43,11 @@ final class RuntimeTest extends TestCase ...@@ -42,6 +43,11 @@ final class RuntimeTest extends TestCase
$this->assertNotEmpty((new Runtime)->getBinary()); $this->assertNotEmpty((new Runtime)->getBinary());
} }
public function testRawBinaryCanBeRetrieved(): void
{
$this->assertNotEmpty((new Runtime)->getRawBinary());
}
public function testIsPhpReturnsTrueWhenRunningOnPhp(): void public function testIsPhpReturnsTrueWhenRunningOnPhp(): void
{ {
$this->markTestSkippedWhenRunningOnPhpdbg(); $this->markTestSkippedWhenRunningOnPhpdbg();
...@@ -112,6 +118,10 @@ final class RuntimeTest extends TestCase ...@@ -112,6 +118,10 @@ final class RuntimeTest extends TestCase
#[RequiresPhpExtension('xdebug')] #[RequiresPhpExtension('xdebug')]
public function testGetCurrentSettingsReturnsCorrectDiffIfXdebugValuesArePassed(): void public function testGetCurrentSettingsReturnsCorrectDiffIfXdebugValuesArePassed(): void
{ {
if (ini_get('xdebug.mode') === '') {
$this->markTestSkipped('xdebug.mode must not be set to "off"');
}
$this->assertIsArray((new Runtime)->getCurrentSettings(['xdebug.mode'])); $this->assertIsArray((new Runtime)->getCurrentSettings(['xdebug.mode']));
$this->assertArrayHasKey('xdebug.mode', (new Runtime)->getCurrentSettings(['xdebug.mode'])); $this->assertArrayHasKey('xdebug.mode', (new Runtime)->getCurrentSettings(['xdebug.mode']));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment