Skip to content

Prepare for PHP 8.1 #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 17, 2021
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
35 changes: 35 additions & 0 deletions .github/workflows/cloc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: cloc
on:
pull_request:
jobs:
cloc:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
path: pr
- name: Checkout base code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
- name: Count Lines Of Code
id: loc
run: |
curl -OL https://github.com/vearutop/sccdiff/releases/download/v1.0.1/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "::set-output name=diff::$OUTPUT"

- name: Comment Code Lines
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: LOC
message: |
### Lines Of Code

${{ steps.loc.outputs.diff }}
37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: lint
on:
push:
branches:
- master
- main
pull_request:
jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ 'ubuntu-latest' ]
php-versions: [ '7.4' ]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache vendor
uses: actions/cache@v2
with:
path: |
vendor
key: vendor-${{ hashFiles('composer.lock') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: post_max_size=256M, max_execution_time=180
tools: composer

- name: Populate vendor
run: '[ -e vendor ] || composer install'

- name: Lint
run: make lint
38 changes: 38 additions & 0 deletions .github/workflows/test-unit-cov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: test-unit-cov
on:
push:
branches:
- master
- main
pull_request:
jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ 'ubuntu-latest' ]
php-versions: [ '7.4' ]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache vendor
uses: actions/cache@v2
with:
path: |
vendor
key: deps-${{ hashFiles('composer.lock') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
tools: composer

- name: Populate vendor
run: '[ -e vendor ] || (composer install && patch -s -p0 < ./tests/phpunit.patch)'

- name: Run Tests With Coverage
run: make deps test-coverage && bash <(curl -s https://codecov.io/bash)
37 changes: 37 additions & 0 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: test-unit
on:
push:
branches:
- master
- main
pull_request:
jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ 'ubuntu-latest' ]
php-versions: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '8.0', '8.1' ]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache vendor
uses: actions/cache@v2
with:
path: |
vendor
key: deps-${{ hashFiles('composer.lock') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: post_max_size=256M, max_execution_time=180
tools: composer

- name: Populate vendor
run: '[ -e vendor ] || (composer install && patch -s -p0 < ./tests/phpunit.patch)'

- name: Run Tests
run: make deps test
39 changes: 0 additions & 39 deletions .gitlab-ci.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.8.2] - 2021-09-17

### Fixed
- PHP 8.1 Deprecation notices with missing returns.

## [3.8.1] - 2020-09-25

### Fixed
Expand Down Expand Up @@ -55,6 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Compatibility option to `TOLERATE_ASSOCIATIVE_ARRAYS` that mimic JSON objects.

[3.8.2]: https://github.com/swaggest/json-diff/compare/v3.8.1...v3.8.2
[3.8.1]: https://github.com/swaggest/json-diff/compare/v3.8.0...v3.8.1
[3.8.0]: https://github.com/swaggest/json-diff/compare/v3.7.5...v3.8.0
[3.7.5]: https://github.com/swaggest/json-diff/compare/v3.7.4...v3.7.5
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PHPSTAN_VERSION ?= 0.11.19
PHPSTAN_VERSION ?= 0.12.99
PHPBENCH_VERSION ?= 0.16.10

deps:
Expand All @@ -11,11 +11,17 @@ lint:
docker-lint:
@docker run -v $$PWD:/app --rm phpstan/phpstan analyze -l 7 -c phpstan.neon ./src

docker-test-new:
@docker run -v $$PWD:/app -w /app --rm php:8.1.0RC1-zts-buster php vendor/bin/phpunit --configuration phpunit.xml

docker-test-old:
@docker run -v $$PWD:/app -w /app --rm php:5.4-cli php vendor/bin/phpunit --configuration phpunit.xml

test:
@php -derror_reporting="E_ALL & ~E_DEPRECATED" vendor/bin/phpunit --configuration phpunit.xml
@php vendor/bin/phpunit --configuration phpunit.xml

test-coverage:
@php -derror_reporting="E_ALL & ~E_DEPRECATED" -dzend_extension=xdebug.so vendor/bin/phpunit --configuration phpunit.xml --coverage-text --coverage-clover=coverage.xml
@php -dzend_extension=xdebug.so vendor/bin/phpunit --configuration phpunit.xml --coverage-text --coverage-clover=coverage.xml

phpbench:
@test -f ${HOME}/.cache/composer/phpbench-${PHPBENCH_VERSION}.phar || (mkdir -p ${HOME}/.cache/composer/ && wget https://github.com/phpbench/phpbench/releases/download/${PHPBENCH_VERSION}/phpbench.phar -O ${HOME}/.cache/composer/phpbench-${PHPBENCH_VERSION}.phar)
Expand Down
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '#has no return typehint specified#'
- '#with no typehint specified#'
- '#has no typehint specified#'
3 changes: 2 additions & 1 deletion src/JsonPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function import(array $data)
{
$result = new JsonPatch();
foreach ($data as $operation) {
/** @var OpPath|OpPathValue|OpPathFrom $operation */
/** @var OpPath|OpPathValue|OpPathFrom|array $operation */
if (is_array($operation)) {
$operation = (object)$operation;
}
Expand Down Expand Up @@ -124,6 +124,7 @@ public function op(OpPath $op)
return $this;
}

#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return self::export($this);
Expand Down
Loading