Skip to content

Commit 435d0a8

Browse files
authored
Merge pull request #37 from liip/doctrine-annotations-dependency
Directly add doctrine/annotations dependency
2 parents 8ff4fee + 01e997c commit 435d0a8

35 files changed

+195
-106
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
17+
php-version: ['7.4', '8.0', '8.1', '8.2']
1818
include:
19-
- php-version: '7.2'
19+
- php-version: '7.4'
2020
composer-flags: '--prefer-stable --prefer-lowest'
2121
steps:
2222
- name: Check out code into the workspace
@@ -25,17 +25,14 @@ jobs:
2525
uses: shivammathur/setup-php@v2
2626
with:
2727
php-version: ${{ matrix.php-version }}
28-
- name: Validate composer.json
29-
run: composer validate --strict --no-check-lock
28+
- name: Remove dev tools to not interfere with dependencies
29+
run: composer remove --dev friendsofphp/php-cs-fixer phpstan/phpstan-phpunit phpstan/phpstan
3030
- name: Composer cache
3131
uses: actions/cache@v3
3232
with:
3333
path: ${{ env.HOME }}/.composer/cache
3434
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
3535
- name: Install dependencies
3636
run: composer update ${{ matrix.composer-flags }} --prefer-dist --no-interaction
37-
- name: PHPStan
38-
if: ${{ matrix.php-version == '8.1' }}
39-
run: composer phpstan-all
4037
- name: Run tests
4138
run: composer phpunit

.github/workflows/static.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Static
2+
3+
on:
4+
push:
5+
branches:
6+
- '*.x'
7+
tags:
8+
- '[0-9].[0-9]+'
9+
pull_request:
10+
11+
jobs:
12+
phpstan:
13+
name: "PHPStan"
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out code into the workspace
17+
uses: actions/checkout@v3
18+
- name: Setup PHP 8.2
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.2
22+
- name: Composer cache
23+
uses: actions/cache@v3
24+
with:
25+
path: ${{ env.HOME }}/.composer/cache
26+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
27+
- name: Install dependencies
28+
run: composer update --prefer-dist --no-interaction
29+
- name: PHPStan
30+
run: composer phpstan-all
31+
32+
cs:
33+
name: "CS Fixer"
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Check out code into the workspace
37+
uses: actions/checkout@v3
38+
- name: Setup PHP 8.2
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: 8.2
42+
- name: Validate composer.json
43+
run: composer validate --strict --no-check-lock
44+
- name: Composer cache
45+
uses: actions/cache@v3
46+
with:
47+
path: ${{ env.HOME }}/.composer/cache
48+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
49+
- name: Install dependencies
50+
run: composer update --prefer-dist --no-interaction
51+
- name: CS Fixer
52+
run: composer cs-fixer

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
###< phpunit/phpunit ###
99

1010
###> friendsofphp/php-cs-fixer ###
11-
/.php_cs
12-
/.php_cs.cache
11+
/.php-cs-fixer.php
12+
/.php-cs-fixer.cache
1313
###< friendsofphp/php-cs-fixer ###

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
declare(strict_types=1);
44

5-
$finder = PhpCsFixer\Finder::create()
6-
->in(__DIR__)
7-
;
5+
$config = new PhpCsFixer\Config();
6+
7+
$config->setFinder(
8+
PhpCsFixer\Finder::create()
9+
->in([
10+
__DIR__,
11+
])
12+
->notPath('src/ModelParser/JMSParserLegacy.php')
13+
);
814

9-
return PhpCsFixer\Config::create()
15+
$config
1016
->setRiskyAllowed(true)
1117
->setRules(
1218
[
@@ -48,7 +54,12 @@
4854

4955
// The convention with phpunit has been to use assertions with the object context.
5056
'php_unit_test_case_static_method_calls' => false,
57+
58+
// Not supported in PHP 7
59+
'get_class_to_class_keyword' => false,
60+
'modernize_strpos' => false,
5161
]
5262
)
53-
->setFinder($finder)
5463
;
64+
65+
return $config;

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
# 1.1.0 (unreleased)
4+
5+
* Drop support for PHP 7.2 and PHP 7.3
6+
* Support doctrine annotations `2.x`
7+
38
# 1.0.0
49

510
No changes since 0.6.1.

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
"issues": "https://github.com/liip/metadata-parser/issues"
1515
},
1616
"require": {
17-
"php": "^7.2 || ^8.0",
17+
"php": "^7.4 || ^8.0",
1818
"ext-json": "*",
19+
"doctrine/annotations": "^1.13 || ^2.0.1",
1920
"psr/log": "^1|^2|^3"
2021
},
2122
"require-dev": {
2223
"doctrine/collections": "^1.6",
23-
"friendsofphp/php-cs-fixer": "v2.18.7",
24+
"friendsofphp/php-cs-fixer": "v3.17.0",
2425
"jms/serializer": "^2.3 || ^3",
25-
"phpstan/phpstan": "^0.12.71",
26-
"phpstan/phpstan-phpunit": "^0.12",
26+
"phpstan/phpstan": "^1.0",
27+
"phpstan/phpstan-phpunit": "^1.0",
2728
"phpunit/phpunit": "^8.5.15 || ^9.5"
2829
},
2930
"suggest": {
@@ -45,7 +46,7 @@
4546
},
4647
"scripts": {
4748
"fix-cs": "vendor/bin/php-cs-fixer fix -v",
48-
"cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --diff --diff-format udiff -v",
49+
"cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --diff -v",
4950
"phpstan": "vendor/bin/phpstan analyse",
5051
"phpstan-tests": "vendor/bin/phpstan analyse -c phpstan.tests.neon",
5152
"phpstan-all": [

src/Annotation/Preferred.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* different versions with JMS serializer, and not specifying any version.
1212
*
1313
* @Annotation
14+
*
1415
* @Target({"METHOD", "PROPERTY"})
1516
*/
1617
final class Preferred

src/Metadata/AbstractPropertyMetadata.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class AbstractPropertyMetadata implements \JsonSerializable
4242
/**
4343
* @var int|null
4444
*/
45-
private $maxDepth = null;
45+
private $maxDepth;
4646

4747
/**
4848
* Hashmap of custom information about this property.
@@ -109,11 +109,11 @@ public function hasCustomInformation(string $key): bool
109109
/**
110110
* Get the value stored as custom information, if it exists.
111111
*
112-
* @throws \InvalidArgumentException if no such custom value is available for this property
113-
*
114112
* @return mixed The information in whatever format it has been set
113+
*
114+
* @throws \InvalidArgumentException if no such custom value is available for this property
115115
*/
116-
public function getCustomInformation(string $key)
116+
public function getCustomInformation(string $key): mixed
117117
{
118118
if (!\array_key_exists($key, $this->customInformation)) {
119119
throw new \InvalidArgumentException(sprintf('Property %s has no custom information %s', $this->name, $key));
@@ -206,7 +206,7 @@ protected function getMaxDepth(): ?int
206206
return $this->maxDepth;
207207
}
208208

209-
protected function setMaxDepth(?int $maxDepth)
209+
protected function setMaxDepth(?int $maxDepth): void
210210
{
211211
$this->maxDepth = $maxDepth;
212212
}

src/Metadata/PropertyAccessor.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@
66

77
final class PropertyAccessor implements \JsonSerializable
88
{
9-
/**
10-
* @var string|null
11-
*/
12-
private $getterMethod;
9+
private ?string $getterMethod;
1310

14-
/**
15-
* @var string|null
16-
*/
17-
private $setterMethod;
11+
private ?string $setterMethod;
1812

1913
public function __construct(?string $getterMethod, ?string $setterMethod)
2014
{
@@ -29,7 +23,7 @@ public static function none(): self
2923

3024
public function isDefined(): bool
3125
{
32-
return $this->hasGetterMethod() || $this->hasGetterMethod();
26+
return $this->hasGetterMethod() || $this->hasSetterMethod();
3327
}
3428

3529
public function hasGetterMethod(): bool
@@ -54,7 +48,7 @@ public function getSetterMethod(): ?string
5448

5549
public function jsonSerialize(): array
5650
{
57-
return \array_filter([
51+
return array_filter([
5852
'getter_method' => $this->getterMethod,
5953
'setter_method' => $this->setterMethod,
6054
]);

src/Metadata/PropertyMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
array $groups = [],
3333
PropertyAccessor $accessor = null,
3434
array $customInformation = [],
35-
?int $maxDepth = null
35+
int $maxDepth = null
3636
) {
3737
parent::__construct($name, $readOnly, $public);
3838
$this->serializedName = $serializedName;

0 commit comments

Comments
 (0)