Commit 4476805d authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

PHP CS.

parent 615bb318
......@@ -10,9 +10,10 @@ $finder = PhpCsFixer\Finder::create()
$loader = require __DIR__ . '/vendor/autoload.php';
try {
return Irstea\CS\Config::create()
->setIndent(' ')
->setLineEnding("\n")
->setFinder($finder);
->setIndent(' ')
->SetRiskyAllowed(true)
->setLineEnding("\n")
->setFinder($finder);
} finally {
$loader->unregister();
}
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -38,7 +39,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* Class NgModelGenerateCommand.
*/
/* final */class NgModelGenerateCommand extends Command
/* final */ class NgModelGenerateCommand extends Command
{
/**
* @var ModelGenerator
......@@ -66,7 +67,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setName('ng-model:generate')
......@@ -80,7 +81,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$writer = new PhonyFileWriter(
$this->openWriter($input, $output),
......@@ -94,7 +95,7 @@ use Symfony\Component\Console\Output\OutputInterface;
$writer = new FilteringFileWriter($writer, function (string $path) use ($globs): bool {
foreach ($globs as $glob) {
if (fnmatch($glob, $path, FNM_PATHNAME)) {
if (fnmatch($glob, $path, \FNM_PATHNAME)) {
return true;
}
}
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -61,7 +62,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setName('ng-model:metadata')
......@@ -72,7 +73,7 @@ use Symfony\Component\Console\Output\OutputInterface;
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$classes = $input->getArgument('classes');
Assertion::isArray($classes);
......@@ -87,7 +88,7 @@ use Symfony\Component\Console\Output\OutputInterface;
$metadata[$class->getBaseName()] = $this->metadataFactory->getResourceMetadata($class);
}
$json = \json_encode($metadata, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
$json = json_encode($metadata, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
Assertion::string($json);
$output->writeln($json);
}
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -34,7 +35,7 @@ class NgModelGeneratorExtension extends Extension
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('config.xml');
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -55,7 +56,7 @@ class CallbackFilterRecursorIterator extends RecursorIterator
/**
* @param \Iterator $iter
*/
protected function doGetChildren(\Traversable $iter): \RecursiveIterator
protected function doGetChildren(Traversable $iter): \RecursiveIterator
{
return new self($iter, $this->filter);
}
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -49,7 +50,7 @@ final class UniqueFilter
private function getKey($value): string
{
if (\is_object($value)) {
return \get_class($value) . '#' . \spl_object_hash($value);
return \get_class($value) . '#' . spl_object_hash($value);
}
if (\is_array($value)) {
return 'array#' . implode(', ', array_map(
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -44,7 +45,7 @@ use Symfony\Component\Routing\RouterInterface;
* Class MetadataFactory
* Cette classe est chargée de collecter les métadonnées des différents services d'API-Platform.
*/
/* final */class MetadataFactory implements MetadataFactoryInterface
/* final */ class MetadataFactory implements MetadataFactoryInterface
{
/** @var ResourceClassResolverInterface */
private $resourceClassResolver;
......@@ -235,7 +236,7 @@ use Symfony\Component\Routing\RouterInterface;
$output = $getAttribute('output', null);
$normalization = null;
if ($output !== false) {
if (is_array($output) && array_key_exists('class', $output)) {
if (\is_array($output) && \array_key_exists('class', $output)) {
$output = $output['class'];
} elseif ($output === null && $opDef->hasNormalization()) {
$output = $class->getFullName();
......@@ -253,7 +254,7 @@ use Symfony\Component\Routing\RouterInterface;
$input = $getAttribute('input', null);
$denormalization = null;
if ($input !== false) {
if (is_array($input) && array_key_exists('class', $input)) {
if (\is_array($input) && \array_key_exists('class', $input)) {
$input = $input['class'];
} elseif ($input === null && $opDef->hasDenormalization()) {
$input = $class->getFullName();
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -52,8 +53,8 @@ final class OperationDef implements \JsonSerializable, HasName
$this->originalName = $name;
$this->method = $method;
if (\strtolower($method) === \strtolower($name)) {
$this->special = \strtoupper($method);
if (strtolower($method) === strtolower($name)) {
$this->special = strtoupper($method);
if ($method === 'POST') {
$isCollection = false;
}
......@@ -151,6 +152,6 @@ final class OperationDef implements \JsonSerializable, HasName
*/
public function jsonSerialize()
{
return \get_object_vars($this);
return get_object_vars($this);
}
}
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -215,7 +216,7 @@ class OperationMetadata implements \JsonSerializable, HasName
{
$vars = array_merge(
$this->opDef->jsonSerialize(),
\get_object_vars($this)
get_object_vars($this)
);
unset($vars['resource'], $vars['opDef']);
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -88,6 +89,6 @@ final class PaginationMetadata implements \JsonSerializable
*/
public function jsonSerialize()
{
return \get_object_vars($this);
return get_object_vars($this);
}
}
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -180,7 +181,7 @@ class PropertyMetadata implements \JsonSerializable, HasName
*/
public function jsonSerialize()
{
$vars = \get_object_vars($this);
$vars = get_object_vars($this);
$vars['type'] = $this->serializeType($this->type);
unset($vars['resource']);
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -161,6 +162,6 @@ final class RepresentationMetadata implements ClassName, HasName
*/
public function jsonSerialize()
{
return \get_object_vars($this);
return get_object_vars($this);
}
}
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -158,6 +159,6 @@ class ResourceMetadata implements ClassName
*/
public function jsonSerialize()
{
return \get_object_vars($this);
return get_object_vars($this);
}
}
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/*
* This file is part of "irstea/ng-model-generator-bundle".
*
* "irstea/ng-model-generator-bundle" generates Typescript interfaces for Angular using api-platform metadata.
* Copyright (C) 2018-2020 IRSTEA
* Copyright (C) 2018-2021 IRSTEA
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
......@@ -146,7 +147,7 @@ final class SerializationMetadata implements ClassName
$subclasses = [];