Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Doctrine Coding Standard #77

Merged
merged 26 commits into from
Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
89e0254
Requiring doctrine/coding-standard
VolCh May 10, 2018
dc1e314
Fix phpcs SlevomatCodingStandard.Commenting.ForbiddenAnnotations
VolCh May 10, 2018
299be4b
Fix phpcs SlevomatCodingStandard.TypeHints.TypeHintDeclaration.Useles…
VolCh May 10, 2018
34b507c
Fix phpcs SlevomatCodingStandard.Commenting.RequireOneLinePropertyDoc…
VolCh May 10, 2018
53b3ae5
Fix phpcs SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
VolCh May 10, 2018
a0cc1ea
Fix phpcs SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses
VolCh May 10, 2018
2fffaf4
Fix phpcs Generic.Formatting.MultipleStatementAlignment
VolCh May 10, 2018
c1dd8c3
Fix phpcs Squiz.Commenting.FunctionComment
VolCh May 10, 2018
a2eb0ef
Fix phpcs SlevomatCodingStandard.ControlStructures.DisallowYodaCompar…
VolCh May 10, 2018
700f365
Fix phpcs SlevomatCodingStandard.ControlStructures.NewWithParentheses
VolCh May 10, 2018
64a5420
Fix phpcs SlevomatCodingStandard.ControlStructures.AssignmentInCondition
VolCh May 10, 2018
5c76ecc
Fix phpcs SlevomatCodingStandard.Namespaces.UnusedUses
VolCh May 10, 2018
e4530b0
Fix few phpcs violations
VolCh May 10, 2018
7bfeba9
Ignore phpcs SlevomatCodingStandard.Classes.UnusedPrivateElements in …
VolCh May 10, 2018
1f3c06a
Using Doctrine Coding Standard in Scrutinizer
VolCh May 10, 2018
ebb9bf8
Using Doctrine Coding Standard in Travis CI
VolCh May 10, 2018
50e58e8
Fix phpcs SlevomatCodingStandard.TypeHints.TypeHintDeclaration (PHP7.…
VolCh May 12, 2018
febabcc
Fix phpcs SlevomatCodingStandard.TypeHints.DeclareStrictTypes
VolCh May 12, 2018
d999871
Apply Doctrine Coding Standard to benchmarks
VolCh May 12, 2018
afe5255
Drop PHP 7.0 & 7.1 support
VolCh May 12, 2018
9e86078
Fix phpcs SlevomatCodingStandard.TypeHints.TypeHintDeclaration
VolCh May 12, 2018
e65acc1
Fix few phpcs violations
VolCh May 12, 2018
163a747
[BC] Fix phpcs SlevomatCodingStandard.Classes
VolCh May 12, 2018
6bb0807
[BC] Fix phpcs SlevomatCodingStandard.Classes
VolCh May 12, 2018
8e064b9
Fix ClassWithPrivateProperties::getProperty0 return type
VolCh May 12, 2018
e093a65
Fix few phpdocs format
VolCh Jun 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tools:
php_code_sniffer:
enabled: true
config:
standard: PSR2
standard: Doctrine
filter:
paths: ["src/*", "tests/*"]
php_cpd:
Expand Down
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.1
- 7.2

env:
Expand All @@ -18,8 +17,4 @@ script:
- ./vendor/bin/phpunit --group=Functional
- php -n ./vendor/bin/phpbench run --report=aggregate --revs=500 --iterations=50 --warmup=3
# Only run the code standards with the latest package
- if [ "$DEPENDENCIES" = "high" ]; then ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/ ./benchmarks; fi;

after_script:
- if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi
- if [ "$DEPENDENCIES" = "high" ]; then ./vendor/bin/phpcs --standard=Doctrine ./src/ ./tests/ ./benchmarks; fi;
10 changes: 10 additions & 0 deletions benchmarks/GeneratedHydratorBenchmark/AllPrivateClass.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Class that contains only private properties
*/
class AllPrivateClass
{
//phpcs:disable SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's preferable to do file-level excludes in phpcs.xml.dist rather than using inline comments.

/** @var mixed */
private $foo;
/** @var mixed */
private $bar;
/** @var mixed */
private $baz;
/** @var mixed */
private $someFooProperty;
/** @var mixed */
private $someBarProperty;
/** @var mixed */
private $someBazProperty;
//phpcs:enable
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Benchmark class that contains only private properties hydration
*
* @BeforeMethods({"setUp"})
*/
class AllPrivateClassHydrationBench extends AbstractHydrationBench
class AllPrivateClassHydrationBench extends HydrationBench
{
public function setUp()
public function setUp() : void
{
$this->createHydrator(AllPrivateClass::class);
$this->createData();
Expand All @@ -20,7 +22,7 @@ public function setUp()
* @Revs(100)
* @Iterations(200)
*/
public function benchConsume()
public function benchConsume() : void
{
$this->hydrator->hydrate($this->data, $this->object);
}
Expand Down
8 changes: 8 additions & 0 deletions benchmarks/GeneratedHydratorBenchmark/AllProtectedClass.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Class that contains only protected properties
*/
class AllProtectedClass
{
/** @var mixed */
protected $foo;
/** @var mixed */
protected $bar;
/** @var mixed */
protected $baz;
/** @var mixed */
protected $someFooProperty;
/** @var mixed */
protected $someBarProperty;
/** @var mixed */
protected $someBazProperty;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Benchmark class that contains only protected properties hydration
*
* @BeforeMethods({"setUp"})
*/
class AllProtectedClassHydrationBench extends AbstractHydrationBench
class AllProtectedClassHydrationBench extends HydrationBench
{
public function setUp()
public function setUp() : void
{
$this->createHydrator(AllProtectedClass::class);
$this->createData();
Expand All @@ -20,7 +22,7 @@ public function setUp()
* @Revs(100)
* @Iterations(200)
*/
public function benchConsume()
public function benchConsume() : void
{
$this->hydrator->hydrate($this->data, $this->object);
}
Expand Down
8 changes: 8 additions & 0 deletions benchmarks/GeneratedHydratorBenchmark/AllPublicClass.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Class that contains only public properties
*/
class AllPublicClass
{
/** @var mixed */
public $foo;
/** @var mixed */
public $bar;
/** @var mixed */
public $baz;
/** @var mixed */
public $someFooProperty;
/** @var mixed */
public $someBarProperty;
/** @var mixed */
public $someBazProperty;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Benchmark class that contains only public properties hydration
*
* @BeforeMethods({"setUp"})
*/
class AllPublicClassHydrationBench extends AbstractHydrationBench
class AllPublicClassHydrationBench extends HydrationBench
{
public function setUp()
public function setUp() : void
{
$this->createHydrator(AllPublicClass::class);
$this->createData();
Expand All @@ -20,7 +22,7 @@ public function setUp()
* @Revs(100)
* @Iterations(200)
*/
public function benchConsume()
public function benchConsume() : void
{
$this->hydrator->hydrate($this->data, $this->object);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

use GeneratedHydrator\Configuration;
Expand All @@ -8,29 +10,21 @@
/**
* Default base class for hydration benchmarks
*/
abstract class AbstractHydrationBench
abstract class HydrationBench
{
/**
* @var HydratorInterface
*/
/** @var HydratorInterface */
protected $hydrator;

/**
* @var mixed[]
*/
/** @var mixed[] */
protected $data;

/**
* @var mixed
*/
/** @var mixed */
protected $object;

/**
* Create and set the hydrator
*
* @param string $class
*/
protected function createHydrator($class)
protected function createHydrator(string $class) : void
{
$config = new Configuration($class);
$hydratorClass = $config->createFactory()->getHydratorClass();
Expand All @@ -41,13 +35,13 @@ protected function createHydrator($class)
/**
* Populate test data array
*/
protected function createData()
protected function createData() : void
{
$this->data = [
'foo' => 'some foo string',
'bar' => 42,
'baz' => new \DateTime(),
'someFooProperty' => array(12, 13, 14),
'someFooProperty' => [12, 13, 14],
'someBarProperty' => 12354.4578,
'someBazProperty' => new \stdClass(),
];
Expand Down
10 changes: 10 additions & 0 deletions benchmarks/GeneratedHydratorBenchmark/InheritanceClass.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Class that contains mixed inherited properties
*/
class InheritanceClass extends MixedClass
{
//phpcs:disable SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty
/** @var mixed */
private $foo1;
/** @var mixed */
protected $bar1;
/** @var mixed */
public $baz1;
/** @var mixed */
private $someFooProperty1;
/** @var mixed */
protected $someBarProperty1;
/** @var mixed */
public $someBazProperty1;
//phpcs:enable
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Benchmark class that contains mixed inherited properties hydration
*
* @BeforeMethods({"setUp"})
*/
class InheritanceClassHydrationBench extends AbstractHydrationBench
class InheritanceClassHydrationBench extends HydrationBench
{
protected function createData()
protected function createData() : void
{
parent::createData();

$this->data += [
'foo1' => 'some foo string',
'bar1' => 42,
'baz1' => new \DateTime(),
'someFooProperty1' => array(12, 13, 14),
'someFooProperty1' => [12, 13, 14],
'someBarProperty1' => 12354.4578,
'someBazProperty1' => new \stdClass(),
];
}

public function setUp()
public function setUp() : void
{
$this->createHydrator(InheritanceClass::class);
$this->createData();
Expand All @@ -34,7 +36,7 @@ public function setUp()
* @Revs(100)
* @Iterations(200)
*/
public function benchConsume()
public function benchConsume() : void
{
$this->hydrator->hydrate($this->data, $this->object);
}
Expand Down
10 changes: 10 additions & 0 deletions benchmarks/GeneratedHydratorBenchmark/InheritanceDeepClass.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<?php

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;

/**
* Class that contains mixed deeply inherited properties
*/
class InheritanceDeepClass extends InheritanceClass
{
//phpcs:disable SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty
/** @var mixed */
private $foo2;
/** @var mixed */
protected $bar2;
/** @var mixed */
public $baz2;
/** @var mixed */
private $someFooProperty2;
/** @var mixed */
protected $someBarProperty2;
/** @var mixed */
public $someBazProperty2;
//phpcs:enable
}
Loading