Skip to content

Commit a3e240f

Browse files
authored
Merge pull request #817 from doctrine/update-build-process
Update build process to use stages and PHPCS
2 parents 2021b3d + 71e8116 commit a3e240f

File tree

78 files changed

+790
-739
lines changed

Some content is hidden

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

78 files changed

+790
-739
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build.properties export-ignore
66
build.xml export-ignore
77
phpunit.xml.dist export-ignore
88
/lib/vendor export-ignore
9+
/phpcs.xml.dist export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ vendor/
88
composer.lock
99
doctrine-common-*.tar
1010
doctrine-common-*.tar.gz
11+
/phpcs.xml
12+
/.phpcs-cache

.travis.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
1-
language: php
2-
1+
dist: trusty
32
sudo: false
3+
language: php
44

55
cache:
6-
directory:
6+
directories:
77
- $HOME/.composer/cache
88

99
php:
1010
- 7.1
11+
- 7.2
12+
- nightly
13+
14+
before_install:
15+
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
16+
17+
install:
18+
- travis_retry composer -n --prefer-source install
19+
20+
script: ./vendor/bin/phpunit
21+
22+
jobs:
23+
allow_failures:
24+
- php: nightly
1125

12-
matrix:
1326
include:
14-
- php: 7.1
15-
env: PHPSTAN=1
27+
- stage: Coverage
28+
before_script:
29+
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
30+
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
31+
script:
32+
- ./vendor/bin/phpunit --coverage-clover clover.xml
33+
after_script:
34+
- wget https://scrutinizer-ci.com/ocular.phar
35+
- php ocular.phar code-coverage:upload --format=php-clover clover.xml
36+
37+
- stage: Coding standard
38+
script:
39+
- ./vendor/bin/phpcs
1640

17-
before_script:
18-
- composer --prefer-source install
19-
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.7; fi
41+
- stage: Lint
42+
before_script:
43+
- travis_retry composer require --dev --prefer-dist --prefer-stable phpstan/phpstan:^0.8
44+
script: vendor/bin/phpstan analyse -l 3 -c phpstan.neon lib tests
2045

21-
script:
22-
- ./vendor/bin/phpunit
23-
- if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -c phpstan.neon -l 3 lib tests; fi

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"doctrine/annotations": "1.*"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^5.7"
25+
"phpunit/phpunit": "^6.3",
26+
"doctrine/coding-standard": "^1.0",
27+
"squizlabs/php_codesniffer": "^3.0"
2628
},
2729
"autoload": {
2830
"psr-4": {

lib/Doctrine/Common/ClassLoader.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ClassLoader
7676
*/
7777
public function __construct($ns = null, $includePath = null)
7878
{
79-
$this->namespace = $ns;
79+
$this->namespace = $ns;
8080
$this->includePath = $includePath;
8181
}
8282

@@ -179,11 +179,11 @@ public function loadClass($className)
179179
return true;
180180
}
181181

182-
if (! $this->canLoadClass($className)) {
182+
if ( ! $this->canLoadClass($className)) {
183183
return false;
184184
}
185185

186-
require ($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '')
186+
require($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '')
187187
. str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className)
188188
. $this->fileExtension;
189189

@@ -200,7 +200,7 @@ public function loadClass($className)
200200
*/
201201
public function canLoadClass($className)
202202
{
203-
if ($this->namespace !== null && strpos($className, $this->namespace.$this->namespaceSeparator) !== 0) {
203+
if ($this->namespace !== null && strpos($className, $this->namespace . $this->namespaceSeparator) !== 0) {
204204
return false;
205205
}
206206

@@ -250,11 +250,11 @@ public static function classExists($className)
250250
*/
251251
public static function getClassLoader($className)
252252
{
253-
foreach (spl_autoload_functions() as $loader) {
253+
foreach (spl_autoload_functions() as $loader) {
254254
if (is_array($loader)
255-
&& ($classLoader = reset($loader))
256-
&& $classLoader instanceof ClassLoader
257-
&& $classLoader->canLoadClass($className)
255+
&& ($classLoader = reset($loader))
256+
&& $classLoader instanceof ClassLoader
257+
&& $classLoader->canLoadClass($className)
258258
) {
259259
return $classLoader;
260260
}

lib/Doctrine/Common/EventManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getListeners($event = null)
8282
*/
8383
public function hasListeners($event)
8484
{
85-
return !empty($this->_listeners[$event]);
85+
return ! empty($this->_listeners[$event]);
8686
}
8787

8888
/**

lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
7272
*/
7373
public function __construct($name, array $connections, array $managers, $defaultConnection, $defaultManager, $proxyInterfaceName)
7474
{
75-
$this->name = $name;
76-
$this->connections = $connections;
77-
$this->managers = $managers;
78-
$this->defaultConnection = $defaultConnection;
79-
$this->defaultManager = $defaultManager;
75+
$this->name = $name;
76+
$this->connections = $connections;
77+
$this->managers = $managers;
78+
$this->defaultConnection = $defaultConnection;
79+
$this->defaultManager = $defaultManager;
8080
$this->proxyInterfaceName = $proxyInterfaceName;
8181
}
8282

@@ -121,7 +121,7 @@ public function getConnection($name = null)
121121
$name = $this->defaultConnection;
122122
}
123123

124-
if (!isset($this->connections[$name])) {
124+
if ( ! isset($this->connections[$name])) {
125125
throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->name, $name));
126126
}
127127

@@ -176,7 +176,7 @@ public function getManager($name = null)
176176
$name = $this->defaultManager;
177177
}
178178

179-
if (!isset($this->managers[$name])) {
179+
if ( ! isset($this->managers[$name])) {
180180
throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name));
181181
}
182182

@@ -191,13 +191,13 @@ public function getManagerForClass($class)
191191
// Check for namespace alias
192192
if (strpos($class, ':') !== false) {
193193
list($namespaceAlias, $simpleClassName) = explode(':', $class, 2);
194-
$class = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
194+
$class = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
195195
}
196196

197197
$proxyClass = new \ReflectionClass($class);
198198

199199
if ($proxyClass->implementsInterface($this->proxyInterfaceName)) {
200-
if (! $parentClass = $proxyClass->getParentClass()) {
200+
if ( ! $parentClass = $proxyClass->getParentClass()) {
201201
return null;
202202
}
203203

@@ -207,7 +207,7 @@ public function getManagerForClass($class)
207207
foreach ($this->managers as $id) {
208208
$manager = $this->getService($id);
209209

210-
if (!$manager->getMetadataFactory()->isTransient($class)) {
210+
if ( ! $manager->getMetadataFactory()->isTransient($class)) {
211211
return $manager;
212212
}
213213
}
@@ -251,7 +251,7 @@ public function resetManager($name = null)
251251
$name = $this->defaultManager;
252252
}
253253

254-
if (!isset($this->managers[$name])) {
254+
if ( ! isset($this->managers[$name])) {
255255
throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name));
256256
}
257257

lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class LifecycleEventArgs extends EventArgs
5151
*/
5252
public function __construct($object, ObjectManager $objectManager)
5353
{
54-
$this->object = $object;
54+
$this->object = $object;
5555
$this->objectManager = $objectManager;
5656
}
5757

lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class OnClearEventArgs extends EventArgs
5151
public function __construct($objectManager, $entityClass = null)
5252
{
5353
$this->objectManager = $objectManager;
54-
$this->entityClass = $entityClass;
54+
$this->entityClass = $entityClass;
5555
}
5656

5757
/**

lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function getAllMetadata()
109109
$this->initialize();
110110
}
111111

112-
$driver = $this->getDriver();
112+
$driver = $this->getDriver();
113113
$metadata = [];
114114
foreach ($driver->getAllClassNames() as $className) {
115115
$metadata[] = $this->getMetadataFor($className);
@@ -226,7 +226,7 @@ public function getMetadataFor($className)
226226
$this->loadMetadata($realClassName);
227227
}
228228
} catch (MappingException $loadingException) {
229-
if (! $fallbackMetadataResponse = $this->onNotFoundMetadata($realClassName)) {
229+
if ( ! $fallbackMetadataResponse = $this->onNotFoundMetadata($realClassName)) {
230230
throw $loadingException;
231231
}
232232

@@ -309,14 +309,14 @@ protected function loadMetadata($name)
309309

310310
$loaded = [];
311311

312-
$parentClasses = $this->getParentClasses($name);
312+
$parentClasses = $this->getParentClasses($name);
313313
$parentClasses[] = $name;
314314

315315
// Move down the hierarchy of parent classes, starting from the topmost class
316-
$parent = null;
316+
$parent = null;
317317
$rootEntityFound = false;
318-
$visited = [];
319-
$reflService = $this->getReflectionService();
318+
$visited = [];
319+
$reflService = $this->getReflectionService();
320320
foreach ($parentClasses as $className) {
321321
if (isset($this->loadedMetadata[$className])) {
322322
$parent = $this->loadedMetadata[$className];
@@ -397,7 +397,7 @@ public function isTransient($class)
397397
// Check for namespace alias
398398
if (strpos($class, ':') !== false) {
399399
list($namespaceAlias, $simpleClassName) = explode(':', $class, 2);
400-
$class = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName);
400+
$class = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName);
401401
}
402402

403403
return $this->getDriver()->isTransient($class);

0 commit comments

Comments
 (0)