Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- uses: ramsey/composer-install@v3
- name: GH token
if: matrix.operating-system != 'windows-latest'
run: sudo composer config --global --auth github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- name: Run PHPUnit on Windows
if: matrix.operating-system == 'windows-latest'
run: vendor/bin/phpunit
Expand Down
30 changes: 26 additions & 4 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Php\Pie;

use Composer\Util\Platform;
use Composer\Util\Platform as ComposerPlatform;
use Illuminate\Container\Container as IlluminateContainer;
use Php\Pie\Building\Build;
use Php\Pie\Building\UnixBuild;
Expand Down Expand Up @@ -44,17 +44,39 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;

use function defined;
use function fopen;
use function getcwd;
use function str_starts_with;

use const STDIN;

/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
final class Container
{
public static function factory(): ContainerInterface
{
$container = new IlluminateContainer();
$container->instance(ContainerInterface::class, $container);
$container->instance(InputInterface::class, new ArgvInput());
$container->singleton(
InputInterface::class,
static function () {
$input = new ArgvInput();

$stdin = defined('STDIN') ? STDIN : fopen('php://stdin', 'r');
$noInteractionEnv = ComposerPlatform::getEnv('COMPOSER_NO_INTERACTION');
if (
$noInteractionEnv === false
|| $noInteractionEnv === '1'
|| $stdin === false
|| ! ComposerPlatform::isTty($stdin)
) {
$input->setInteractive(false);
}

return $input;
},
);
$container->instance(OutputInterface::class, new ConsoleOutput());
$container->singleton(EventDispatcher::class, static function () {
$displayedBanner = false;
Expand Down Expand Up @@ -124,7 +146,7 @@ static function (ConsoleCommandEvent $event) use (&$displayedBanner): void {
$container->singleton(
Build::class,
static function (ContainerInterface $container): Build {
if (Platform::isWindows()) {
if (ComposerPlatform::isWindows()) {
return $container->get(WindowsBuild::class);
}

Expand All @@ -148,7 +170,7 @@ static function (ContainerInterface $container): Ini\SetupIniApproach {
$container->singleton(
Install::class,
static function (ContainerInterface $container): Install {
if (Platform::isWindows()) {
if (ComposerPlatform::isWindows()) {
return $container->get(WindowsInstall::class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function validVersionsList(): array
['dev-main#769f906413d6d1e12152f6d34134cbcd347ca253', 'dev-main', self::DOWNLOAD_URL_1_0_1],
];

if (PHP_VERSION_ID >= 80300 && PHP_VERSION_ID <= 80300) {
if (PHP_VERSION_ID >= 80300 && PHP_VERSION_ID <= 80399) {
$versionsAndExpected[] = ['1.0.1-alpha.3@alpha', '1.0.1-alpha.3', self::DOWNLOAD_URL_1_0_1_ALPHA_3];
$versionsAndExpected[] = ['^1.0', '1.0.1', self::DOWNLOAD_URL_1_0_1];
$versionsAndExpected[] = ['^1.1.0@alpha', '1.1.0-beta.1', self::DOWNLOAD_URL_1_1_0_BETA_1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Php\Pie\Platform\WindowsCompiler;
use Php\Pie\Platform\WindowsExtensionAssetName;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily;
use PHPUnit\Framework\TestCase;

use function getenv;
Expand All @@ -30,6 +31,7 @@
#[CoversClass(GithubPackageReleaseAssets::class)]
final class GithubPackageReleaseAssetsTest extends TestCase
{
#[RequiresOperatingSystemFamily('Windows')]
public function testDeterminingReleaseAssetUrlForWindows(): void
{
$phpBinaryPath = $this->createMock(PhpBinaryPath::class);
Expand Down