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

Update build process to use stages and PHPCS #817

Merged
merged 9 commits into from
Sep 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ vendor/
composer.lock
doctrine-common-*.tar
doctrine-common-*.tar.gz
/phpcs.xml
/.phpcs-cache
46 changes: 34 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
16 changes: 8 additions & 8 deletions lib/Doctrine/Common/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ClassLoader
*/
public function __construct($ns = null, $includePath = null)
{
$this->namespace = $ns;
$this->namespace = $ns;
$this->includePath = $includePath;
}

Expand Down Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/EventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getListeners($event = null)
*/
public function hasListeners($event)
{
return !empty($this->_listeners[$event]);
return ! empty($this->_listeners[$event]);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
*/
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;
}

Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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));
}

Expand All @@ -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;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class LifecycleEventArgs extends EventArgs
*/
public function __construct($object, ObjectManager $objectManager)
{
$this->object = $object;
$this->object = $object;
$this->objectManager = $objectManager;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class OnClearEventArgs extends EventArgs
public function __construct($objectManager, $entityClass = null)
{
$this->objectManager = $objectManager;
$this->entityClass = $entityClass;
$this->entityClass = $entityClass;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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());
}

Expand All @@ -135,7 +135,7 @@ public function isTransient($className)
return false;
}

return !$this->locator->fileExists($className);
return ! $this->locator->fileExists($className);
}

/**
Expand All @@ -147,7 +147,7 @@ public function getAllClassNames()
$this->initialize();
}

if (! $this->classCache) {
if ( ! $this->classCache) {
return (array) $this->locator->getAllClassNames($this->globalBasename);
}

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down
Loading