Permalink
Browse files

Merge pull request #817 from doctrine/update-build-process

Update build process to use stages and PHPCS
  • Loading branch information...
2 parents 2021b3d + 71e8116 commit a3e240fa07ec9748387c13534949d543c0e177fa @Majkl578 Majkl578 committed Sep 2, 2017
Showing with 790 additions and 739 deletions.
  1. +1 −0 .gitattributes
  2. +2 −0 .gitignore
  3. +34 −12 .travis.yml
  4. +3 −1 composer.json
  5. +8 −8 lib/Doctrine/Common/ClassLoader.php
  6. +1 −1 lib/Doctrine/Common/EventManager.php
  7. +11 −11 lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php
  8. +1 −1 lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php
  9. +1 −1 lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php
  10. +7 −7 lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
  11. +3 −3 lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php
  12. +5 −5 lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php
  13. +5 −5 lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php
  14. +5 −5 lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php
  15. +15 −16 lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php
  16. +2 −2 lib/Doctrine/Common/Persistence/Mapping/MappingException.php
  17. +2 −2 lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php
  18. +20 −20 lib/Doctrine/Common/Persistence/PersistentObject.php
  19. +1 −1 lib/Doctrine/Common/PropertyChangedListener.php
  20. +3 −4 lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
  21. +1 −1 lib/Doctrine/Common/Proxy/Exception/InvalidArgumentException.php
  22. +0 −1 lib/Doctrine/Common/Proxy/ProxyDefinition.php
  23. +11 −12 lib/Doctrine/Common/Proxy/ProxyGenerator.php
  24. +1 −1 lib/Doctrine/Common/Reflection/StaticReflectionMethod.php
  25. +21 −20 lib/Doctrine/Common/Reflection/StaticReflectionParser.php
  26. +1 −1 lib/Doctrine/Common/Reflection/StaticReflectionProperty.php
  27. +5 −5 lib/Doctrine/Common/Util/ClassUtils.php
  28. +10 −9 lib/Doctrine/Common/Util/Debug.php
  29. +1 −1 lib/Doctrine/Common/Version.php
  30. +31 −0 phpcs.xml.dist
  31. +0 −2 phpstan.neon
  32. +4 −9 phpunit.xml.dist
  33. +25 −25 tests/Doctrine/Tests/Common/ClassLoaderTest.php
  34. +1 −1 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php
  35. +1 −1 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassB.class.php
  36. +1 −1 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassC.class.php
  37. +3 −1 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassD.php
  38. +3 −1 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassE.php
  39. +23 −9 tests/Doctrine/Tests/Common/ClassLoaderTest/ExternalLoader.php
  40. +22 −23 tests/Doctrine/Tests/Common/EventManagerTest.php
  41. +9 −9 tests/Doctrine/Tests/Common/Persistence/ManagerRegistryTest.php
  42. +2 −2 tests/Doctrine/Tests/Common/Persistence/Mapping/AnnotationDriverTest.php
  43. +18 −20 tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php
  44. +15 −15 tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php
  45. +16 −16 tests/Doctrine/Tests/Common/Persistence/Mapping/DriverChainTest.php
  46. +18 −19 tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php
  47. +1 −1 tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php
  48. +10 −11 tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php
  49. +4 −4 tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php
  50. +9 −10 tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php
  51. +32 −32 tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php
  52. +1 −1 tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php
  53. +5 −5 tests/Doctrine/Tests/Common/Persistence/ObjectManagerDecoratorTest.php
  54. +11 −15 tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php
  55. +11 −12 tests/Doctrine/Tests/Common/Proxy/AbstractProxyFactoryTest.php
  56. +8 −10 tests/Doctrine/Tests/Common/Proxy/AutoloaderTest.php
  57. +0 −1 tests/Doctrine/Tests/Common/Proxy/InvalidReturnTypeClass.php
  58. +6 −6 tests/Doctrine/Tests/Common/Proxy/LazyLoadableObject.php
  59. +2 −3 tests/Doctrine/Tests/Common/Proxy/LazyLoadableObjectWithNullableTypehints.php
  60. +6 −8 tests/Doctrine/Tests/Common/Proxy/LazyLoadableObjectWithTypehints.php
  61. +76 −77 tests/Doctrine/Tests/Common/Proxy/ProxyGeneratorTest.php
  62. +4 −5 tests/Doctrine/Tests/Common/Proxy/ProxyLogicIdentifierGetterTest.php
  63. +82 −81 tests/Doctrine/Tests/Common/Proxy/ProxyLogicTest.php
  64. +18 −18 tests/Doctrine/Tests/Common/Proxy/ProxyLogicVoidReturnTypeTest.php
  65. +36 −39 tests/Doctrine/Tests/Common/Proxy/ProxyMagicMethodsTest.php
  66. +6 −6 tests/Doctrine/Tests/Common/Proxy/ReturnTypesClass.php
  67. +1 −1 tests/Doctrine/Tests/Common/Proxy/VoidReturnTypeClass.php
  68. +5 −5 tests/Doctrine/Tests/Common/Reflection/AnnotationClassWithScopeResolution.php
  69. +3 −2 tests/Doctrine/Tests/Common/Reflection/ExampleAnnotationClass.php
  70. +12 −13 tests/Doctrine/Tests/Common/Reflection/RuntimePublicReflectionPropertyTest.php
  71. +12 −12 tests/Doctrine/Tests/Common/Reflection/StaticReflectionParserTest.php
  72. +19 −14 tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php
  73. +25 −25 tests/Doctrine/Tests/Common/Util/DebugTest.php
  74. +2 −2 tests/Doctrine/Tests/Common/Util/TestAsset/ChildClass.php
  75. +2 −2 tests/Doctrine/Tests/Common/Util/TestAsset/ChildWithSameAttributesClass.php
  76. +2 −2 tests/Doctrine/Tests/Common/Util/TestAsset/ParentClass.php
  77. +2 −2 tests/Doctrine/Tests/DoctrineTestCase.php
  78. +4 −4 tests/Doctrine/Tests/TestInit.php
View
@@ -6,3 +6,4 @@ build.properties export-ignore
build.xml export-ignore
phpunit.xml.dist export-ignore
/lib/vendor export-ignore
+/phpcs.xml.dist export-ignore
View
@@ -8,3 +8,5 @@ vendor/
composer.lock
doctrine-common-*.tar
doctrine-common-*.tar.gz
+/phpcs.xml
+/.phpcs-cache
View
@@ -1,23 +1,45 @@
-language: php
-
+dist: trusty
sudo: false
+language: php
cache:
- directory:
+ directories:
- $HOME/.composer/cache
php:
- 7.1
+ - 7.2
+ - nightly
+
+before_install:
+ - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
+
+install:
+ - travis_retry composer -n --prefer-source install
+
+script: ./vendor/bin/phpunit
+
+jobs:
+ allow_failures:
+ - php: nightly
-matrix:
include:
- - php: 7.1
- env: PHPSTAN=1
+ - stage: Coverage
+ before_script:
+ - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
+ - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
+ script:
+ - ./vendor/bin/phpunit --coverage-clover clover.xml
+ after_script:
+ - wget https://scrutinizer-ci.com/ocular.phar
+ - php ocular.phar code-coverage:upload --format=php-clover clover.xml
+
+ - stage: Coding standard
+ script:
+ - ./vendor/bin/phpcs
-before_script:
- - composer --prefer-source install
- - if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.7; fi
+ - stage: Lint
+ before_script:
+ - travis_retry composer require --dev --prefer-dist --prefer-stable phpstan/phpstan:^0.8
+ script: vendor/bin/phpstan analyse -l 3 -c phpstan.neon lib tests
-script:
- - ./vendor/bin/phpunit
- - if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -c phpstan.neon -l 3 lib tests; fi
View
@@ -22,7 +22,9 @@
"doctrine/annotations": "1.*"
},
"require-dev": {
- "phpunit/phpunit": "^5.7"
+ "phpunit/phpunit": "^6.3",
+ "doctrine/coding-standard": "^1.0",
+ "squizlabs/php_codesniffer": "^3.0"
},
"autoload": {
"psr-4": {
@@ -76,7 +76,7 @@ class ClassLoader
*/
public function __construct($ns = null, $includePath = null)
{
- $this->namespace = $ns;
+ $this->namespace = $ns;
$this->includePath = $includePath;
}
@@ -179,11 +179,11 @@ public function loadClass($className)
return true;
}
- if (! $this->canLoadClass($className)) {
+ if ( ! $this->canLoadClass($className)) {
return false;
}
- require ($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '')
+ require($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '')
. str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className)
. $this->fileExtension;
@@ -200,7 +200,7 @@ public function loadClass($className)
*/
public function canLoadClass($className)
{
- if ($this->namespace !== null && strpos($className, $this->namespace.$this->namespaceSeparator) !== 0) {
+ if ($this->namespace !== null && strpos($className, $this->namespace . $this->namespaceSeparator) !== 0) {
return false;
}
@@ -250,11 +250,11 @@ public static function classExists($className)
*/
public static function getClassLoader($className)
{
- foreach (spl_autoload_functions() as $loader) {
+ foreach (spl_autoload_functions() as $loader) {
if (is_array($loader)
- && ($classLoader = reset($loader))
- && $classLoader instanceof ClassLoader
- && $classLoader->canLoadClass($className)
+ && ($classLoader = reset($loader))
+ && $classLoader instanceof ClassLoader
+ && $classLoader->canLoadClass($className)
) {
return $classLoader;
}
@@ -82,7 +82,7 @@ public function getListeners($event = null)
*/
public function hasListeners($event)
{
- return !empty($this->_listeners[$event]);
+ return ! empty($this->_listeners[$event]);
}
/**
@@ -72,11 +72,11 @@
*/
public function __construct($name, array $connections, array $managers, $defaultConnection, $defaultManager, $proxyInterfaceName)
{
- $this->name = $name;
- $this->connections = $connections;
- $this->managers = $managers;
- $this->defaultConnection = $defaultConnection;
- $this->defaultManager = $defaultManager;
+ $this->name = $name;
+ $this->connections = $connections;
+ $this->managers = $managers;
+ $this->defaultConnection = $defaultConnection;
+ $this->defaultManager = $defaultManager;
$this->proxyInterfaceName = $proxyInterfaceName;
}
@@ -121,7 +121,7 @@ public function getConnection($name = null)
$name = $this->defaultConnection;
}
- if (!isset($this->connections[$name])) {
+ if ( ! isset($this->connections[$name])) {
throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->name, $name));
}
@@ -176,7 +176,7 @@ public function getManager($name = null)
$name = $this->defaultManager;
}
- if (!isset($this->managers[$name])) {
+ if ( ! isset($this->managers[$name])) {
throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name));
}
@@ -191,13 +191,13 @@ public function getManagerForClass($class)
// Check for namespace alias
if (strpos($class, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $class, 2);
- $class = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
+ $class = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
}
$proxyClass = new \ReflectionClass($class);
if ($proxyClass->implementsInterface($this->proxyInterfaceName)) {
- if (! $parentClass = $proxyClass->getParentClass()) {
+ if ( ! $parentClass = $proxyClass->getParentClass()) {
return null;
}
@@ -207,7 +207,7 @@ public function getManagerForClass($class)
foreach ($this->managers as $id) {
$manager = $this->getService($id);
- if (!$manager->getMetadataFactory()->isTransient($class)) {
+ if ( ! $manager->getMetadataFactory()->isTransient($class)) {
return $manager;
}
}
@@ -251,7 +251,7 @@ public function resetManager($name = null)
$name = $this->defaultManager;
}
- if (!isset($this->managers[$name])) {
+ if ( ! isset($this->managers[$name])) {
throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name));
}
@@ -51,7 +51,7 @@ class LifecycleEventArgs extends EventArgs
*/
public function __construct($object, ObjectManager $objectManager)
{
- $this->object = $object;
+ $this->object = $object;
$this->objectManager = $objectManager;
}
@@ -51,7 +51,7 @@ class OnClearEventArgs extends EventArgs
public function __construct($objectManager, $entityClass = null)
{
$this->objectManager = $objectManager;
- $this->entityClass = $entityClass;
+ $this->entityClass = $entityClass;
}
/**
@@ -109,7 +109,7 @@ public function getAllMetadata()
$this->initialize();
}
- $driver = $this->getDriver();
+ $driver = $this->getDriver();
$metadata = [];
foreach ($driver->getAllClassNames() as $className) {
$metadata[] = $this->getMetadataFor($className);
@@ -226,7 +226,7 @@ public function getMetadataFor($className)
$this->loadMetadata($realClassName);
}
} catch (MappingException $loadingException) {
- if (! $fallbackMetadataResponse = $this->onNotFoundMetadata($realClassName)) {
+ if ( ! $fallbackMetadataResponse = $this->onNotFoundMetadata($realClassName)) {
throw $loadingException;
}
@@ -309,14 +309,14 @@ protected function loadMetadata($name)
$loaded = [];
- $parentClasses = $this->getParentClasses($name);
+ $parentClasses = $this->getParentClasses($name);
$parentClasses[] = $name;
// Move down the hierarchy of parent classes, starting from the topmost class
- $parent = null;
+ $parent = null;
$rootEntityFound = false;
- $visited = [];
- $reflService = $this->getReflectionService();
+ $visited = [];
+ $reflService = $this->getReflectionService();
foreach ($parentClasses as $className) {
if (isset($this->loadedMetadata[$className])) {
$parent = $this->loadedMetadata[$className];
@@ -397,7 +397,7 @@ public function isTransient($class)
// Check for namespace alias
if (strpos($class, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $class, 2);
- $class = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName);
+ $class = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName);
}
return $this->getDriver()->isTransient($class);
@@ -196,11 +196,11 @@ public function getAllClassNames()
return $this->classNames;
}
- if (!$this->paths) {
+ if ( ! $this->paths) {
throw MappingException::pathRequired();
}
- $classes = [];
+ $classes = [];
$includedFiles = [];
foreach ($this->paths as $path) {
@@ -242,7 +242,7 @@ public function getAllClassNames()
$declared = get_declared_classes();
foreach ($declared as $className) {
- $rc = new \ReflectionClass($className);
+ $rc = new \ReflectionClass($className);
$sourceFile = $rc->getFileName();
if (in_array($sourceFile, $includedFiles) && ! $this->isTransient($className)) {
$classes[] = $className;
@@ -66,7 +66,7 @@ public function __construct($locator, $fileExtension = null)
if ($locator instanceof FileLocator) {
$this->locator = $locator;
} else {
- $this->locator = new DefaultFileLocator((array)$locator, $fileExtension);
+ $this->locator = new DefaultFileLocator((array) $locator, $fileExtension);
}
}
@@ -113,7 +113,7 @@ public function getElement($className)
}
$result = $this->loadMappingFile($this->locator->findMappingFile($className));
- if (!isset($result[$className])) {
+ if ( ! isset($result[$className])) {
throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->locator->getFileExtension());
}
@@ -135,7 +135,7 @@ public function isTransient($className)
return false;
}
- return !$this->locator->fileExists($className);
+ return ! $this->locator->fileExists($className);
}
/**
@@ -147,7 +147,7 @@ public function getAllClassNames()
$this->initialize();
}
- if (! $this->classCache) {
+ if ( ! $this->classCache) {
return (array) $this->locator->getAllClassNames($this->globalBasename);
}
@@ -183,7 +183,7 @@ protected function initialize()
$this->classCache = [];
if (null !== $this->globalBasename) {
foreach ($this->locator->getPaths() as $path) {
- $file = $path.'/'.$this->globalBasename.$this->locator->getFileExtension();
+ $file = $path . '/' . $this->globalBasename . $this->locator->getFileExtension();
if (is_file($file)) {
$this->classCache = array_merge(
$this->classCache,
@@ -117,18 +117,18 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
*/
public function getAllClassNames()
{
- $classNames = [];
+ $classNames = [];
$driverClasses = [];
/* @var $driver MappingDriver */
- foreach ($this->drivers AS $namespace => $driver) {
+ foreach ($this->drivers as $namespace => $driver) {
$oid = spl_object_hash($driver);
- if (!isset($driverClasses[$oid])) {
+ if ( ! isset($driverClasses[$oid])) {
$driverClasses[$oid] = $driver->getAllClassNames();
}
- foreach ($driverClasses[$oid] AS $className) {
+ foreach ($driverClasses[$oid] as $className) {
if (strpos($className, $namespace) === 0) {
$classNames[$className] = true;
}
@@ -150,7 +150,7 @@ public function getAllClassNames()
public function isTransient($className)
{
/* @var $driver MappingDriver */
- foreach ($this->drivers AS $namespace => $driver) {
+ foreach ($this->drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) {
return $driver->isTransient($className);
}
Oops, something went wrong.

0 comments on commit a3e240f

Please sign in to comment.