Skip to content

Commit 3e7d354

Browse files
authored
Merge pull request #35 from karriereat/feature/prepare-v4-release
Prepare v4 release
2 parents f918438 + 5a88eea commit 3e7d354

26 files changed

+164
-151
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
- uses: shivammathur/setup-php@v2
2222
with:
2323
php-version: ${{ matrix.php }}
24-
tools: pecl
25-
extensions: imagick
2624

2725
- uses: actions/checkout@v2
2826

.github/workflows/test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: true
1515
matrix:
16-
php: [7.2, 7.3, 7.4]
16+
php: [7.3, 7.4]
1717

1818
runs-on: ubuntu-latest
1919
name: PHP@${{ matrix.php }}
@@ -32,6 +32,4 @@ jobs:
3232
run: composer install --prefer-dist --no-progress --no-suggest
3333

3434
- name: Run test suite
35-
run: composer coverage
36-
37-
- uses: codecov/codecov-action@v1
35+
run: composer test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
vendor/
22
composer.lock
3+
.phpunit.result.cache
4+
.php_cs.cache
5+
coverage.xml

.php_cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests')
5+
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')
6+
->append(['.php_cs']);
7+
8+
$rules = [
9+
'@Symfony' => true,
10+
'phpdoc_no_empty_return' => false,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'yoda_style' => false,
13+
'binary_operator_spaces' => [
14+
'operators' => [
15+
'=>' => 'align',
16+
'=' => 'align',
17+
],
18+
],
19+
'concat_space' => ['spacing' => 'one'],
20+
'not_operator_with_space' => false,
21+
];
22+
23+
$rules['increment_style'] = ['style' => 'post'];
24+
25+
return PhpCsFixer\Config::create()
26+
->setUsingCache(true)
27+
->setRules($rules)
28+
->setFinder($finder);

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [4.0.0] - 2002-10-06
8+
### Added
9+
- support for magic class properties
10+
- auto casing for json field - class properties mapping
11+
- PHP CS Fixer for linting and fixing code style
12+
13+
### Changed
14+
- unit tests to phpunit
15+
16+
### Removed
17+
- support for PHP 7.2
18+
719
## [3.1.0] - 2020-04-10
820
### Added
921
- `DateTimeBinding` for parsing date string

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@
2121
}
2222
},
2323
"require": {
24-
"php": ">=7.2",
24+
"php": ">=7.3",
2525
"php-di/phpdoc-reader": "^2.1"
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit": "^8.0 || ^9.0",
29-
"squizlabs/php_codesniffer": "^3.0"
29+
"friendsofphp/php-cs-fixer": "^2.16"
3030
},
3131
"scripts": {
32-
"test": "vendor/bin/phpunit",
33-
"coverage": "vendor/bin/phpunit --coverage-clover coverage.xml",
34-
"lint": "vendor/bin/phpcs src/ --standard=PSR12"
32+
"test": "phpunit",
33+
"coverage": "phpunit --coverage-clover coverage.xml",
34+
"lint": "php-cs-fixer fix -v --dry-run",
35+
"fix": "php-cs-fixer fix -v"
3536
}
3637
}

phpunit.xml.dist

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false">
12-
<testsuites>
13-
<testsuite name="JSON Decoder Test Suite">
14-
<directory>tests</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="JSON Decoder Test Suite">
10+
<directory>tests</directory>
11+
</testsuite>
12+
</testsuites>
2213
</phpunit>

readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<span>&nbsp;&nbsp;&nbsp;</span>
33
![](https://github.com/karriereat/json-decoder/workflows/test/badge.svg)
44
![](https://github.com/karriereat/json-decoder/workflows/lint/badge.svg)
5-
[![codecov](https://codecov.io/gh/karriereat/json-decoder/branch/master/graph/badge.svg)](https://codecov.io/gh/karriereat/json-decoder)
65

76
# JsonDecoder for PHP
87

src/Binding.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,16 @@ abstract class Binding
3434
*/
3535
public function __construct($property, $jsonField, $type, $isRequired = false)
3636
{
37-
$this->property = $property;
38-
$this->jsonField = $jsonField;
39-
$this->type = $type;
37+
$this->property = $property;
38+
$this->jsonField = $jsonField;
39+
$this->type = $type;
4040
$this->isRequired = $isRequired;
4141
}
4242

4343
/**
4444
* validates the given binding data.
4545
*
4646
* @param mixed $jsonData
47-
*
48-
* @return bool
4947
*/
5048
public function validate(array $jsonData): bool
5149
{
@@ -71,9 +69,8 @@ public function jsonField(): string
7169
/**
7270
* executes the defined binding method on the class instance.
7371
*
74-
* @param JsonDecoder $jsonDecoder
75-
* @param mixed $jsonData
76-
* @param Property $property the class instance to bind to
72+
* @param mixed $jsonData
73+
* @param Property $property the class instance to bind to
7774
*
7875
* @return mixed
7976
*/

src/Bindings/ArrayBinding.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ArrayBinding extends Binding
1414
public function bind(JsonDecoder $jsonDecoder, ?array $jsonData, Property $property)
1515
{
1616
if (array_key_exists($this->jsonField, $jsonData)) {
17-
$data = $jsonData[$this->jsonField];
17+
$data = $jsonData[$this->jsonField];
1818
$values = [];
1919

2020
if (is_array($data)) {

0 commit comments

Comments
 (0)