Skip to content

Commit

Permalink
cs fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Apr 6, 2024
1 parent 9341e85 commit d368b9b
Show file tree
Hide file tree
Showing 26 changed files with 97 additions and 202 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Static analysis

on:
push:
branches:
- '[0-9]+.x'
- '[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.x'
pull_request:

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: "curl,dom,json,xml,dom"
coverage: none

- name: Checkout code
uses: actions/checkout@v4

# have to install phpstan ourselves here, the phpstan-ga fails at composer install with weird errors
# composer require --no-update jackalope/jackalope-doctrine-dbal jackalope/jackalope-jackrabbit phpstan/phpstan
- name: Install phpstan
run: |
composer update
- name: PHPStan
run: vendor/bin/phpstan analyze --no-progress

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --dry-run --diff
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ phpunit.xml
composer.lock
vendor
tests/Fixtures/App/var/
.phpunit.result.cache
.phpunit.result.cache
.php-cs-fixer.cache
19 changes: 19 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
->exclude('tests/Fixtures/App/var/')
->name('*.php')
;

$config = new PhpCsFixer\Config();

return $config
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'single_line_throw' => false,
])
->setFinder($finder)
;
31 changes: 0 additions & 31 deletions .styleci.yml

This file was deleted.

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"conflict": {
"doctrine/common": "<3.1.1",
"doctrine/persistence": "<1.3.0",
"doctrine/phpcr-odm": "<2.0",
"symfony/doctrine-bridge": "<6.4.0",
"symfony/security-core": "<6.4.0"
},
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/CmfRoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
*/
final class CmfRoutingExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration(new Configuration(), $configs);
Expand Down
2 changes: 0 additions & 2 deletions src/Doctrine/Orm/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ protected function getModelAndId(string $identifier): array
}

/**
* {@inheritdoc}
*
* @param string $id The ID contains both model name and id, separated by a colon
*/
public function findById(mixed $id): ?object
Expand Down
9 changes: 0 additions & 9 deletions src/Doctrine/Orm/RedirectRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public function setParameters(array $parameters): void
$this->serialisedParameters = json_encode($parameters, \JSON_THROW_ON_ERROR);
}

/**
* {@inheritdoc}
*/
public function getParameters(): array
{
if (!isset($this->serialisedParameters)) {
Expand All @@ -65,9 +62,6 @@ public function getParameters(): array
return \is_array($params) ? $params : [];
}

/**
* {@inheritdoc}
*/
public function getPath(): string
{
$pattern = parent::getPath();
Expand All @@ -78,9 +72,6 @@ public function getPath(): string
return $pattern;
}

/**
* {@inheritdoc}
*/
protected function isBooleanOption(string $name): bool
{
return 'add_trailing_slash' === $name || parent::isBooleanOption($name);
Expand Down
3 changes: 0 additions & 3 deletions src/Doctrine/Orm/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public function getPosition(): int
return $this->position;
}

/**
* {@inheritdoc}
*/
public function getRouteKey(): string
{
return $this->getName();
Expand Down
15 changes: 3 additions & 12 deletions src/Doctrine/Orm/RouteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public function __construct(ManagerRegistry $managerRegistry, CandidatesInterfac
$this->candidatesStrategy = $candidatesStrategy;
}

/**
* {@inheritdoc}
*/
public function getRouteCollectionForRequest(Request $request): RouteCollection
{
$collection = new RouteCollection();
Expand All @@ -52,7 +49,7 @@ public function getRouteCollectionForRequest(Request $request): RouteCollection
if (0 === \count($candidates)) {
return $collection;
}
$routes = $this->getRouteRepository()->findByStaticPrefix($candidates, ['position' => 'ASC']); /** @phpstan-ignore-line */
$routes = $this->getRouteRepository()->findByStaticPrefix($candidates, ['position' => 'ASC']); /* @phpstan-ignore-line */
/** @var Route $route */
foreach ($routes as $route) {
$collection->add($route->getName(), $route);
Expand All @@ -61,9 +58,6 @@ public function getRouteCollectionForRequest(Request $request): RouteCollection
return $collection;
}

/**
* {@inheritdoc}
*/
public function getRouteByName($name): SymfonyRoute
{
if (!$this->candidatesStrategy->isCandidate($name)) {
Expand All @@ -78,9 +72,6 @@ public function getRouteByName($name): SymfonyRoute
return $route;
}

/**
* {@inheritdoc}
*/
public function getRoutesByNames($names = null): array
{
if (null === $names) {
Expand All @@ -90,7 +81,7 @@ public function getRoutesByNames($names = null): array

try {
return $this->getRouteRepository()->findBy([], null, $this->routeCollectionLimit ?: null);
} catch (TableNotFoundException $e) {
} catch (TableNotFoundException) {
return [];
}
}
Expand All @@ -100,7 +91,7 @@ public function getRoutesByNames($names = null): array
// TODO: if we do findByName with multivalue, we need to filter with isCandidate afterwards
try {
$routes[] = $this->getRouteByName($name);
} catch (RouteNotFoundException $e) {
} catch (RouteNotFoundException) {
// not found
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/Doctrine/Phpcr/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@
*/
class ContentRepository extends DoctrineProvider implements ContentRepositoryInterface
{
/**
* {@inheritdoc}
*/
public function findById($id): ?object
{
return $this->getObjectManager()->find(null, $id);
}

/**
* {@inheritdoc}
*/
public function getContentId($content): ?string
{
if (!\is_object($content)) {
Expand Down
7 changes: 1 addition & 6 deletions src/Doctrine/Phpcr/PrefixCandidates.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class PrefixCandidates extends Candidates
* is using
* @param int $limit Limit to candidates generated per prefix
*/
public function __construct(array $prefixes, array $locales = [], ManagerRegistry $doctrine = null, int $limit = 20)
public function __construct(array $prefixes, array $locales = [], ?ManagerRegistry $doctrine = null, int $limit = 20)
{
parent::__construct($locales, $limit);
$this->setPrefixes($prefixes);
Expand All @@ -74,8 +74,6 @@ public function isCandidate($name): bool
}

/**
* {@inheritdoc}
*
* @param QueryBuilder $queryBuilder
*/
public function restrictQuery($queryBuilder): void
Expand All @@ -91,9 +89,6 @@ public function restrictQuery($queryBuilder): void
}
}

/**
* {@inheritdoc}
*/
public function getCandidates(Request $request): array
{
$candidates = [];
Expand Down
34 changes: 0 additions & 34 deletions src/Doctrine/Phpcr/RedirectRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,11 @@ public function setParentDocument($parent): static
return $this;
}

/**
* {@inheritdoc}
*/
public function getParentDocument(): ?object
{
return $this->parent;
}

/**
* @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface
* @see setParentDocument
*/
public function setParent($parent)
{
@trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 4.0. Use setParentDocument() instead.', \E_USER_DEPRECATED);

return $this->setParentDocument($parent);
}

/**
* @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface
* @see getParentDocument
*/
public function getParent()
{
@trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 4.0. Use getParentDocument() instead.', \E_USER_DEPRECATED);

return $this->getParentDocument();
}

/**
* Rename a route by setting its new name.
*
Expand Down Expand Up @@ -160,9 +135,6 @@ public function getPrefix(): string
return $this->idPrefix;
}

/**
* {@inheritdoc}
*/
public function setPrefix(string $prefix): static
{
$this->idPrefix = $prefix;
Expand Down Expand Up @@ -206,9 +178,6 @@ public function generateStaticPrefix(string $id, string $idPrefix): string
return $url;
}

/**
* {@inheritdoc}
*/
public function getPath(): string
{
$pattern = parent::getPath();
Expand Down Expand Up @@ -240,9 +209,6 @@ public function getRouteChildren(): array
return $children;
}

/**
* {@inheritdoc}
*/
protected function isBooleanOption(string $name): bool
{
return 'add_trailing_slash' === $name || parent::isBooleanOption($name);
Expand Down
28 changes: 0 additions & 28 deletions src/Doctrine/Phpcr/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,6 @@ public function getParentDocument(): object
return $this->parent;
}

/**
* @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface
* @see setParentDocument
*/
public function setParent($parent)
{
@trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 4.0. Use setParentDocument() instead.', \E_USER_DEPRECATED);

return $this->setParentDocument($parent);
}

/**
* @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface
* @see getParentDocument
*/
public function getParent()
{
@trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 4.0. Use getParentDocument() instead.', \E_USER_DEPRECATED);

return $this->getParentDocument();
}

/**
* Rename a route by setting its new name.
*
Expand Down Expand Up @@ -172,9 +150,6 @@ public function getPrefix(): ?string
return $this->idPrefix;
}

/**
* {@inheritdoc}
*/
public function setPrefix(string $prefix): static
{
$this->idPrefix = $prefix;
Expand Down Expand Up @@ -264,9 +239,6 @@ public function getChildren(): Collection
return $this->children;
}

/**
* {@inheritdoc}
*/
protected function isBooleanOption(string $name): bool
{
return 'add_trailing_slash' === $name || parent::isBooleanOption($name);
Expand Down
Loading

0 comments on commit d368b9b

Please sign in to comment.