Skip to content

Commit e34075c

Browse files
authored
PHP 8 (#112)
1 parent ba2c50d commit e34075c

Some content is hidden

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

80 files changed

+538
-826
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ composer.phar
33
/vendor/
44
/composer.lock
55
/.php_cs.cache
6+
.php-cs-fixer.cache
7+
.phpunit.result.cache

.php-cs-fixer.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('somedir')
5+
->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php')
6+
->in(__DIR__);
7+
8+
$config = new PhpCsFixer\Config();
9+
return $config->setRules([
10+
'@PSR12' => true,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'braces' => [
13+
'allow_single_line_closure' => true,
14+
'position_after_functions_and_oop_constructs' => 'same'],
15+
])
16+
->setFinder($finder);

.php_cs.dist

Lines changed: 0 additions & 53 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [3.0.0] - 2022-07-26
10+
### Changed
11+
- The package is migrated to PHP 8.1
12+
13+
### Removed
14+
- Support for PHP 7 and older versions
15+
- Compound document validation logic is dropped
16+
917
## [2.2.0] - 2020-10-12
1018
### Added
1119
- `NewResourceObject` to allow omitting `id` in resources to-be-created (#108)
@@ -30,7 +38,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3038
### Added
3139
- v2 initial release
3240

33-
[Unreleased]: https://github.com/json-api-php/json-api/compare/2.2.0...HEAD
41+
[Unreleased]: https://github.com/json-api-php/json-api/compare/3.0.0...HEAD
42+
[3.0.0]: https://github.com/json-api-php/json-api/compare/2.2.2...3.0.0
3443
[2.2.0]: https://github.com/json-api-php/json-api/compare/2.1.2...2.2.0
3544
[2.1.2]: https://github.com/json-api-php/json-api/compare/2.1.1...2.1.2
3645
[2.1.1]: https://github.com/json-api-php/json-api/compare/2.1.0...2.1.1

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-api-php/json-api",
3-
"description": "An attempt to express JSON API specs (jsonapi.org) in object-oriented way as a set of PHP 7 classes",
3+
"description": "JSON API specs (jsonapi.org) as a set of PHP classes",
44
"type": "library",
55
"prefer-stable": true,
66
"license": "MIT",
@@ -11,12 +11,12 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=7.1",
14+
"php": ">=8.1",
1515
"ext-json": "*"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "^7.0||^8.0",
19-
"friendsofphp/php-cs-fixer": "^2.13"
18+
"phpunit/phpunit": "^9.0",
19+
"friendsofphp/php-cs-fixer": "^3.9"
2020
},
2121
"autoload": {
2222
"psr-4": {

examples/compound_doc.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
use JsonApiPhp\JsonApi\Attribute;
46
use JsonApiPhp\JsonApi\CompoundDocument;

examples/simple_doc.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24
require_once __DIR__.'/../vendor/autoload.php';
35

46
use JsonApiPhp\JsonApi\Attribute;

phpunit.xml.dist

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
<?xml version="1.0" encoding="UTF-8" ?>
2-
<phpunit
3-
bootstrap="vendor/autoload.php"
4-
stopOnFailure="false"
5-
verbose="true"
6-
colors="true">
7-
<testsuites>
8-
<testsuite name="Main">
9-
<directory>./test</directory>
10-
</testsuite>
11-
</testsuites>
12-
<filter>
13-
<whitelist>
14-
<directory suffix=".php">./src/</directory>
15-
</whitelist>
16-
</filter>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" stopOnFailure="false" verbose="true" colors="true" 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="Main">
10+
<directory>./test</directory>
11+
</testsuite>
12+
</testsuites>
1713
</phpunit>

src/Attribute.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace JsonApiPhp\JsonApi;
46

@@ -8,13 +10,12 @@
810
/**
911
* @see http://jsonapi.org/format/#document-resource-object-attributes
1012
*/
11-
final class Attribute implements ResourceField
12-
{
13+
final class Attribute implements ResourceField {
1314
use ResourceFieldTrait;
14-
private $val;
1515

16-
public function __construct(string $name, $val)
17-
{
16+
private string|int|float|bool|null|array|object $val;
17+
18+
public function __construct(string $name, $val) {
1819
$this->validateFieldName($name);
1920
$this->name = $name;
2021
$this->val = $val;
@@ -24,8 +25,7 @@ public function __construct(string $name, $val)
2425
* @param object $o
2526
* @internal
2627
*/
27-
public function attachTo($o): void
28-
{
28+
public function attachTo(object $o): void {
2929
child($o, 'attributes')->{$this->name} = $this->val;
3030
}
3131
}

0 commit comments

Comments
 (0)