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

Static Code Analysis with Php Inspections (EA Extended)

This commit is contained in:
Vladimir Reznichenko 2016-11-06 14:22:47 +01:00
parent 3b6309318b
commit 0bf3d7f84c
11 changed files with 16 additions and 12 deletions

View File

@ -314,7 +314,7 @@ class DefaultCache implements Cache
private function buildCollectionCacheKey(ClassMetadata $metadata, $association, $ownerIdentifier) private function buildCollectionCacheKey(ClassMetadata $metadata, $association, $ownerIdentifier)
{ {
if ( ! is_array($ownerIdentifier)) { if ( ! is_array($ownerIdentifier)) {
$ownerIdentifier = $this->toIdentifierArray($metadata, $ownerIdentifier);; $ownerIdentifier = $this->toIdentifierArray($metadata, $ownerIdentifier);
} }
return new CollectionCacheKey($metadata->rootEntityName, $association, $ownerIdentifier); return new CollectionCacheKey($metadata->rootEntityName, $association, $ownerIdentifier);

View File

@ -53,6 +53,6 @@ class Lock
*/ */
public static function createLockRead() public static function createLockRead()
{ {
return new self(uniqid(time())); return new self(uniqid(time(), true));
} }
} }

View File

@ -1629,6 +1629,7 @@ class ClassMetadataInfo implements ClassMetadata
? $joinColumn['fieldName'] ? $joinColumn['fieldName']
: $joinColumn['name']; : $joinColumn['name'];
} }
unset($joinColumn);
if ($uniqueConstraintColumns) { if ($uniqueConstraintColumns) {
if ( ! $this->table) { if ( ! $this->table) {
@ -1754,6 +1755,7 @@ class ClassMetadataInfo implements ClassMetadata
$mapping['relationToSourceKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName']; $mapping['relationToSourceKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName'];
$mapping['joinTableColumns'][] = $joinColumn['name']; $mapping['joinTableColumns'][] = $joinColumn['name'];
} }
unset($joinColumn);
foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) { foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) {
if (empty($inverseJoinColumn['name'])) { if (empty($inverseJoinColumn['name'])) {
@ -1781,6 +1783,7 @@ class ClassMetadataInfo implements ClassMetadata
$mapping['relationToTargetKeyColumns'][$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName']; $mapping['relationToTargetKeyColumns'][$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName'];
$mapping['joinTableColumns'][] = $inverseJoinColumn['name']; $mapping['joinTableColumns'][] = $inverseJoinColumn['name'];
} }
unset($inverseJoinColumn);
} }
$mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval'];

View File

@ -227,7 +227,7 @@ class DatabaseDriver implements MappingDriver
$fkCols = $myFk->getForeignColumns(); $fkCols = $myFk->getForeignColumns();
$cols = $myFk->getColumns(); $cols = $myFk->getColumns();
for ($i = 0; $i < count($cols); $i++) { for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) {
$associationMapping['joinTable']['joinColumns'][] = array( $associationMapping['joinTable']['joinColumns'][] = array(
'name' => $cols[$i], 'name' => $cols[$i],
'referencedColumnName' => $fkCols[$i], 'referencedColumnName' => $fkCols[$i],
@ -237,7 +237,7 @@ class DatabaseDriver implements MappingDriver
$fkCols = $otherFk->getForeignColumns(); $fkCols = $otherFk->getForeignColumns();
$cols = $otherFk->getColumns(); $cols = $otherFk->getColumns();
for ($i = 0; $i < count($cols); $i++) { for ($i = 0, $colsCount = count($cols); $i < $colsCount; $i++) {
$associationMapping['joinTable']['inverseJoinColumns'][] = array( $associationMapping['joinTable']['inverseJoinColumns'][] = array(
'name' => $cols[$i], 'name' => $cols[$i],
'referencedColumnName' => $fkCols[$i], 'referencedColumnName' => $fkCols[$i],
@ -465,7 +465,7 @@ class DatabaseDriver implements MappingDriver
$associationMapping['id'] = true; $associationMapping['id'] = true;
} }
for ($i = 0; $i < count($fkColumns); $i++) { for ($i = 0, $fkColumnsCount = count($fkColumns); $i < $fkColumnsCount; $i++) {
$associationMapping['joinColumns'][] = array( $associationMapping['joinColumns'][] = array(
'name' => $fkColumns[$i], 'name' => $fkColumns[$i],
'referencedColumnName' => $fkForeignColumns[$i], 'referencedColumnName' => $fkForeignColumns[$i],

View File

@ -45,7 +45,7 @@ class ParameterTypeInferer
*/ */
public static function inferType($value) public static function inferType($value)
{ {
if (is_integer($value)) { if (is_int($value)) {
return Type::INTEGER; return Type::INTEGER;
} }
@ -58,7 +58,7 @@ class ParameterTypeInferer
} }
if (is_array($value)) { if (is_array($value)) {
return is_integer(current($value)) return is_int(current($value))
? Connection::PARAM_INT_ARRAY ? Connection::PARAM_INT_ARRAY
: Connection::PARAM_STR_ARRAY; : Connection::PARAM_STR_ARRAY;
} }

View File

@ -119,7 +119,7 @@ class TreeWalkerChainIterator implements \Iterator, \ArrayAccess
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
if (is_null($offset)) { if (null === $offset) {
$this->walkers[] = $value; $this->walkers[] = $value;
} else { } else {
$this->walkers[$offset] = $value; $this->walkers[$offset] = $value;

View File

@ -1458,7 +1458,7 @@ class QueryBuilder
*/ */
public function resetDQLParts($parts = null) public function resetDQLParts($parts = null)
{ {
if (is_null($parts)) { if (null === $parts) {
$parts = array_keys($this->_dqlParts); $parts = array_keys($this->_dqlParts);
} }

View File

@ -180,6 +180,7 @@ EOT
); );
} }
} }
unset($dirName);
if ( ! file_exists($destPath)) { if ( ! file_exists($destPath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(

View File

@ -87,7 +87,7 @@ EOT
$output->writeln(''); $output->writeln('');
} }
$exit += 1; ++$exit;
} else { } else {
$output->writeln('<info>[Mapping] OK - The mapping files are correct.</info>'); $output->writeln('<info>[Mapping] OK - The mapping files are correct.</info>');
} }

View File

@ -78,7 +78,7 @@ class DebugUnitOfWorkListener
$uow = $em->getUnitOfWork(); $uow = $em->getUnitOfWork();
$identityMap = $uow->getIdentityMap(); $identityMap = $uow->getIdentityMap();
$fh = fopen($this->file, "x+"); $fh = fopen($this->file, 'xb+');
if (count($identityMap) == 0) { if (count($identityMap) == 0) {
fwrite($fh, "Flush Operation [".$this->context."] - Empty identity map.\n"); fwrite($fh, "Flush Operation [".$this->context."] - Empty identity map.\n");

View File

@ -808,7 +808,7 @@ public function __construct(<params>)
$inNamespace = false; $inNamespace = false;
$inClass = false; $inClass = false;
for ($i = 0; $i < count($tokens); $i++) { for ($i = 0, $tokensCount = count($tokens); $i < $tokensCount; $i++) {
$token = $tokens[$i]; $token = $tokens[$i];
if (in_array($token[0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) { if (in_array($token[0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) {
continue; continue;