Skip to content

Commit deea558

Browse files
committed
Major refactoring performed
1 parent ec88278 commit deea558

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2441
-255
lines changed

.travis.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
language: php
22

3-
php:
4-
- '7.1'
5-
- '7.2'
6-
- '7.3'
3+
matrix:
4+
include:
5+
- php: '7.3'
6+
env: XDEBUG=YES
7+
- php: '7.4snapshot'
8+
env: XDEBUG=NO
79

8-
before_script:
10+
install:
11+
- mkdir -p ./build/logs
912
- composer self-update
1013
- composer install --prefer-source --no-interaction
14+
- vendor/bin/phing
1115

12-
script: vendor/bin/phpunit --coverage-clover=build/logs/clover.xml --coverage-xml=build/logs/coverage-xml --log-junit=build/logs/phpunit.junit.xml
16+
script:
17+
- vendor/bin/phpcs -sp --report-junit=build/logs/phpcs.xml
18+
- if [ "$XDEBUG" == "YES" ]; then vendor/bin/phpunit --coverage-clover=build/logs/clover.xml --coverage-xml=build/logs/coverage-xml --log-junit=build/logs/phpunit.junit.xml; else vendor/bin/phpunit; fi
19+
- if [ "$XDEBUG" == "YES" ]; then vendor/bin/infection --coverage=build/logs --threads=4 --no-progress; fi
1320

1421
after_success:
15-
- bash <(curl -s https://codecov.io/bash -s "build/logs")
16-
- wget https://scrutinizer-ci.com/ocular.phar
17-
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
22+
- if [ "$XDEBUG" == "YES" ]; then bash <(curl -s https://codecov.io/bash -s "build/logs"); fi
23+
- if [ "$XDEBUG" == "YES" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
24+
- if [ "$XDEBUG" == "YES" ]; then php ocular.phar code-coverage:upload --access-token=$SCRUTINIZER_TOKEN --format=php-clover build/logs/clover.xml; fi

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
### Added
9+
- Implementation totally refactored.

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@
99
This library implements [RFC6902](https://tools.ietf.org/html/rfc6902)-compliant JSON patch tool.
1010

1111
## Requirements
12-
* PHP 7.1+
13-
14-
## Features
15-
* Supports PHP 7.1
16-
* No PHP extensions required
17-
* Throws SPL exceptions
18-
19-
# License
20-
PHP JSON Patch is licensed under MIT license.
12+
- PHP 7.3+
13+
- [Internationalization functions](https://www.php.net/manual/en/book.intl.php) (ext-intl) - required by [`remorhaz/php-json-data`](https://github.com/remorhaz/php-json-data) to compare Unicode strings.
2114

2215
# Installation
2316
You will need [composer](https://getcomposer.org) to perform install.
@@ -48,7 +41,7 @@ To apply JSON Patch to the JSON document you need just 4 simple steps:
4841

4942
use Remorhaz\JSON\Data\Reference\Selector;
5043
use Remorhaz\JSON\Data\Reference\Writer;
51-
use Remorhaz\JSON\Patch\Patch;
44+
use Remorhaz\JSON\Patch\Processor\Processor;
5245

5346
// Setting up document.
5447
$data = (object) ['a' => (object) ['b' => 'c', 'd' => 'e']];
@@ -61,4 +54,8 @@ $patchData = [
6154
$patchSelector = new Selector($patchData);
6255

6356
// Applying the patch.
64-
(new Patch($dataWriter))->apply($patchSelector); // $data->a->f property is added and set to 'g'
57+
(new Processor($dataWriter))->apply($patchSelector); // $data->a->f property is added and set to 'g'
58+
```
59+
60+
# License
61+
PHP JSON Patch is licensed under MIT license.

composer.json

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"name": "remorhaz/php-json-patch",
33
"description": "JSON Patch (RFC-6902) PHP implementation",
4-
"keywords": ["json", "json patch", "RFC6902"],
4+
"keywords": [
5+
"json",
6+
"json patch",
7+
"RFC6902"
8+
],
59
"homepage": "https://github.com/remorhaz/php-json-patch",
610
"license": "MIT",
711
"authors": [
@@ -13,12 +17,14 @@
1317
],
1418
"require": {
1519
"php": "^7.3",
20+
"ext-intl": "*",
1621
"remorhaz/php-json-data": "^0.5.2",
17-
"remorhaz/php-json-pointer": "^0.6.0"
22+
"remorhaz/php-json-pointer": "dev-master"
1823
},
1924
"require-dev": {
2025
"phpunit/phpunit": "^8.4.3",
21-
"infection/infection": "^0.14.2"
26+
"infection/infection": "^0.14.2",
27+
"squizlabs/php_codesniffer": "^3.5.2"
2228
},
2329
"autoload": {
2430
"psr-4": {
@@ -29,5 +35,18 @@
2935
"psr-4": {
3036
"Remorhaz\\JSON\\Test\\Patch\\": "tests/"
3137
}
38+
},
39+
"scripts": {
40+
"phpcs": [
41+
"vendor/bin/phpcs"
42+
],
43+
"test": [
44+
"vendor/bin/phpunit --coverage-xml=build/log/coverage-xml --log-junit=build/log/phpunit.junit.xml"
45+
],
46+
"infection": [
47+
"@test",
48+
"mkdir -p build/log/infection",
49+
"vendor/bin/infection --threads=4 --coverage=build/log --no-progress"
50+
]
3251
}
3352
}

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ services:
88
volumes:
99
- .:/app
1010
working_dir: /app
11+
php-7.4:
12+
build:
13+
context: .
14+
dockerfile: php-7.4.Dockerfile
15+
volumes:
16+
- .:/app
17+
working_dir: /app

infection.json.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"source": {
3+
"directories": [
4+
"src"
5+
]
6+
},
7+
"timeout": 10,
8+
"logs": {
9+
"text": "build/logs/infection/infection.log",
10+
"summary": "build/logs/infection/summary.log",
11+
"perMutator": "build/logs/infection/per-mutator.md",
12+
"badge": {
13+
"branch": "master"
14+
}
15+
}
16+
}

php-7.4.Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM php:7.4-rc-cli
2+
3+
RUN apt-get update && apt-get install -y \
4+
zip \
5+
git \
6+
libicu-dev && \
7+
pecl install xdebug && \
8+
docker-php-ext-enable xdebug && \
9+
docker-php-ext-configure intl --enable-intl && \
10+
docker-php-ext-install intl
11+
12+
ENV COMPOSER_ALLOW_SUPERUSER=1 \
13+
COMPOSER_PROCESS_TIMEOUT=1200
14+
15+
RUN curl --silent --show-error https://getcomposer.org/installer | php -- \
16+
--install-dir=/usr/bin --filename=composer

phpcs.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<ruleset name="PHP JSONPath">
3+
<description>The coding standards for PHP JSONPath library.</description>
4+
5+
<file>src</file>
6+
<file>tests</file>
7+
8+
<arg name="colors"/>
9+
10+
<rule ref="PSR2">
11+
</rule>
12+
13+
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
14+
<exclude-pattern>*/tests/*Test.php</exclude-pattern>
15+
</rule>
16+
</ruleset>

phpunit.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<phpunit
3-
bootstrap="vendor/autoload.php"
4-
colors="true">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.4/phpunit.xsd"
5+
forceCoversAnnotation="true"
6+
colors="true"
7+
defaultTestSuite="unit">
58
<testsuites>
6-
<testsuite name="Full Test Suite">
9+
<testsuite name="unit">
710
<directory>tests/</directory>
811
</testsuite>
912
</testsuites>
1013
<filter>
1114
<whitelist
12-
addUncoveredFilesFromWhitelist="true"
13-
processUncoveredFilesFromWhitelist="true">
15+
processUncoveredFilesFromWhitelist="true">
1416
<directory suffix=".php">src/</directory>
1517
</whitelist>
1618
</filter>
17-
<logging>
18-
<log type="coverage-clover" target="build/logs/clover.xml"/>
19-
</logging>
2019
</phpunit>

src/Exception/ExceptionInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Remorhaz\JSON\Patch\Exception;
5+
6+
use Throwable;
7+
8+
interface ExceptionInterface extends Throwable
9+
{
10+
}

0 commit comments

Comments
 (0)