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
30 changes: 30 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,33 @@ on:
jobs:
test:
uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main

minimum-php-guard:
name: Minimum PHP guard - PHP ${{ matrix.php }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php: ['5.6', '7.1']
steps:
- name: Check out source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false

- name: Set up PHP environment
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '${{ matrix.php }}'
coverage: none

- name: Check minimum PHP guard
run: |
if php php/boot-phar.php > stdout.txt 2> stderr.txt; then
echo 'Expected boot-phar.php to reject unsupported PHP version.'
exit 1
fi

test ! -s stdout.txt
printf 'Error: WP-CLI requires PHP 7.2.24 or newer. You are running version %s.\n' "$(php -r 'echo PHP_VERSION;')" > expected.txt
diff -u expected.txt stderr.txt
10 changes: 10 additions & 0 deletions php/boot-phar.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

// This file needs to parse without error in PHP 5.x.

if ( 'cli' !== PHP_SAPI ) {
echo "WP-CLI only works correctly from the command line, using the 'cli' PHP SAPI.\n",
"You're currently executing the WP-CLI binary via the '" . PHP_SAPI . "' PHP SAPI.\n",
Expand All @@ -9,6 +11,14 @@
die( -1 );
}

if ( version_compare( PHP_VERSION, '7.2.24', '<' ) ) {
fwrite(
STDERR,
sprintf( "Error: WP-CLI requires PHP %s or newer. You are running version %s.\n", '7.2.24', PHP_VERSION )
);
die( -1 );
}

// Store the path to the Phar early on for `Utils\phar-safe-path()` function.
define( 'WP_CLI_PHAR_PATH', Phar::running( true ) );

Expand Down
Loading