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

PSR-2 Cleanup #1173

Closed
wants to merge 13 commits into from
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Configuration.php
Expand Up @@ -60,7 +60,7 @@ public function addDocumentNamespace($alias, $namespace)
*/
public function getDocumentNamespace($documentNamespaceAlias)
{
if ( ! isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) {
if (! isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) {
throw MongoDBException::unknownDocumentNamespace($documentNamespaceAlias);
}

Expand Down Expand Up @@ -315,7 +315,7 @@ public function setClassMetadataFactoryName($cmfName)
*/
public function getClassMetadataFactoryName()
{
if ( ! isset($this->attributes['classMetadataFactoryName'])) {
if (! isset($this->attributes['classMetadataFactoryName'])) {
$this->attributes['classMetadataFactoryName'] = 'Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory';
}
return $this->attributes['classMetadataFactoryName'];
Expand Down
26 changes: 13 additions & 13 deletions lib/Doctrine/ODM/MongoDB/DocumentManager.php
Expand Up @@ -333,11 +333,11 @@ public function getDocumentCollection($className)
$metadata = $this->metadataFactory->getMetadataFor($className);
$collectionName = $metadata->getCollection();

if ( ! $collectionName) {
if (! $collectionName) {
throw MongoDBException::documentNotMappedToCollection($className);
}

if ( ! isset($this->documentCollections[$className])) {
if (! isset($this->documentCollections[$className])) {
$db = $this->getDocumentDatabase($className);

$this->documentCollections[$className] = $metadata->isFile()
Expand Down Expand Up @@ -389,7 +389,7 @@ public function createQueryBuilder($documentName = null)
*/
public function persist($document)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
Expand All @@ -407,7 +407,7 @@ public function persist($document)
*/
public function remove($document)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
Expand All @@ -423,7 +423,7 @@ public function remove($document)
*/
public function refresh($document)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
Expand All @@ -442,7 +442,7 @@ public function refresh($document)
*/
public function detach($document)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->detach($document);
Expand All @@ -460,7 +460,7 @@ public function detach($document)
*/
public function merge($document)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
Expand All @@ -477,7 +477,7 @@ public function merge($document)
*/
public function lock($document, $lockMode, $lockVersion = null)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->lock($document, $lockMode, $lockVersion);
Expand All @@ -491,7 +491,7 @@ public function lock($document, $lockMode, $lockVersion = null)
*/
public function unlock($document)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->unlock($document);
Expand Down Expand Up @@ -654,7 +654,7 @@ public function close()
*/
public function contains($document)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
return $this->unitOfWork->isScheduledForInsert($document) ||
Expand Down Expand Up @@ -683,7 +683,7 @@ public function getConfiguration()
*/
public function createDBRef($document, array $referenceMapping = null)
{
if ( ! is_object($document)) {
if (! is_object($document)) {
throw new \InvalidArgumentException('Cannot create a DBRef, the document is not an object');
}

Expand All @@ -696,7 +696,7 @@ public function createDBRef($document, array $referenceMapping = null)
);
}

if ( ! empty($referenceMapping['simple'])) {
if (! empty($referenceMapping['simple'])) {
return $class->getDatabaseIdentifierValue($id);
}

Expand Down Expand Up @@ -760,7 +760,7 @@ private function errorIfClosed()
*/
public function isOpen()
{
return ( ! $this->closed);
return (! $this->closed);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/DocumentNotFoundException.php
Expand Up @@ -32,7 +32,7 @@ public static function documentNotFound($className, $identifier)
{
return new self(sprintf(
'The "%s" document with identifier %s could not be found.',
$className,
$className,
json_encode($identifier)
));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/DocumentRepository.php
Expand Up @@ -210,7 +210,7 @@ public function __call($method, $arguments)
);
}

if ( ! isset($arguments[0])) {
if (! isset($arguments[0])) {
throw MongoDBException::findByRequiresParameter($method . $by);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Event/PreUpdateEventArgs.php
Expand Up @@ -115,7 +115,7 @@ public function setNewValue($field, $value)
*/
private function assertValidField($field)
{
if ( ! isset($this->documentChangeSet[$field])) {
if (! isset($this->documentChangeSet[$field])) {
throw new \InvalidArgumentException(sprintf(
'Field "%s" is not a valid field of the document "%s" in PreUpdateEventArgs.',
$field,
Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Events.php
Expand Up @@ -30,7 +30,9 @@
*/
final class Events
{
private function __construct() {}
private function __construct()
{
}

/**
* The preRemove event occurs for a given document before the respective
Expand Down
20 changes: 9 additions & 11 deletions lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
Expand Up @@ -97,10 +97,10 @@ class HydratorFactory
*/
public function __construct(DocumentManager $dm, EventManager $evm, $hydratorDir, $hydratorNs, $autoGenerate)
{
if ( ! $hydratorDir) {
if (! $hydratorDir) {
throw HydratorException::hydratorDirectoryRequired();
}
if ( ! $hydratorNs) {
if (! $hydratorNs) {
throw HydratorException::hydratorNamespaceRequired();
}
$this->dm = $dm;
Expand Down Expand Up @@ -135,7 +135,7 @@ public function getHydratorFor($className)
$fqn = $this->hydratorNamespace . '\\' . $hydratorClassName;
$class = $this->dm->getClassMetadata($className);

if ( ! class_exists($fqn, false)) {
if (! class_exists($fqn, false)) {
$fileName = $this->hydratorDir . DIRECTORY_SEPARATOR . $hydratorClassName . '.php';
if ($this->autoGenerate) {
$this->generateHydratorClass($class, $hydratorClassName, $fileName);
Expand Down Expand Up @@ -208,9 +208,7 @@ private function generateHydratorClass(ClassMetadata $class, $hydratorClassName,
$mapping['fieldName'],
Type::getType($mapping['type'])->closureToPHP()
);


} elseif ( ! isset($mapping['association'])) {
} elseif (! isset($mapping['association'])) {
$code .= sprintf(<<<EOF

/** @Field(type="{$mapping['type']}") */
Expand Down Expand Up @@ -379,11 +377,11 @@ public function hydrate(\$document, \$data, array \$hints = array())

$parentDirectory = dirname($fileName);

if ( ! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) {
if (! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) {
throw HydratorException::hydratorDirectoryNotWritable();
}

if ( ! is_writable($parentDirectory)) {
if (! is_writable($parentDirectory)) {
throw HydratorException::hydratorDirectoryNotWritable();
}

Expand All @@ -404,7 +402,7 @@ public function hydrate($document, $data, array $hints = array())
{
$metadata = $this->dm->getClassMetadata(get_class($document));
// Invoke preLoad lifecycle events and listeners
if ( ! empty($metadata->lifecycleCallbacks[Events::preLoad])) {
if (! empty($metadata->lifecycleCallbacks[Events::preLoad])) {
$args = array(&$data);
$metadata->invokeLifecycleCallbacks(Events::preLoad, $document, $args);
}
Expand All @@ -413,7 +411,7 @@ public function hydrate($document, $data, array $hints = array())
}

// alsoLoadMethods may transform the document before hydration
if ( ! empty($metadata->alsoLoadMethods)) {
if (! empty($metadata->alsoLoadMethods)) {
foreach ($metadata->alsoLoadMethods as $method => $fieldNames) {
foreach ($fieldNames as $fieldName) {
// Invoke the method only once for the first field we find
Expand All @@ -431,7 +429,7 @@ public function hydrate($document, $data, array $hints = array())
}

// Invoke the postLoad lifecycle callbacks and listeners
if ( ! empty($metadata->lifecycleCallbacks[Events::postLoad])) {
if (! empty($metadata->lifecycleCallbacks[Events::postLoad])) {
$metadata->invokeLifecycleCallbacks(Events::postLoad, $document);
}
if ($this->evm->hasListeners(Events::postLoad)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Hydrator/HydratorInterface.php
Expand Up @@ -37,5 +37,5 @@ interface HydratorInterface
* @param array $hints Any hints to account for during reconstitution/lookup of the document.
* @return array $values The array of hydrated values.
*/
function hydrate($document, $data, array $hints = array());
public function hydrate($document, $data, array $hints = array());
}
1 change: 0 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Id/AlnumGenerator.php
Expand Up @@ -39,7 +39,6 @@
*/
class AlnumGenerator extends IncrementGenerator
{

protected $pad = null;

protected $awkwardSafeMode = false;
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Id/IncrementGenerator.php
Expand Up @@ -41,13 +41,13 @@ class IncrementGenerator extends AbstractIdGenerator
protected $collection = null;
protected $key = null;

public function setCollection($collection)
{
public function setCollection($collection)
{
$this->collection = $collection;
}

public function setKey($key)
{
public function setKey($key)
{
$this->key = $key;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php
Expand Up @@ -117,7 +117,7 @@ public function generateV4()
*/
public function generateV5($namespace, $salt)
{
if ( ! $this->isValid($namespace)) {
if (! $this->isValid($namespace)) {
throw new \Exception('Provided $namespace is invalid: ' . $namespace);
}

Expand Down
Expand Up @@ -111,7 +111,7 @@ public function addDependency($fromClass, $toClass)

public function hasDependency($fromClass, $toClass)
{
if ( ! isset($this->relatedClasses[$fromClass->name])) {
if (! isset($this->relatedClasses[$fromClass->name])) {
return false;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/ODM/MongoDB/LockMode.php
Expand Up @@ -34,5 +34,7 @@ class LockMode
const PESSIMISTIC_READ = 2;
const PESSIMISTIC_WRITE = 4;

final private function __construct() { }
final private function __construct()
{
}
}
10 changes: 5 additions & 5 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php
Expand Up @@ -192,7 +192,7 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS
*/
protected function validateIdentifier($class)
{
if ( ! $class->identifier && ! $class->isMappedSuperclass && ! $class->isEmbeddedDocument) {
if (! $class->identifier && ! $class->isMappedSuperclass && ! $class->isEmbeddedDocument) {
throw MappingException::identifierRequired($class->name);
}
}
Expand Down Expand Up @@ -250,14 +250,14 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class)

$customGenerator = new $idGenOptions['class'];
unset($idGenOptions['class']);
if ( ! $customGenerator instanceof \Doctrine\ODM\MongoDB\Id\AbstractIdGenerator) {
if (! $customGenerator instanceof \Doctrine\ODM\MongoDB\Id\AbstractIdGenerator) {
throw MappingException::classIsNotAValidGenerator(get_class($customGenerator));
}

$methods = get_class_methods($customGenerator);
foreach ($idGenOptions as $name => $value) {
$method = 'set' . ucfirst($name);
if ( ! in_array($method, $methods)) {
if (! in_array($method, $methods)) {
throw MappingException::missingGeneratorSetter(get_class($customGenerator), $name);
}

Expand All @@ -281,10 +281,10 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class)
private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->fieldMappings as $fieldName => $mapping) {
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
$mapping['inherited'] = $parentClass->name;
}
if ( ! isset($mapping['declared'])) {
if (! isset($mapping['declared'])) {
$mapping['declared'] = $parentClass->name;
}
$subClass->addInheritedFieldMapping($mapping);
Expand Down