Skip to content

Commit f426bcd

Browse files
authored
Merge pull request #38 from superbrave/coding-standards
Added 'friendsofphp/php-cs-fixer' as coding standard package.
2 parents 885e928 + a70d9e2 commit f426bcd

36 files changed

+750
-290
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@
4343

4444
# PHPUnit
4545
.phpunit.result.cache
46+
47+
# PHP CS Fixer
48+
.php_cs.cache

.php_cs.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('var')
5+
->exclude('vendor')
6+
->in(__DIR__);
7+
8+
return PhpCsFixer\Config::create()
9+
->setRules([
10+
'@Symfony' => true,
11+
'no_superfluous_phpdoc_tags' => false,
12+
'ordered_imports' => true,
13+
'single_line_throw' => false,
14+
'yoda_style' => null, // Do not enforce Yoda style (add unit tests instead...)
15+
])
16+
->setFinder($finder);

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ before_script:
1515

1616
script:
1717
- bin/phpunit --log-junit build/logs/phpunit.xml
18-
- bin/phpcs --report-full --report-junit=build/logs/phpcs.xml
18+
- bin/php-cs-fixer fix --dry-run -v

Annotation/AnnotationReader.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* This file is part of the GDPR bundle.
44
*
55
* @category Bundle
6-
* @package Gdpr
6+
*
77
* @author SuperBrave <info@superbrave.nl>
88
* @copyright 2018 SuperBrave <info@superbrave.nl>
99
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT
10-
* @link https://www.superbrave.nl/
10+
*
11+
* @see https://www.superbrave.nl/
1112
*/
1213

1314
namespace Superbrave\GdprBundle\Annotation;
@@ -33,7 +34,7 @@ class AnnotationReader extends DoctrineAnnotationReader
3334
*/
3435
public function getPropertiesWithAnnotation(ReflectionClass $class, $annotationName)
3536
{
36-
$annotatedProperties = array();
37+
$annotatedProperties = [];
3738

3839
$properties = $class->getProperties();
3940
foreach ($properties as $property) {

Annotation/Anonymize.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<?php
22
/**
3-
* This file contains the Anonymize annotation class
3+
* This file contains the Anonymize annotation class.
44
*
55
* Minimal required PHP version is 5.6
66
*
77
* @category Bundle
8-
* @package Gdpr
8+
*
99
* @author SuperBrave <info@superbrave.nl>
1010
* @copyright 2018 SuperBrave <info@superbrave.nl>
1111
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT
12-
* @link https://www.superbrave.nl/
12+
*
13+
* @see https://www.superbrave.nl/
1314
*/
1415

1516
namespace Superbrave\GdprBundle\Annotation;
@@ -20,7 +21,7 @@
2021

2122
/**
2223
* Annotation to flag an entity field to be anonymized
23-
* to conform with the GDPR right to be forgotten
24+
* to conform with the GDPR right to be forgotten.
2425
*
2526
* @Annotation()
2627
* @Annotation\Target({"PROPERTY"})
@@ -33,14 +34,14 @@
3334
class Anonymize
3435
{
3536
/**
36-
* The type used to specify what kind of anonymizer should be used for the field
37+
* The type used to specify what kind of anonymizer should be used for the field.
3738
*
3839
* @var string
3940
*/
4041
public $type;
4142

4243
/**
43-
* The value used as a hard string to be used to anonymize the field
44+
* The value used as a hard string to be used to anonymize the field.
4445
*
4546
* @var string
4647
*/

Annotation/Export.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* This file is part of the GDPR bundle.
44
*
55
* @category Bundle
6-
* @package Gdpr
6+
*
77
* @author SuperBrave <info@superbrave.nl>
88
* @copyright 2018 SuperBrave <info@superbrave.nl>
99
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT
10-
* @link https://www.superbrave.nl/
10+
*
11+
* @see https://www.superbrave.nl/
1112
*/
1213

1314
namespace Superbrave\GdprBundle\Annotation;

Anonymize/Anonymizer.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@
33
* This file is part of the GDPR bundle.
44
*
55
* @category Bundle
6-
* @package Gdpr
6+
*
77
* @author SuperBrave <info@superbrave.nl>
88
* @copyright 2018 SuperBrave <info@superbrave.nl>
99
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT
10-
* @link https://www.superbrave.nl/
10+
*
11+
* @see https://www.superbrave.nl/
1112
*/
1213

1314
namespace Superbrave\GdprBundle\Anonymize;
1415

15-
use Superbrave\GdprBundle\Annotation\AnnotationReader;
16-
use Superbrave\GdprBundle\Annotation\Anonymize;
1716
use InvalidArgumentException;
18-
use ReflectionException;
1917
use ReflectionClass;
18+
use ReflectionException;
19+
use Superbrave\GdprBundle\Annotation\AnnotationReader;
20+
use Superbrave\GdprBundle\Annotation\Anonymize;
2021

2122
/**
22-
* Class Anonymizer
23-
*
24-
* @package Superbrave\GdprBundle\Anonymize
23+
* Class Anonymizer.
2524
*/
2625
class Anonymizer
2726
{
@@ -38,26 +37,26 @@ class Anonymizer
3837
/**
3938
* Anonymizer constructor.
4039
*
41-
* @param AnnotationReader $annotationReader The annotation reader that should be used.
42-
* @param PropertyAnonymizer $propertyAnonymizer The property anonymizer.
40+
* @param AnnotationReader $annotationReader the annotation reader that should be used
41+
* @param PropertyAnonymizer $propertyAnonymizer the property anonymizer
4342
*/
4443
public function __construct(
4544
AnnotationReader $annotationReader,
4645
PropertyAnonymizer $propertyAnonymizer
4746
) {
48-
$this->annotationReader = $annotationReader;
49-
$this->propertyAnonymizer = $propertyAnonymizer;
47+
$this->annotationReader = $annotationReader;
48+
$this->propertyAnonymizer = $propertyAnonymizer;
5049
}
5150

5251
/**
5352
* Anonymizes the given object which should contain the @see Anonymize annotations.
5453
*
55-
* @param object $object The object to anonymize.
54+
* @param object $object the object to anonymize
5655
*
5756
* @return void
5857
*
59-
* @throws InvalidArgumentException If argument supplied is not an object.
60-
* @throws ReflectionException If class doesn't exist.
58+
* @throws InvalidArgumentException if argument supplied is not an object
59+
* @throws ReflectionException if class doesn't exist
6160
*/
6261
public function anonymize(/*object */$object)
6362
{
@@ -69,7 +68,7 @@ public function anonymize(/*object */$object)
6968
}
7069

7170
$reflectionClass = new ReflectionClass($object);
72-
$annotations = $this->annotationReader->getPropertiesWithAnnotation($reflectionClass, Anonymize::class);
71+
$annotations = $this->annotationReader->getPropertiesWithAnnotation($reflectionClass, Anonymize::class);
7372

7473
foreach ($annotations as $property => $annotation) {
7574
$this->propertyAnonymizer->anonymizeField($object, $property, $annotation);

Anonymize/AnonymizerCollection.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* This file is part of the GDPR bundle.
44
*
55
* @category Bundle
6-
* @package Gdpr
6+
*
77
* @author SuperBrave <info@superbrave.nl>
88
* @copyright 2018 SuperBrave <info@superbrave.nl>
99
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT
10-
* @link https://www.superbrave.nl/
10+
*
11+
* @see https://www.superbrave.nl/
1112
*/
1213

1314
namespace Superbrave\GdprBundle\Anonymize;
@@ -16,14 +17,12 @@
1617
use Superbrave\GdprBundle\Anonymize\Type\AnonymizerInterface;
1718

1819
/**
19-
* Class AnonymizerCollection
20-
*
21-
* @package Superbrave\GdprBundle\Anonymize
20+
* Class AnonymizerCollection.
2221
*/
2322
class AnonymizerCollection
2423
{
2524
/**
26-
* Array of anonymizers
25+
* Array of anonymizers.
2726
*
2827
* @var AnonymizerInterface[]
2928
*/
@@ -32,12 +31,12 @@ class AnonymizerCollection
3231
/**
3332
* Adds an anonymizer to the collection.
3433
*
35-
* @param string $type The anonymizer type to be added.
36-
* @param AnonymizerInterface $anonymizer The anonymizer class to be added.
34+
* @param string $type the anonymizer type to be added
35+
* @param AnonymizerInterface $anonymizer the anonymizer class to be added
3736
*
3837
* @return void
3938
*
40-
* @throws LogicException On duplicate anonymizer keys.
39+
* @throws LogicException on duplicate anonymizer keys
4140
*/
4241
public function addAnonymizer($type, $anonymizer)
4342
{
@@ -51,11 +50,11 @@ public function addAnonymizer($type, $anonymizer)
5150
/**
5251
* Get an anonymizer by its type from the collection.
5352
*
54-
* @param string $type The anonymizer type to be fetched.
53+
* @param string $type the anonymizer type to be fetched
5554
*
5655
* @return AnonymizerInterface
5756
*
58-
* @throws LogicException If the anonymizer type is not registered.
57+
* @throws LogicException if the anonymizer type is not registered
5958
*/
6059
public function getAnonymizer($type)
6160
{

Anonymize/PropertyAnonymizer.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* This file is part of the GDPR bundle.
44
*
55
* @category Bundle
6-
* @package Gdpr
6+
*
77
* @author SuperBrave <info@superbrave.nl>
88
* @copyright 2018 SuperBrave <info@superbrave.nl>
99
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT
10-
* @link https://www.superbrave.nl/
10+
*
11+
* @see https://www.superbrave.nl/
1112
*/
1213

1314
namespace Superbrave\GdprBundle\Anonymize;
@@ -16,28 +17,26 @@
1617
use Superbrave\GdprBundle\Manipulator\PropertyManipulator;
1718

1819
/**
19-
* Class PropertyAnonymizer
20-
*
21-
* @package Superbrave\GdprBundle\Anonymizer
20+
* Class PropertyAnonymizer.
2221
*/
2322
class PropertyAnonymizer
2423
{
2524
/**
26-
* Property manipulator service
25+
* Property manipulator service.
2726
*
2827
* @var PropertyManipulator
2928
*/
3029
private $propertyManipulator;
3130

3231
/**
33-
* The collection of anonymizers
32+
* The collection of anonymizers.
3433
*
3534
* @var AnonymizerCollection
3635
*/
3736
private $anonymizerCollection;
3837

3938
/**
40-
* Constructs the class given the parameters
39+
* Constructs the class given the parameters.
4140
*
4241
* @param PropertyManipulator $propertyManipulator The PropertyManipulator class used to get the property value
4342
* @param AnonymizerCollection $anonymizerCollection A collection of anonymizers registered by the compiler pass
@@ -50,7 +49,7 @@ public function __construct(PropertyManipulator $propertyManipulator, Anonymizer
5049

5150
/**
5251
* Anonymize the property the annotation is on.
53-
* Takes into account the type specified in the annotation
52+
* Takes into account the type specified in the annotation.
5453
*
5554
* @param object $object The owner of the property being anonymized
5655
* @param string $property The property being anonymized
@@ -64,10 +63,10 @@ public function anonymizeField($object, $property, Anonymize $annotation)
6463

6564
$propertyValue = $this->propertyManipulator->getPropertyValue($object, $property);
6665

67-
$newPropertyValue = $anonymizer->anonymize($propertyValue, array(
66+
$newPropertyValue = $anonymizer->anonymize($propertyValue, [
6867
'annotationValue' => $annotation->value,
6968
'object' => $object,
70-
));
69+
]);
7170

7271
$this->propertyManipulator->setPropertyValue($object, $property, $newPropertyValue);
7372
}

Anonymize/Type/AnonymizerInterface.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@
33
* This file is part of the GDPR bundle.
44
*
55
* @category Bundle
6-
* @package Gdpr
6+
*
77
* @author SuperBrave <info@superbrave.nl>
88
* @copyright 2018 SuperBrave <info@superbrave.nl>
99
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT
10-
* @link https://www.superbrave.nl/
10+
*
11+
* @see https://www.superbrave.nl/
1112
*/
1213

1314
namespace Superbrave\GdprBundle\Anonymize\Type;
1415

1516
/**
16-
* Interface AnonymizerInterface
17-
*
18-
* @package Superbrave\GdprBundle\Anonymize\Type
17+
* Interface AnonymizerInterface.
1918
*/
2019
interface AnonymizerInterface
2120
{
2221
/**
2322
* Anonymizes the given property value.
2423
*
25-
* @param mixed $propertyValue The value of the property.
26-
* @param array $options The options for the anonymizer.
24+
* @param mixed $propertyValue the value of the property
25+
* @param array $options the options for the anonymizer
2726
*
2827
* @return mixed
2928
*/

Anonymize/Type/ArrayAnonymizer.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
* This file is part of the GDPR bundle.
44
*
55
* @category Bundle
6-
* @package Gdpr
6+
*
77
* @author SuperBrave <info@superbrave.nl>
88
* @copyright 2018 SuperBrave <info@superbrave.nl>
99
* @license https://github.com/superbrave/gdpr-bundle/blob/master/LICENSE MIT
10-
* @link https://www.superbrave.nl/
10+
*
11+
* @see https://www.superbrave.nl/
1112
*/
1213

1314
namespace Superbrave\GdprBundle\Anonymize\Type;
1415

1516
/**
16-
* Class ArrayAnonymizer
17-
*
18-
* @package Superbrave\GdprBundle\Anonymize\Type
17+
* Class ArrayAnonymizer.
1918
*/
2019
class ArrayAnonymizer implements AnonymizerInterface
2120
{
@@ -27,7 +26,7 @@ class ArrayAnonymizer implements AnonymizerInterface
2726
/**
2827
* ArrayAnonymizer constructor.
2928
*
30-
* @param AnonymizerInterface $anonymizer The anonymizer.
29+
* @param AnonymizerInterface $anonymizer the anonymizer
3130
*/
3231
public function __construct(AnonymizerInterface $anonymizer)
3332
{
@@ -37,7 +36,7 @@ public function __construct(AnonymizerInterface $anonymizer)
3736
/**
3837
* {@inheritdoc}
3938
*
40-
* @throws \InvalidArgumentException If property is not iterable.
39+
* @throws \InvalidArgumentException if property is not iterable
4140
*/
4241
public function anonymize($propertyValue, array $options = [])
4342
{

0 commit comments

Comments
 (0)