1
0
mirror of synced 2025-02-02 21:41:45 +03:00

minor code work:

- method calls with incorrect case
- removed unused imports
- typos and some other minor code smells
- documentation update (wrong return types etc. )
This commit is contained in:
Artem Stepin 2017-06-08 22:04:07 +02:00
parent 049ad1e079
commit 43009682a4
42 changed files with 82 additions and 52 deletions

View File

@ -27,9 +27,6 @@ use Doctrine\ORM\Query\Parameter;
use Doctrine\ORM\Cache\QueryCacheKey;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\ORM\Cache;
use Doctrine\ORM\Query\ResultSetMapping;
/**
* Base contract for ORM queries. Base class for Query and NativeQuery.
*

View File

@ -30,7 +30,6 @@ use Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister;
use Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister;
use Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister;
use Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister;
use Doctrine\ORM\Cache\Region;
use Doctrine\ORM\Cache\Region\DefaultMultiGetRegion;
use Doctrine\ORM\Cache\Region\DefaultRegion;
use Doctrine\ORM\Cache\Region\FileLockRegion;

View File

@ -21,7 +21,6 @@
namespace Doctrine\ORM\Cache\Region;
use Doctrine\Common\Cache\MultiGetCache;
use Doctrine\ORM\Cache\Region;
use Doctrine\ORM\Cache\CollectionCacheEntry;
/**

View File

@ -19,7 +19,6 @@
namespace Doctrine\ORM;
use Doctrine\ORM\Mapping\MappingException;
use Exception;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Connection;

View File

@ -433,7 +433,7 @@ class ObjectHydrator extends AbstractHydrator
if ( ! $reflFieldValue || isset($this->_hints[Query::HINT_REFRESH]) || ($reflFieldValue instanceof Proxy && !$reflFieldValue->__isInitialized__)) {
// we only need to take action if this value is null,
// we refresh the entity or its an unitialized proxy.
// we refresh the entity or its an uninitialized proxy.
if (isset($nonemptyComponents[$dqlAlias])) {
$element = $this->getEntity($data, $dqlAlias);
$reflField->setValue($parentObject, $element);

View File

@ -1376,7 +1376,7 @@ class ClassMetadataInfo implements ClassMetadata
*
* @param array $mapping The field mapping to validate & complete.
*
* @return array The validated and completed field mapping.
* @return void
*
* @throws MappingException
*/
@ -2034,7 +2034,7 @@ class ClassMetadataInfo implements ClassMetadata
*
* @return \Doctrine\DBAL\Types\Type|string|null
*
* @deprecated 3.0 remove this. this method is bogous and unreliable, since it cannot resolve the type of a column
* @deprecated 3.0 remove this. this method is bogus and unreliable, since it cannot resolve the type of a column
* that is derived by a referenced field on a different entity.
*/
public function getTypeOfColumn($columnName)

View File

@ -393,7 +393,7 @@ class DatabaseDriver implements MappingDriver
'fieldName' => $this->getFieldNameForColumn($tableName, $column->getName(), false),
'columnName' => $column->getName(),
'type' => $column->getType()->getName(),
'nullable' => ( ! $column->getNotNull()),
'nullable' => ( ! $column->getNotnull()),
];
// Type specific elements
@ -482,7 +482,7 @@ class DatabaseDriver implements MappingDriver
}
/**
* Retreive schema table definition foreign keys.
* Retrieve schema table definition foreign keys.
*
* @param \Doctrine\DBAL\Schema\Table $table
*

View File

@ -166,7 +166,7 @@ class XmlDriver extends FileDriver
$inheritanceType = (string) $xmlRoot['inheritance-type'];
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceType));
if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
if ($metadata->inheritanceType != Metadata::INHERITANCE_TYPE_NONE) {
// Evaluate <discriminator-column...>
if (isset($xmlRoot->{'discriminator-column'})) {
$discrColumn = $xmlRoot->{'discriminator-column'};

View File

@ -175,7 +175,7 @@ class YamlDriver extends FileDriver
if (isset($element['inheritanceType'])) {
$metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($element['inheritanceType'])));
if ($metadata->inheritanceType != \Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_NONE) {
if ($metadata->inheritanceType != Metadata::INHERITANCE_TYPE_NONE) {
// Evaluate discriminatorColumn
if (isset($element['discriminatorColumn'])) {
$discrColumn = $element['discriminatorColumn'];

View File

@ -52,8 +52,10 @@ interface NamingStrategy
/**
* Returns a column name for an embedded property.
*
* @param string $propertyName
* @param string $embeddedColumnName
* @param string $propertyName
* @param string $embeddedColumnName
* @param string $className
* @param string $embeddedClassName
*
* @return string
*/
@ -70,12 +72,10 @@ interface NamingStrategy
* Returns a join column name for a property.
*
* @param string $propertyName A property name.
* @param string|null $className The fully-qualified class name.
* This parameter is omitted from the signature due to BC
*
* @return string A join column name.
*/
function joinColumnName($propertyName/*, $className = null*/);
function joinColumnName($propertyName);
/**
* Returns a join table name.

View File

@ -1064,11 +1064,11 @@ class BasicEntityPersister implements EntityPersister
switch ($lockMode) {
case LockMode::PESSIMISTIC_READ:
$lockSql = ' ' . $this->platform->getReadLockSql();
$lockSql = ' ' . $this->platform->getReadLockSQL();
break;
case LockMode::PESSIMISTIC_WRITE:
$lockSql = ' ' . $this->platform->getWriteLockSql();
$lockSql = ' ' . $this->platform->getWriteLockSQL();
break;
}
@ -1520,12 +1520,12 @@ class BasicEntityPersister implements EntityPersister
switch ($lockMode) {
case LockMode::PESSIMISTIC_READ:
$lockSql = $this->platform->getReadLockSql();
$lockSql = $this->platform->getReadLockSQL();
break;
case LockMode::PESSIMISTIC_WRITE:
$lockSql = $this->platform->getWriteLockSql();
$lockSql = $this->platform->getWriteLockSQL();
break;
}
@ -1870,8 +1870,9 @@ class BasicEntityPersister implements EntityPersister
/**
* Infers field types to be used by parameter type casting.
*
* @param string $field
* @param mixed $value
* @param string $field
* @param mixed $value
* @param ClassMetadata $class
*
* @return array
*

View File

@ -341,13 +341,13 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
switch ($lockMode) {
case LockMode::PESSIMISTIC_READ:
$lockSql = ' ' . $this->platform->getReadLockSql();
$lockSql = ' ' . $this->platform->getReadLockSQL();
break;
case LockMode::PESSIMISTIC_WRITE:
$lockSql = ' ' . $this->platform->getWriteLockSql();
$lockSql = ' ' . $this->platform->getWriteLockSQL();
break;
}

View File

@ -24,6 +24,9 @@ use Doctrine\ORM\ORMException;
class PersisterException extends ORMException
{
/**
* @param string $class
* @param string $associationName
*
* @return PersisterException
*/
static public function matchingAssocationFieldRequiresObject($class, $associationName)

View File

@ -46,7 +46,7 @@ class SqlValueVisitor extends ExpressionVisitor
*
* @param \Doctrine\Common\Collections\Expr\Comparison $comparison
*
* @return mixed
* @return void
*/
public function walkComparison(Comparison $comparison)
{
@ -69,7 +69,7 @@ class SqlValueVisitor extends ExpressionVisitor
*
* @param \Doctrine\Common\Collections\Expr\CompositeExpression $expr
*
* @return mixed
* @return void
*/
public function walkCompositeExpression(CompositeExpression $expr)
{

View File

@ -19,7 +19,6 @@
namespace Doctrine\ORM;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\Query\Exec\AbstractSqlExecutor;
use Doctrine\ORM\Query\Parser;
@ -204,7 +203,7 @@ final class Query extends AbstractQuery
*/
public function getSQL()
{
return $this->_parse()->getSQLExecutor()->getSQLStatements();
return $this->_parse()->getSqlExecutor()->getSqlStatements();
}
/**
@ -738,7 +737,7 @@ final class Query extends AbstractQuery
->getName();
return md5(
$this->getDql() . serialize($this->_hints) .
$this->getDQL() . serialize($this->_hints) .
'&platform=' . $platform .
($this->_em->hasFilters() ? $this->_em->getFilters()->getHash() : '') .
'&firstResult=' . $this->_firstResult . '&maxResult=' . $this->_maxResults .

View File

@ -41,6 +41,7 @@ class AbsFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -51,6 +52,7 @@ class AbsFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -36,6 +36,7 @@ class BitAndFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -49,6 +50,7 @@ class BitAndFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -36,6 +36,7 @@ class BitOrFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -49,6 +50,7 @@ class BitOrFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -42,6 +42,7 @@ class ConcatFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -58,6 +59,7 @@ class ConcatFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -36,6 +36,7 @@ class CurrentDateFunction extends FunctionNode
{
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -44,6 +45,7 @@ class CurrentDateFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -36,6 +36,7 @@ class CurrentTimeFunction extends FunctionNode
{
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -44,6 +45,7 @@ class CurrentTimeFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -36,6 +36,7 @@ class CurrentTimestampFunction extends FunctionNode
{
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -44,6 +45,7 @@ class CurrentTimestampFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -41,6 +41,7 @@ class DateAddFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(SqlWalker $sqlWalker)
{
@ -77,6 +78,7 @@ class DateAddFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(Parser $parser)
{

View File

@ -38,6 +38,7 @@ class DateDiffFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(SqlWalker $sqlWalker)
{
@ -49,6 +50,7 @@ class DateDiffFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(Parser $parser)
{

View File

@ -35,6 +35,7 @@ class DateSubFunction extends DateAddFunction
{
/**
* @override
* @inheritdoc
*/
public function getSql(SqlWalker $sqlWalker)
{

View File

@ -38,6 +38,7 @@ class LengthFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -48,6 +49,7 @@ class LengthFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -44,6 +44,7 @@ class LocateFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -60,6 +61,7 @@ class LocateFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -38,6 +38,7 @@ class LowerFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -48,6 +49,7 @@ class LowerFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -46,6 +46,7 @@ class ModFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -57,6 +58,7 @@ class ModFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -41,6 +41,7 @@ class SizeFunction extends FunctionNode
/**
* @override
* @inheritdoc
* @todo If the collection being counted is already joined, the SQL can be simpler (more efficient).
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
@ -110,6 +111,7 @@ class SizeFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -41,6 +41,7 @@ class SqrtFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -51,6 +52,7 @@ class SqrtFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -48,6 +48,7 @@ class SubstringFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -65,6 +66,7 @@ class SubstringFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -38,6 +38,7 @@ class UpperFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -48,6 +49,7 @@ class UpperFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function parse(\Doctrine\ORM\Query\Parser $parser)
{

View File

@ -197,7 +197,7 @@ class Parser
{
$this->query = $query;
$this->em = $query->getEntityManager();
$this->lexer = new Lexer($query->getDql());
$this->lexer = new Lexer($query->getDQL());
$this->parserResult = new ParserResult();
}
@ -277,7 +277,7 @@ class Parser
}
if ($this->deferredPathExpressions) {
$this->processDeferredPathExpressions($AST);
$this->processDeferredPathExpressions();
}
if ($this->deferredResultVariables) {
@ -482,7 +482,7 @@ class Parser
$distance = 12;
// Find a position of a final word to display in error string
$dql = $this->query->getDql();
$dql = $this->query->getDQL();
$length = strlen($dql);
$pos = $token['position'] + $distance;
$pos = strpos($dql, ' ', ($length > $pos) ? $pos : $length);
@ -749,11 +749,9 @@ class Parser
* SingleValuedAssociationPathExpression ::= IdentificationVariable "." SingleValuedAssociationField
* CollectionValuedPathExpression ::= IdentificationVariable "." CollectionValuedAssociationField
*
* @param mixed $AST
*
* @return void
*/
private function processDeferredPathExpressions($AST)
private function processDeferredPathExpressions()
{
foreach ($this->deferredPathExpressions as $deferredItem) {
$pathExpression = $deferredItem['expression'];
@ -1504,7 +1502,7 @@ class Parser
$glimpse = $this->lexer->glimpse();
switch (true) {
case ($this->isFunction($peek)):
case ($this->isFunction()):
$expr = $this->FunctionDeclaration();
break;
@ -1795,7 +1793,7 @@ class Parser
* PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet
* PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}"
*
* @return array
* @return \Doctrine\ORM\Query\AST\PartialObjectExpression
*/
public function PartialObjectExpression()
{

View File

@ -1502,8 +1502,8 @@ class SqlWalker implements TreeWalker
}
/**
* @param AST\NewObjectExpression $newObjectExpression
*
* @param AST\NewObjectExpression $newObjectExpression
* @param null|string $newObjectResultAlias
* @return string The SQL.
*/
public function walkNewObject($newObjectExpression, $newObjectResultAlias=null)
@ -1761,7 +1761,7 @@ class SqlWalker implements TreeWalker
public function walkWhereClause($whereClause)
{
$condSql = null !== $whereClause ? $this->walkConditionalExpression($whereClause->conditionalExpression) : '';
$discrSql = $this->_generateDiscriminatorColumnConditionSql($this->rootAliases);
$discrSql = $this->_generateDiscriminatorColumnConditionSQL($this->rootAliases);
if ($this->em->hasFilters()) {
$filterClauses = [];

View File

@ -21,7 +21,6 @@ namespace Doctrine\ORM\Tools\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console;
use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
use Doctrine\ORM\Tools\ConvertDoctrine1Schema;
use Doctrine\ORM\Tools\EntityGenerator;

View File

@ -185,7 +185,7 @@ EOT
if (count($matches) > 1) {
throw new \InvalidArgumentException(sprintf(
'Entity name "%s" is ambigous, possible matches: "%s"',
'Entity name "%s" is ambiguous, possible matches: "%s"',
$entityName, implode(', ', $matches)
));
}

View File

@ -143,7 +143,7 @@ class DebugUnitOfWorkListener
if (is_object($var)) {
$refl = new \ReflectionObject($var);
return $refl->getShortname();
return $refl->getShortName();
}
return gettype($var);
@ -176,7 +176,7 @@ class DebugUnitOfWorkListener
$idstring .= " [REMOVED]";
} elseif ($state == UnitOfWork::STATE_MANAGED) {
$idstring .= " [MANAGED]";
} elseif ($state == UnitOfwork::STATE_DETACHED) {
} elseif ($state == UnitOfWork::STATE_DETACHED) {
$idstring .= " [DETACHED]";
}

View File

@ -40,6 +40,7 @@ class RowNumberOverFunction extends FunctionNode
/**
* @override
* @inheritdoc
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
@ -50,6 +51,7 @@ class RowNumberOverFunction extends FunctionNode
/**
* @override
* @inheritdoc
*
* @throws ORMException
*/

View File

@ -80,7 +80,7 @@ class ResolveTargetEntityListener implements EventSubscriber
$args->setFoundMetadata(
$args
->getObjectManager()
->getClassMetadata($this->resolveTargetEntities[$args->getClassname()]['targetEntity'])
->getClassMetadata($this->resolveTargetEntities[$args->getClassName()]['targetEntity'])
);
}
}

View File

@ -351,8 +351,7 @@ class SchemaTool
* @param ClassMetadata $class
* @param Table $table
*
* @return array The portable column definition of the discriminator column as required by
* the DBAL.
* @return void
*/
private function addDiscriminatorColumnDefinition($class, Table $table)
{
@ -384,7 +383,7 @@ class SchemaTool
* @param ClassMetadata $class
* @param Table $table
*
* @return array The list of portable column definitions as required by the DBAL.
* @return void
*/
private function gatherColumns($class, Table $table)
{
@ -410,7 +409,7 @@ class SchemaTool
* @param array $mapping The field mapping.
* @param Table $table
*
* @return array The portable column definition as required by the DBAL.
* @return void
*/
private function gatherColumn($class, array $mapping, Table $table)
{

View File

@ -90,7 +90,7 @@ class SchemaValidator
foreach ($class->fieldMappings as $fieldName => $mapping) {
if (!Type::hasType($mapping['type'])) {
$ce[] = "The field '" . $class->name . "#" . $fieldName."' uses a non-existant type '" . $mapping['type'] . "'.";
$ce[] = "The field '" . $class->name . "#" . $fieldName."' uses a non-existent type '" . $mapping['type'] . "'.";
}
}