Skip to content

Commit f6e4c59

Browse files
authored
Merge pull request #2630 from meyerbaptiste/quality_fixes
Various quality fixes
2 parents 049d5aa + 97fa954 commit f6e4c59

File tree

196 files changed

+465
-617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+465
-617
lines changed

.php_cs.dist

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ return PhpCsFixer\Config::create()
7878
'phpdoc_trim_consecutive_blank_line_separation' => true,
7979
'strict_comparison' => true,
8080
'strict_param' => true,
81+
'visibility_required' => [
82+
'elements' => [
83+
'const',
84+
'method',
85+
'property',
86+
],
87+
],
8188
'void_return' => false, // BC breaks; to be done in API Platform 3.0
8289
])
8390
->setFinder($finder)

src/Annotation/AttributesHydratorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ trait AttributesHydratorTrait
4242
/**
4343
* @throws InvalidArgumentException
4444
*/
45-
private function hydrateAttributes(array $values)
45+
private function hydrateAttributes(array $values): void
4646
{
4747
if (isset($values['attributes'])) {
4848
$this->attributes = $values['attributes'];

src/Api/CachedIdentifiersExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class CachedIdentifiersExtractor implements IdentifiersExtractorInterface
2828
{
2929
use ClassInfoTrait;
3030

31-
const CACHE_KEY_PREFIX = 'iri_identifiers';
31+
public const CACHE_KEY_PREFIX = 'iri_identifiers';
3232

3333
private $cacheItemPool;
3434
private $propertyAccessor;

src/Api/FilterLocatorTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ trait FilterLocatorTrait
3232
*
3333
* @param ContainerInterface|FilterCollection|null $filterLocator
3434
*/
35-
private function setFilterLocator($filterLocator = null, bool $allowNull = false)
35+
private function setFilterLocator($filterLocator, bool $allowNull = false): void
3636
{
3737
if ($filterLocator instanceof ContainerInterface || $filterLocator instanceof FilterCollection || (null === $filterLocator && $allowNull)) {
3838
if ($filterLocator instanceof FilterCollection) {
@@ -47,10 +47,8 @@ private function setFilterLocator($filterLocator = null, bool $allowNull = false
4747

4848
/**
4949
* Gets a filter with a backward compatibility.
50-
*
51-
* @return FilterInterface|null
5250
*/
53-
private function getFilter(string $filterId)
51+
private function getFilter(string $filterId): ?FilterInterface
5452
{
5553
if ($this->filterLocator instanceof ContainerInterface && $this->filterLocator->has($filterId)) {
5654
return $this->filterLocator->get($filterId);

src/Api/OperationType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
final class OperationType
1717
{
18-
const ITEM = 'item';
19-
const COLLECTION = 'collection';
20-
const SUBRESOURCE = 'subresource';
21-
const TYPES = [self::ITEM, self::COLLECTION, self::SUBRESOURCE];
18+
public const ITEM = 'item';
19+
public const COLLECTION = 'collection';
20+
public const SUBRESOURCE = 'subresource';
21+
public const TYPES = [self::ITEM, self::COLLECTION, self::SUBRESOURCE];
2222
}

src/Api/UrlGeneratorInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ interface UrlGeneratorInterface
3434
/**
3535
* Generates an absolute URL, e.g. "http://example.com/dir/file".
3636
*/
37-
const ABS_URL = 0;
37+
public const ABS_URL = 0;
3838

3939
/**
4040
* Generates an absolute path, e.g. "/dir/file".
4141
*/
42-
const ABS_PATH = 1;
42+
public const ABS_PATH = 1;
4343

4444
/**
4545
* Generates a relative path based on the current request path, e.g. "../parent-file".
4646
*
4747
* @see UrlGenerator::getRelativePath()
4848
*/
49-
const REL_PATH = 2;
49+
public const REL_PATH = 2;
5050

5151
/**
5252
* Generates a network path, e.g. "//example.com/dir/file".
5353
* Such reference reuses the current scheme but specifies the host.
5454
*/
55-
const NET_PATH = 3;
55+
public const NET_PATH = 3;
5656

5757
/**
5858
* Generates a URL or path for a specific route based on the given parameters.

src/Bridge/Doctrine/Common/DataPersister.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,16 @@ public function remove($data, array $context = [])
7777

7878
/**
7979
* Gets the Doctrine object manager associated with given data.
80-
*
81-
* @return DoctrineObjectManager|null
8280
*/
83-
private function getManager($data)
81+
private function getManager($data): ?DoctrineObjectManager
8482
{
8583
return \is_object($data) ? $this->managerRegistry->getManagerForClass($this->getObjectClass($data)) : null;
8684
}
8785

8886
/**
8987
* Checks if doctrine does not manage data automatically.
90-
*
91-
* @return bool
9288
*/
93-
private function isDeferredExplicit(DoctrineObjectManager $manager, $data)
89+
private function isDeferredExplicit(DoctrineObjectManager $manager, $data): bool
9490
{
9591
$classMetadata = $manager->getClassMetadata($this->getObjectClass($data));
9692
if ($classMetadata instanceof ClassMetadataInfo && method_exists($classMetadata, 'isChangeTrackingDeferredExplicit')) {

src/Bridge/Doctrine/Common/Filter/DateFilterInterface.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
*/
2323
interface DateFilterInterface
2424
{
25-
const PARAMETER_BEFORE = 'before';
26-
const PARAMETER_STRICTLY_BEFORE = 'strictly_before';
27-
const PARAMETER_AFTER = 'after';
28-
const PARAMETER_STRICTLY_AFTER = 'strictly_after';
29-
const EXCLUDE_NULL = 'exclude_null';
30-
const INCLUDE_NULL_BEFORE = 'include_null_before';
31-
const INCLUDE_NULL_AFTER = 'include_null_after';
32-
const INCLUDE_NULL_BEFORE_AND_AFTER = 'include_null_before_and_after';
25+
public const PARAMETER_BEFORE = 'before';
26+
public const PARAMETER_STRICTLY_BEFORE = 'strictly_before';
27+
public const PARAMETER_AFTER = 'after';
28+
public const PARAMETER_STRICTLY_AFTER = 'strictly_after';
29+
public const EXCLUDE_NULL = 'exclude_null';
30+
public const INCLUDE_NULL_BEFORE = 'include_null_before';
31+
public const INCLUDE_NULL_AFTER = 'include_null_after';
32+
public const INCLUDE_NULL_BEFORE_AND_AFTER = 'include_null_before_and_after';
3333
}

src/Bridge/Doctrine/Common/Filter/ExistsFilterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
*/
2222
interface ExistsFilterInterface
2323
{
24-
const QUERY_PARAMETER_KEY = 'exists';
24+
public const QUERY_PARAMETER_KEY = 'exists';
2525
}

src/Bridge/Doctrine/Common/Filter/OrderFilterInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
*/
2323
interface OrderFilterInterface
2424
{
25-
const DIRECTION_ASC = 'ASC';
26-
const DIRECTION_DESC = 'DESC';
27-
const NULLS_SMALLEST = 'nulls_smallest';
28-
const NULLS_LARGEST = 'nulls_largest';
29-
const NULLS_DIRECTION_MAP = [
25+
public const DIRECTION_ASC = 'ASC';
26+
public const DIRECTION_DESC = 'DESC';
27+
public const NULLS_SMALLEST = 'nulls_smallest';
28+
public const NULLS_LARGEST = 'nulls_largest';
29+
public const NULLS_DIRECTION_MAP = [
3030
self::NULLS_SMALLEST => [
3131
'ASC' => 'ASC',
3232
'DESC' => 'DESC',

0 commit comments

Comments
 (0)