Skip to content

Commit

Permalink
Merge pull request #408 from vincentchalamon/fix/cs
Browse files Browse the repository at this point in the history
Fix CS
  • Loading branch information
vincentchalamon authored Jun 29, 2023
2 parents 2f70987 + 3adab34 commit 7d0a356
Show file tree
Hide file tree
Showing 39 changed files with 59 additions and 188 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
COVERAGE: '0'

Expand All @@ -25,7 +29,7 @@ jobs:

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

- uses: actions/cache@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 5.2.0

* feat: improve type detection

## 5.1.1

* fix: missing unique for self-referencing relations
Expand Down
4 changes: 2 additions & 2 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function (string $filePath, string $prefix, string $content): string {
// TODO: Temporary patch until the issue is fixed upstream
// @link https://github.com/humbug/php-scoper/issues/285
function (string $filePath, string $prefix, string $content): string {
if (false === strpos($content, '@')) {
if (!str_contains($content, '@')) {
return $content;
}

Expand All @@ -52,7 +52,7 @@ function (string $filePath, string $prefix, string $content): string {
);
},
function (string $filePath, string $prefix, string $content): string {
if (0 !== strpos($filePath, 'src/AnnotationGenerator/')) {
if (!str_starts_with($filePath, 'src/AnnotationGenerator/')) {
return $content;
}

Expand Down
27 changes: 0 additions & 27 deletions src/AnnotationGenerator/AbstractAnnotationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,73 +48,46 @@ public function __construct(PhpTypeConverterInterface $phpTypeConverter, Inflect
$this->classes = $classes;
}

/**
* {@inheritdoc}
*/
public function generateClassAnnotations(Class_ $class): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateInterfaceAnnotations(Class_ $class): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateConstantAnnotations(Constant $constant): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generatePropertyAnnotations(Property $property, string $className): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateGetterAnnotations(Property $property): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateSetterAnnotations(Property $property): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateAdderAnnotations(Property $property): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateRemoverAnnotations(Property $property): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateUses(Class_ $class): array
{
return [];
Expand Down
27 changes: 0 additions & 27 deletions src/AnnotationGenerator/PhpDocAnnotationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,23 @@ final class PhpDocAnnotationGenerator extends AbstractAnnotationGenerator

private HtmlConverter $htmlToMarkdown;

/**
* {@inheritdoc}
*/
public function __construct(PhpTypeConverterInterface $phpTypeConverter, InflectorInterface $inflector, array $config, array $classes)
{
parent::__construct($phpTypeConverter, $inflector, $config, $classes);

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

/**
* {@inheritdoc}
*/
public function generateClassAnnotations(Class_ $class): array
{
return $this->generateDoc($class);
}

/**
* {@inheritdoc}
*/
public function generateInterfaceAnnotations(Class_ $class): array
{
return $this->generateDoc($class, true);
}

/**
* {@inheritdoc}
*/
public function generateConstantAnnotations(Constant $constant): array
{
$annotations = $this->formatDoc($constant->comment(), true);
Expand All @@ -68,9 +56,6 @@ public function generateConstantAnnotations(Constant $constant): array
return $annotations;
}

/**
* {@inheritdoc}
*/
public function generatePropertyAnnotations(Property $property, string $className): array
{
$description = $this->formatDoc((string) $property->description(), true);
Expand All @@ -92,9 +77,6 @@ public function generatePropertyAnnotations(Property $property, string $classNam
return $annotations;
}

/**
* {@inheritdoc}
*/
public function generateGetterAnnotations(Property $property): array
{
if (!$this->isDocUseful($property)) {
Expand All @@ -104,9 +86,6 @@ public function generateGetterAnnotations(Property $property): array
return [sprintf('@return %s', $this->toPhpDocType($property))];
}

/**
* {@inheritdoc}
*/
public function generateSetterAnnotations(Property $property): array
{
if (!$this->isDocUseful($property)) {
Expand All @@ -116,9 +95,6 @@ public function generateSetterAnnotations(Property $property): array
return [sprintf('@param %s $%s', $this->toPhpDocType($property), $property->name())];
}

/**
* {@inheritdoc}
*/
public function generateAdderAnnotations(Property $property): array
{
if (!$this->isDocUseful($property, true)) {
Expand All @@ -128,9 +104,6 @@ public function generateAdderAnnotations(Property $property): array
return [sprintf('@param %s $%s', $this->toPhpDocType($property, true), $this->inflector->singularize($property->name())[0])];
}

/**
* {@inheritdoc}
*/
public function generateRemoverAnnotations(Property $property): array
{
if (!$this->isDocUseful($property, true)) {
Expand Down
12 changes: 0 additions & 12 deletions src/AttributeGenerator/AbstractAttributeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,21 @@ public function __construct(PhpTypeConverterInterface $phpTypeConverter, Inflect
$this->classes = $classes;
}

/**
* {@inheritdoc}
*/
public function generateClassAttributes(Class_ $class): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generatePropertyAttributes(Property $property, string $className): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateLateClassAttributes(Class_ $class): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function generateUses(Class_ $class): array
{
return [];
Expand Down
9 changes: 0 additions & 9 deletions src/AttributeGenerator/ApiPlatformCoreAttributeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
*/
final class ApiPlatformCoreAttributeGenerator extends AbstractAttributeGenerator
{
/**
* {@inheritdoc}
*/
public function generateClassAttributes(Class_ $class): array
{
if ($class->hasChild || $class->isEnum()) {
Expand Down Expand Up @@ -110,9 +107,6 @@ private function validateClassOperations(array $operations): array
return $resolver->resolve($operations);
}

/**
* {@inheritdoc}
*/
public function generatePropertyAttributes(Property $property, string $className): array
{
$arguments = [];
Expand All @@ -128,9 +122,6 @@ public function generatePropertyAttributes(Property $property, string $className
return $property->isCustom ? [] : [new Attribute('ApiProperty', $arguments)];
}

/**
* {@inheritdoc}
*/
public function generateUses(Class_ $class): array
{
if ($this->config['apiPlatformOldAttributes']) {
Expand Down
13 changes: 2 additions & 11 deletions src/AttributeGenerator/ConfigurationAttributeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

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

/**
* {@inheritdoc}
*/
public function generatePropertyAttributes(Property $property, string $className): array
{
$typeConfig = $this->config['types'][$className] ?? null;
Expand All @@ -90,9 +84,6 @@ public function generatePropertyAttributes(Property $property, string $className
return $attributes;
}

/**
* {@inheritdoc}
*/
public function generateUses(Class_ $class): array
{
$uses = [];
Expand Down
9 changes: 0 additions & 9 deletions src/AttributeGenerator/ConstraintAttributeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
*/
final class ConstraintAttributeGenerator extends AbstractAttributeGenerator
{
/**
* {@inheritdoc}
*/
public function generatePropertyAttributes(Property $property, string $className): array
{
if ($property->isId) {
Expand Down Expand Up @@ -84,9 +81,6 @@ public function generatePropertyAttributes(Property $property, string $className
return $asserts;
}

/**
* {@inheritdoc}
*/
public function generateUses(Class_ $class): array
{
if ($class->isEnum()) {
Expand All @@ -113,9 +107,6 @@ public function generateUses(Class_ $class): array
return $uses;
}

/**
* {@inheritdoc}
*/
public function generateClassAttributes(Class_ $class): array
{
if ($class->isEnum()) {
Expand Down
9 changes: 0 additions & 9 deletions src/AttributeGenerator/DoctrineMongoDBAttributeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
*/
final class DoctrineMongoDBAttributeGenerator extends AbstractAttributeGenerator
{
/**
* {@inheritdoc}
*/
public function generateClassAttributes(Class_ $class): array
{
if ($class->isEnum()) {
Expand Down Expand Up @@ -72,9 +69,6 @@ public function generateClassAttributes(Class_ $class): array
return $attributes;
}

/**
* {@inheritdoc}
*/
public function generatePropertyAttributes(Property $property, string $className): array
{
if (null === $property->type && null === $property->reference) {
Expand Down Expand Up @@ -146,9 +140,6 @@ public function generatePropertyAttributes(Property $property, string $className
return [];
}

/**
* {@inheritdoc}
*/
public function generateUses(Class_ $class): array
{
return $class->isEnum() ? [] : [new Use_('Doctrine\ODM\MongoDB\Mapping\Annotations', 'MongoDB')];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ final class DoctrineOrmAssociationOverrideAttributeGenerator extends AbstractAtt
{
use GenerateIdentifierNameTrait;

/**
* {@inheritdoc}
*/
public function generateLateClassAttributes(Class_ $class): array
{
if ($class->isAbstract || !($parentName = $class->parent())) {
Expand Down
Loading

0 comments on commit 7d0a356

Please sign in to comment.