Skip to content

Commit 7d0a356

Browse files
Merge pull request #408 from vincentchalamon/fix/cs
Fix CS
2 parents 2f70987 + 3adab34 commit 7d0a356

39 files changed

+59
-188
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
pull_request:
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
711
env:
812
COVERAGE: '0'
913

@@ -25,7 +29,7 @@ jobs:
2529

2630
- name: Get Composer Cache Directory
2731
id: composer-cache
28-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
32+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
2933

3034
- uses: actions/cache@v3
3135
with:

CHANGELOG.md

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

3+
## 5.2.0
4+
5+
* feat: improve type detection
6+
37
## 5.1.1
48

59
* fix: missing unique for self-referencing relations

scoper.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function (string $filePath, string $prefix, string $content): string {
3636
// TODO: Temporary patch until the issue is fixed upstream
3737
// @link https://github.com/humbug/php-scoper/issues/285
3838
function (string $filePath, string $prefix, string $content): string {
39-
if (false === strpos($content, '@')) {
39+
if (!str_contains($content, '@')) {
4040
return $content;
4141
}
4242

@@ -52,7 +52,7 @@ function (string $filePath, string $prefix, string $content): string {
5252
);
5353
},
5454
function (string $filePath, string $prefix, string $content): string {
55-
if (0 !== strpos($filePath, 'src/AnnotationGenerator/')) {
55+
if (!str_starts_with($filePath, 'src/AnnotationGenerator/')) {
5656
return $content;
5757
}
5858

src/AnnotationGenerator/AbstractAnnotationGenerator.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,73 +48,46 @@ public function __construct(PhpTypeConverterInterface $phpTypeConverter, Inflect
4848
$this->classes = $classes;
4949
}
5050

51-
/**
52-
* {@inheritdoc}
53-
*/
5451
public function generateClassAnnotations(Class_ $class): array
5552
{
5653
return [];
5754
}
5855

59-
/**
60-
* {@inheritdoc}
61-
*/
6256
public function generateInterfaceAnnotations(Class_ $class): array
6357
{
6458
return [];
6559
}
6660

67-
/**
68-
* {@inheritdoc}
69-
*/
7061
public function generateConstantAnnotations(Constant $constant): array
7162
{
7263
return [];
7364
}
7465

75-
/**
76-
* {@inheritdoc}
77-
*/
7866
public function generatePropertyAnnotations(Property $property, string $className): array
7967
{
8068
return [];
8169
}
8270

83-
/**
84-
* {@inheritdoc}
85-
*/
8671
public function generateGetterAnnotations(Property $property): array
8772
{
8873
return [];
8974
}
9075

91-
/**
92-
* {@inheritdoc}
93-
*/
9476
public function generateSetterAnnotations(Property $property): array
9577
{
9678
return [];
9779
}
9880

99-
/**
100-
* {@inheritdoc}
101-
*/
10281
public function generateAdderAnnotations(Property $property): array
10382
{
10483
return [];
10584
}
10685

107-
/**
108-
* {@inheritdoc}
109-
*/
11086
public function generateRemoverAnnotations(Property $property): array
11187
{
11288
return [];
11389
}
11490

115-
/**
116-
* {@inheritdoc}
117-
*/
11891
public function generateUses(Class_ $class): array
11992
{
12093
return [];

src/AnnotationGenerator/PhpDocAnnotationGenerator.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,23 @@ final class PhpDocAnnotationGenerator extends AbstractAnnotationGenerator
3131

3232
private HtmlConverter $htmlToMarkdown;
3333

34-
/**
35-
* {@inheritdoc}
36-
*/
3734
public function __construct(PhpTypeConverterInterface $phpTypeConverter, InflectorInterface $inflector, array $config, array $classes)
3835
{
3936
parent::__construct($phpTypeConverter, $inflector, $config, $classes);
4037

4138
$this->htmlToMarkdown = new HtmlConverter();
4239
}
4340

44-
/**
45-
* {@inheritdoc}
46-
*/
4741
public function generateClassAnnotations(Class_ $class): array
4842
{
4943
return $this->generateDoc($class);
5044
}
5145

52-
/**
53-
* {@inheritdoc}
54-
*/
5546
public function generateInterfaceAnnotations(Class_ $class): array
5647
{
5748
return $this->generateDoc($class, true);
5849
}
5950

60-
/**
61-
* {@inheritdoc}
62-
*/
6351
public function generateConstantAnnotations(Constant $constant): array
6452
{
6553
$annotations = $this->formatDoc($constant->comment(), true);
@@ -68,9 +56,6 @@ public function generateConstantAnnotations(Constant $constant): array
6856
return $annotations;
6957
}
7058

71-
/**
72-
* {@inheritdoc}
73-
*/
7459
public function generatePropertyAnnotations(Property $property, string $className): array
7560
{
7661
$description = $this->formatDoc((string) $property->description(), true);
@@ -92,9 +77,6 @@ public function generatePropertyAnnotations(Property $property, string $classNam
9277
return $annotations;
9378
}
9479

95-
/**
96-
* {@inheritdoc}
97-
*/
9880
public function generateGetterAnnotations(Property $property): array
9981
{
10082
if (!$this->isDocUseful($property)) {
@@ -104,9 +86,6 @@ public function generateGetterAnnotations(Property $property): array
10486
return [sprintf('@return %s', $this->toPhpDocType($property))];
10587
}
10688

107-
/**
108-
* {@inheritdoc}
109-
*/
11089
public function generateSetterAnnotations(Property $property): array
11190
{
11291
if (!$this->isDocUseful($property)) {
@@ -116,9 +95,6 @@ public function generateSetterAnnotations(Property $property): array
11695
return [sprintf('@param %s $%s', $this->toPhpDocType($property), $property->name())];
11796
}
11897

119-
/**
120-
* {@inheritdoc}
121-
*/
12298
public function generateAdderAnnotations(Property $property): array
12399
{
124100
if (!$this->isDocUseful($property, true)) {
@@ -128,9 +104,6 @@ public function generateAdderAnnotations(Property $property): array
128104
return [sprintf('@param %s $%s', $this->toPhpDocType($property, true), $this->inflector->singularize($property->name())[0])];
129105
}
130106

131-
/**
132-
* {@inheritdoc}
133-
*/
134107
public function generateRemoverAnnotations(Property $property): array
135108
{
136109
if (!$this->isDocUseful($property, true)) {

src/AttributeGenerator/AbstractAttributeGenerator.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,21 @@ public function __construct(PhpTypeConverterInterface $phpTypeConverter, Inflect
4747
$this->classes = $classes;
4848
}
4949

50-
/**
51-
* {@inheritdoc}
52-
*/
5350
public function generateClassAttributes(Class_ $class): array
5451
{
5552
return [];
5653
}
5754

58-
/**
59-
* {@inheritdoc}
60-
*/
6155
public function generatePropertyAttributes(Property $property, string $className): array
6256
{
6357
return [];
6458
}
6559

66-
/**
67-
* {@inheritdoc}
68-
*/
6960
public function generateLateClassAttributes(Class_ $class): array
7061
{
7162
return [];
7263
}
7364

74-
/**
75-
* {@inheritdoc}
76-
*/
7765
public function generateUses(Class_ $class): array
7866
{
7967
return [];

src/AttributeGenerator/ApiPlatformCoreAttributeGenerator.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
*/
4040
final class ApiPlatformCoreAttributeGenerator extends AbstractAttributeGenerator
4141
{
42-
/**
43-
* {@inheritdoc}
44-
*/
4542
public function generateClassAttributes(Class_ $class): array
4643
{
4744
if ($class->hasChild || $class->isEnum()) {
@@ -110,9 +107,6 @@ private function validateClassOperations(array $operations): array
110107
return $resolver->resolve($operations);
111108
}
112109

113-
/**
114-
* {@inheritdoc}
115-
*/
116110
public function generatePropertyAttributes(Property $property, string $className): array
117111
{
118112
$arguments = [];
@@ -128,9 +122,6 @@ public function generatePropertyAttributes(Property $property, string $className
128122
return $property->isCustom ? [] : [new Attribute('ApiProperty', $arguments)];
129123
}
130124

131-
/**
132-
* {@inheritdoc}
133-
*/
134125
public function generateUses(Class_ $class): array
135126
{
136127
if ($this->config['apiPlatformOldAttributes']) {

src/AttributeGenerator/ConfigurationAttributeGenerator.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
final class ConfigurationAttributeGenerator extends AbstractAttributeGenerator
2323
{
24-
/**
25-
* {@inheritdoc}
26-
*/
2724
public function generateClassAttributes(Class_ $class): array
2825
{
2926
$typeAttributes = $this->config['types'][$class->name()]['attributes'] ?? [[]];
@@ -44,8 +41,8 @@ public function generateClassAttributes(Class_ $class): array
4441
// An attribute from a vocabulary cannot be appended if a same one has not
4542
// previously been generated or if the same one is not mergeable.
4643
// It allows vocabulary attributes configuration to only merge the attributes args.
47-
'alwaysGenerate' => !\in_array($name, $vocabAttributesNames, true) ||
48-
\in_array($name, $typeAttributesNames, true),
44+
'alwaysGenerate' => !\in_array($name, $vocabAttributesNames, true)
45+
|| \in_array($name, $typeAttributesNames, true),
4946
// Custom explicitly configured attributes is not mergeable with next one
5047
// but treated as repeated if given more than once.
5148
'mergeable' => false,
@@ -69,9 +66,6 @@ public function generateClassAttributes(Class_ $class): array
6966
return $attributes;
7067
}
7168

72-
/**
73-
* {@inheritdoc}
74-
*/
7569
public function generatePropertyAttributes(Property $property, string $className): array
7670
{
7771
$typeConfig = $this->config['types'][$className] ?? null;
@@ -90,9 +84,6 @@ public function generatePropertyAttributes(Property $property, string $className
9084
return $attributes;
9185
}
9286

93-
/**
94-
* {@inheritdoc}
95-
*/
9687
public function generateUses(Class_ $class): array
9788
{
9889
$uses = [];

src/AttributeGenerator/ConstraintAttributeGenerator.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
*/
2828
final class ConstraintAttributeGenerator extends AbstractAttributeGenerator
2929
{
30-
/**
31-
* {@inheritdoc}
32-
*/
3330
public function generatePropertyAttributes(Property $property, string $className): array
3431
{
3532
if ($property->isId) {
@@ -84,9 +81,6 @@ public function generatePropertyAttributes(Property $property, string $className
8481
return $asserts;
8582
}
8683

87-
/**
88-
* {@inheritdoc}
89-
*/
9084
public function generateUses(Class_ $class): array
9185
{
9286
if ($class->isEnum()) {
@@ -113,9 +107,6 @@ public function generateUses(Class_ $class): array
113107
return $uses;
114108
}
115109

116-
/**
117-
* {@inheritdoc}
118-
*/
119110
public function generateClassAttributes(Class_ $class): array
120111
{
121112
if ($class->isEnum()) {

src/AttributeGenerator/DoctrineMongoDBAttributeGenerator.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
*/
3131
final class DoctrineMongoDBAttributeGenerator extends AbstractAttributeGenerator
3232
{
33-
/**
34-
* {@inheritdoc}
35-
*/
3633
public function generateClassAttributes(Class_ $class): array
3734
{
3835
if ($class->isEnum()) {
@@ -72,9 +69,6 @@ public function generateClassAttributes(Class_ $class): array
7269
return $attributes;
7370
}
7471

75-
/**
76-
* {@inheritdoc}
77-
*/
7872
public function generatePropertyAttributes(Property $property, string $className): array
7973
{
8074
if (null === $property->type && null === $property->reference) {
@@ -146,9 +140,6 @@ public function generatePropertyAttributes(Property $property, string $className
146140
return [];
147141
}
148142

149-
/**
150-
* {@inheritdoc}
151-
*/
152143
public function generateUses(Class_ $class): array
153144
{
154145
return $class->isEnum() ? [] : [new Use_('Doctrine\ODM\MongoDB\Mapping\Annotations', 'MongoDB')];

0 commit comments

Comments
 (0)