Skip to content

Commit 1119c41

Browse files
GinoPaneAndrey Semikov
and
Andrey Semikov
authored
Bump code style to PSR12 (#2)
* Bump code style to PSR12 * Add missing PSR12 reference * Fix bcmul usage * Remove docker certificates promotion * Fix round usage * Add more spaces * Fix test float mapping --------- Co-authored-by: Andrey Semikov <andrey.semikov@dealtrak.co.uk>
1 parent 9354caf commit 1119c41

File tree

113 files changed

+259
-27
lines changed

Some content is hidden

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

113 files changed

+259
-27
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ jobs:
2727
uses: php-actions/phpcs@v1
2828
with:
2929
php_version: 8.1
30-
path: src/
31-
standard: PSR2
30+
standard: phpcs.xml
3231

3332
tests:
3433
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ docker-compose run dynamodb-odm vendor/bin/behat -c behat.yml --stop-on-failure
5252

5353
You need to check if the code style is OK by running:
5454
```bash
55-
docker-compose run --no-deps dynamodb-odm vendor/bin/phpcs --basepath=/application/src --standard=PSR2 src
55+
docker-compose run --no-deps dynamodb-odm vendor/bin/phpcs --standard=/application/phpcs.xml
5656
```

phpcs.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0"?>
2+
<!-- @see https://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php -->
3+
<ruleset name= "PHPCS Rules">
4+
<description>PHPCS ruleset for the DynamoDB ODM</description>
5+
6+
<file>src</file>
7+
8+
<!-- Show progress of the run -->
9+
<arg value= "p"/>
10+
11+
<!-- Show sniff codes in all reports -->
12+
<arg value= "s"/>
13+
14+
<!-- Ignore warnings -->
15+
<arg value= "n"/>
16+
17+
<!-- Our base rule: set to PSR12 -->
18+
<rule ref="PSR12" />
19+
20+
<rule ref= "Generic.Files.LineLength">
21+
<properties>
22+
<property name="lineLimit" value="80"/>
23+
<property name="absoluteLineLimit" value="120"/>
24+
</properties>
25+
</rule>
26+
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
27+
<exclude-pattern>spec/</exclude-pattern>
28+
<exclude-pattern>features/</exclude-pattern>
29+
</rule>
30+
31+
<!-- All files MUST declare strict types. -->
32+
<rule ref="Generic.PHP.RequireStrictTypes"/>
33+
34+
<rule ref="Generic.Files.LineEndings">
35+
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
36+
</rule>
37+
</ruleset>

spec/Repository/fixtures/NewModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class NewModel extends Model
4747
/**
4848
* @var float
4949
*
50-
* @Types\NumberType
50+
* @Types\FloatType
5151
*/
5252
protected float $percent;
5353

src/Annotation/AnnotationManager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation;
46

57
use Autoprotect\DynamodbODM\Annotation\Exception\NoPropertyFoundException;

src/Annotation/AnnotationManagerInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation;
46

57
use Autoprotect\DynamodbODM\Annotation\Property\PropertyInterface;

src/Annotation/Exception/AnnotationLogicException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88

99
class AnnotationLogicException extends DynamoDbAdapterException
1010
{
11-
1211
}

src/Annotation/Exception/DuplicatePrivatePropertyException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Exception;
46

57
use Autoprotect\DynamodbODM\Exception\DynamoDbAdapterException;

src/Annotation/Exception/EncryptionTypeNotSupportedException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88

99
class EncryptionTypeNotSupportedException extends DynamoDbAdapterException
1010
{
11-
1211
}

src/Annotation/Exception/NoEncryptionOptionsDefinedForProperty.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
65
namespace Autoprotect\DynamodbODM\Annotation\Exception;
76

87
use Autoprotect\DynamodbODM\Exception\DynamoDbAdapterException;

src/Annotation/Exception/NoTypeDefinedForPropertyException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88

99
class NoTypeDefinedForPropertyException extends DynamoDbAdapterException
1010
{
11-
1211
}

src/Annotation/Key/Primary.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Key;
46

57
use Doctrine\Common\Annotations\Annotation;
@@ -19,5 +21,4 @@
1921
#[Attribute(Attribute::TARGET_PROPERTY)]
2022
class Primary
2123
{
22-
2324
}

src/Annotation/Key/Sort.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Key;
46

57
use Attribute;

src/Annotation/ModelAnnotationProcessor.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation;
46

57
use Autoprotect\DynamodbODM\Annotation\Encryption\EncryptedPropertyInterface;
@@ -95,9 +97,11 @@ public function parseAnnotations(): void
9597
return;
9698
}
9799

98-
foreach ($this->getParentClassPrivateProperties(
99-
$refClass->getParentClass()->getName()
100-
) as $parentProperty) {
100+
foreach (
101+
$this->getParentClassPrivateProperties(
102+
$refClass->getParentClass()->getName()
103+
) as $parentProperty
104+
) {
101105
$annotationProperty = $this->buildAnnotationProperty($parentProperty);
102106

103107
if (!is_null($annotationProperty)) {

src/Annotation/ModelAnnotationProcessorInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation;
46

57
use Autoprotect\DynamodbODM\Annotation\Property\AnnotationProperty;

src/Annotation/Types/BooleanType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/CollectionType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/DateType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/FloatType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/HashMapType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/IntegerType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/ModelType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/ModelTypeInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
/**

src/Annotation/Types/Money.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/MoneyType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/NumberType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/ScalarCollectionType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/StringType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
use Attribute;

src/Annotation/Types/TypeInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Annotation\Types;
46

57
/**

src/Client/DynamoDBPDOClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Client;
46

57
use Aws\DynamoDb\DynamoDbClient as DynamoDbClientSDK;

src/Client/DynamodbOperationsClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Client;
46

57
class DynamodbOperationsClient extends DynamoDBPDOClient implements DynamodbOperationsClientInterface

src/Client/DynamodbOperationsClientInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Client;
46

57
interface DynamodbOperationsClientInterface

src/Client/PDOClientInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Client;
46

57
use GuzzleHttp\Promise\PromiseInterface;

src/Factory/RepositoryFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Factory;
46

57
use Aws\DynamoDb\Marshaler;
@@ -142,7 +144,7 @@ public function create(string $repositoryClassName, string $modelClassName): Dyn
142144
*/
143145
private function createAnonymousRepository(string $modelClassName, Hydrator $hydrator): DynamoDBRepository
144146
{
145-
return new class(
147+
return new class (
146148
$modelClassName,
147149
$this->dynamodbOperationsClient,
148150
$this->queryBuilder,

src/Factory/RepositoryFactoryInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Factory;
46

57
use Autoprotect\DynamodbODM\Repository\DynamoDBRepository;

src/Hydrator/AbstractHydrator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Hydrator;
46

57
use DateTime;
@@ -176,7 +178,7 @@ protected function getModel(array $data, ?string $discriminatorFieldName = null)
176178
{
177179
$this->modelClassName = $this->getModelNameUsingParams($data, $discriminatorFieldName);
178180

179-
return new $this->modelClassName;
181+
return new $this->modelClassName();
180182
}
181183

182184
/**

src/Hydrator/Hydrator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Hydrator;
46

57
use Autoprotect\DynamodbODM\Annotation\AnnotationManagerInterface;

src/Hydrator/HydratorInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Autoprotect\DynamodbODM\Hydrator;
46

57
use Autoprotect\DynamodbODM\Model\ModelInterface;

src/Hydrator/TypeHydrator/Date/DateTypeHydrator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
class DateTypeHydrator implements DateTypeHydratorInterface
1212
{
13-
1413
public function hydrate(string $value): DateTimeInterface
1514
{
1615
try {

src/Hydrator/TypeHydrator/Enum/EnumTypeHydrator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,16 @@ protected function getEnumClassname(
7878
if (!$reflectionType instanceof ReflectionNamedType) {
7979
throw new PropertyShouldBeOfNamedTypeException(
8080
sprintf(
81-
'Property %s should be ReflectionNamedType, '.
81+
'Property %s should be ReflectionNamedType, ' .
8282
'e. g. should have only enum type in the class %s',
8383
$annotationPropertyName,
8484
$modelClassName
8585
)
8686
);
8787
}
8888
$name = $reflectionType->getName();
89-
if (!$reflectionType->allowsNull()
89+
if (
90+
!$reflectionType->allowsNull()
9091
&&
9192
!(
9293
(

0 commit comments

Comments
 (0)