Skip to content

Commit

Permalink
Adjust supported PHP version
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Aug 25, 2023
1 parent 9b87907 commit f3734e2
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 221 deletions.
16 changes: 0 additions & 16 deletions .github/bin/composer.sh

This file was deleted.

5 changes: 0 additions & 5 deletions .github/bin/hhvm.sh

This file was deleted.

68 changes: 10 additions & 58 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
jobs:
tests_linux:
name: PHP ${{ matrix.php }} Linux
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
matrix:
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -27,32 +27,23 @@ jobs:
- name: Setup Problem Matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install PHP 5/7 Dependencies
uses: nick-invision/retry@v1
- name: Install PHP Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress
if: "matrix.php < 8"

- name: Install PHP 8 Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress --ignore-platform-req=php
if: "matrix.php >= 8"

- name: Execute PHPUnit
run: vendor/bin/phpunit

tests_windows:
name: PHP ${{ matrix.php }} Windows
runs-on: windows-2019
runs-on: windows-2022

strategy:
matrix:
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

steps:
- name: Configure Git
Expand All @@ -61,7 +52,7 @@ jobs:
git config --global core.eol lf
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -73,51 +64,12 @@ jobs:
- name: Setup Problem Matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install PHP 5/7 Dependencies
uses: nick-invision/retry@v1
- name: Install PHP Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress
if: "matrix.php < 8"

- name: Install PHP 8 Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress --ignore-platform-req=php
if: "matrix.php >= 8"

- name: Execute PHPUnit
run: vendor\bin\phpunit.bat

test_hhvm:
name: HHVM ${{ matrix.hhvm }}
runs-on: ubuntu-16.04

strategy:
matrix:
hhvm: ["3.15", "3.18", "3.21", "3.24"]

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install HHVM
shell: bash
run: sudo .github/bin/hhvm.sh ${{ matrix.hhvm }}

- name: Install Composer
shell: bash
run: sudo .github/bin/composer.sh

- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress

- name: Execute PHPUnit
run: hhvm vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit.result.cache
vendor
composer.lock
phpunit.xml
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 2.7.0 - UPCOMING

* Drop support for HHVM and PHP earlier than 7.2.5.
* Add support for PHP 8.1, 8.2, and 8.3.

## 2.6.0 - 2020-07-31

* Support for PHP 8.0.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jmespath.php

JMESPath (pronounced "jaymz path") allows you to declaratively specify how to
extract elements from a JSON document. *jmespath.php* allows you to use
JMESPath in PHP applications with PHP data structures. It requires PHP 5.4 or
JMESPath in PHP applications with PHP data structures. It requires PHP 7.2.5 or
greater and can be installed through `Composer <http://getcomposer.org/doc/00-intro.md>`_
using the ``mtdowling/jmespath.php`` package.

Expand Down
69 changes: 34 additions & 35 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
{
"name": "mtdowling/jmespath.php",
"description": "Declaratively specify how to extract elements from a JSON document",
"keywords": ["json", "jsonpath"],
"license": "MIT",

"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],

"require": {
"php": "^5.4 || ^7.0 || ^8.0",
"symfony/polyfill-mbstring": "^1.17"
},

"require-dev": {
"composer/xdebug-handler": "^1.4 || ^2.0",
"phpunit/phpunit": "^4.8.36 || ^7.5.15"
},

"autoload": {
"psr-4": {
"JmesPath\\": "src/"
"name": "mtdowling/jmespath.php",
"description": "Declaratively specify how to extract elements from a JSON document",
"keywords": ["json", "jsonpath"],
"license": "MIT",
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"require": {
"php": "^7.2.5 || ^8.0",
"symfony/polyfill-mbstring": "^1.17"
},
"require-dev": {
"composer/xdebug-handler": "^3.0.3",
"phpunit/phpunit": "^8.5.33"
},
"autoload": {
"psr-4": {
"JmesPath\\": "src/"
},
"files": ["src/JmesPath.php"]
},
"files": ["src/JmesPath.php"]
},

"bin": ["bin/jp.php"],

"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
"bin": ["bin/jp.php"],
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
}
}
}
9 changes: 7 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php"
colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
failOnRisky="true"
failOnWarning="true"
convertDeprecationsToExceptions="true"
>

<testsuites>
<testsuite name="Unit Tests">
Expand Down
2 changes: 1 addition & 1 deletion src/SyntaxErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(
array $token,
$expression
) {
$message = "Syntax error at character {$token['pos']}\n"
$message = sprintf("Syntax error at character %d\n", max($token['pos'], 0))
. $expression . "\n" . str_repeat(' ', max($token['pos'], 0)) . "^\n";
$message .= !is_array($expectedTypesOrMessage)
? $expectedTypesOrMessage
Expand Down
21 changes: 6 additions & 15 deletions tests/ComplianceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class ComplianceTest extends TestCase
{
private static $path;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$path = __DIR__ . '/../../compiled';
array_map('unlink', glob(self::$path . '/jmespath_*.php'));
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
array_map('unlink', glob(self::$path . '/jmespath_*.php'));
}
Expand All @@ -34,7 +34,7 @@ public function testPassesCompliance(
$case,
$compiled,
$asAssoc
) {
): void {
$evalResult = null;
$failed = false;
$failureMsg = '';
Expand All @@ -61,8 +61,8 @@ public function testPassesCompliance(

$file = __DIR__ . '/compliance/' . $file . '.json';
$failure .= "\n{$compiledStr}php bin/jp.php --file {$file} --suite {$suite} --case {$case}\n\n"
. "Result: " . $this->prettyJson($evalResult) . "\n\n"
. "Expected: " . $this->prettyJson($result) . "\n\n";
. "Result: " . json_encode($evalResult, JSON_PRETTY_PRINT) . "\n\n"
. "Expected: " . json_encode($result, JSON_PRETTY_PRINT) . "\n\n";
$failure .= 'Associative? ' . var_export($asAssoc, true) . "\n\n";

if (!$error && $failed) {
Expand All @@ -78,7 +78,7 @@ public function testPassesCompliance(
);
}

public function complianceProvider()
public static function complianceProvider(): array
{
$cases = [];

Expand Down Expand Up @@ -126,13 +126,4 @@ private function convertAssoc($data)
return $data;
}
}

private function prettyJson($json)
{
if (defined('JSON_PRETTY_PRINT')) {
return json_encode($json, JSON_PRETTY_PRINT);
}

return json_encode($json);
}
}
6 changes: 3 additions & 3 deletions tests/EnvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@

class EnvTest extends TestCase
{
public function testSearchesInput()
public function testSearchesInput(): void
{
$data = ['foo' => 123];
$this->assertEquals(123, Env::search('foo', $data));
$this->assertEquals(123, Env::search('foo', $data));
}

public function testSearchesWithFunction()
public function testSearchesWithFunction(): void
{
$data = ['foo' => 123];
$this->assertEquals(123, \JmesPath\search('foo', $data));
}

public function testCleansCompileDir()
public function testCleansCompileDir(): void
{
$dir = sys_get_temp_dir();
$runtime = new CompilerRuntime($dir);
Expand Down
8 changes: 4 additions & 4 deletions tests/FnDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class fnDispatcherTest extends TestCase
{
public function testConvertsToString()
public function testConvertsToString(): void
{
$fn = new FnDispatcher();
$this->assertEquals('foo', $fn('to_string', ['foo']));
Expand All @@ -22,20 +22,20 @@ public function testConvertsToString()

class _TestStringClass
{
public function __toString()
public function __toString(): string
{
return 'foo';
}
}

class _TestJsonStringClass implements \JsonSerializable
{
public function __toString()
public function __toString(): string
{
return 'no!';
}

public function jsonSerialize()
public function jsonSerialize(): string
{
return 'foo';
}
Expand Down
Loading

0 comments on commit f3734e2

Please sign in to comment.