Skip to content

Commit

Permalink
Fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Majkl578 authored and lcobucci committed Dec 31, 2017
1 parent 6a9b817 commit 17e7c2a
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public function __construct($value, $time = null)
*/
public static function createLockRead()
{
return new self(uniqid(time(), true));
return new self(uniqid((string) time(), true));
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ private function convertCacheElementToCacheMetadata(

$region = isset($cacheMapping['region']) ? (string) $cacheMapping['region'] : $defaultRegion;
$usage = isset($cacheMapping['usage'])
? constant(sprintf('%s::%s', Mapping\CacheUsage::class, strtoupper($cacheMapping['usage'])))
? constant(sprintf('%s::%s', Mapping\CacheUsage::class, strtoupper((string) $cacheMapping['usage'])))
: Mapping\CacheUsage::READ_ONLY
;

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Proxy/Factory/ProxyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ private function generateMethods(ProxyDefinition $definition) : string
}

// Do not consider identifier-getter methods
$fieldCandidate = lcfirst(substr($reflectionMethod->getName(), 3));
$fieldCandidate = lcfirst((string) substr($reflectionMethod->getName(), 3));
$isIdentifier = $reflectionMethod->getNumberOfParameters() === 0
&& strpos($reflectionMethod->getName(), 'get') === 0
&& $classMetadata->hasField($fieldCandidate)
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Query/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Parameter
*/
public function __construct($name, $value, $type = null)
{
$this->name = trim($name, ':');
$this->name = trim((string) $name, ':');

$this->setValue($value, $type);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public function semanticalError($message = '', $token = null)
$length = ($pos !== false) ? $pos - $token['position'] : $distance;

$tokenPos = (isset($token['position']) && $token['position'] > 0) ? $token['position'] : '-1';
$tokenStr = substr($dql, $token['position'], $length);
$tokenStr = substr($dql, (int) $token['position'], $length);

// Building informative message
$message = 'line 0, col ' . $tokenPos . " near '" . $tokenStr . "': Error: " . $message;
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Query/SqlWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ public function walkNewObject($newObjectExpression, $newObjectResultAlias=null)
$class = $qComp['metadata'];
$fieldType = $class->getProperty($e->field)->getType();

$sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias;
$sqlSelectExpressions[] = trim((string) $e->dispatch($this)) . ' AS ' . $columnAlias;
break;

case ($e instanceof AST\Literal):
Expand All @@ -1632,11 +1632,11 @@ public function walkNewObject($newObjectExpression, $newObjectResultAlias=null)
break;
}

$sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias;
$sqlSelectExpressions[] = trim((string) $e->dispatch($this)) . ' AS ' . $columnAlias;
break;

default:
$sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias;
$sqlSelectExpressions[] = trim((string) $e->dispatch($this)) . ' AS ' . $columnAlias;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function generateEntityRepositoryClass($fullClassName)
*/
private function getClassNamespace($fullClassName)
{
$namespace = substr($fullClassName, 0, strrpos($fullClassName, '\\'));
$namespace = substr($fullClassName, 0, (int) strrpos($fullClassName, '\\'));

return $namespace;
}
Expand Down
26 changes: 13 additions & 13 deletions lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public function exportClassMetadata(ClassMetadata $metadata)
$discriminatorColumnXml->addAttribute('type', $discrColumn->getTypeName());

if (is_int($discrColumn->getLength())) {
$discriminatorColumnXml->addAttribute('length', $discrColumn->getLength());
$discriminatorColumnXml->addAttribute('length', (string) $discrColumn->getLength());
}

if (is_int($discrColumn->getScale())) {
$discriminatorColumnXml->addAttribute('scale', $discrColumn->getScale());
$discriminatorColumnXml->addAttribute('scale', (string) $discrColumn->getScale());
}

if (is_int($discrColumn->getPrecision())) {
$discriminatorColumnXml->addAttribute('precision', $discrColumn->getPrecision());
$discriminatorColumnXml->addAttribute('precision', (string) $discrColumn->getPrecision());
}
}

Expand All @@ -115,7 +115,7 @@ public function exportClassMetadata(ClassMetadata $metadata)

foreach ($metadata->discriminatorMap as $value => $className) {
$discriminatorMappingXml = $discriminatorMapXml->addChild('discriminator-mapping');
$discriminatorMappingXml->addAttribute('value', $value);
$discriminatorMappingXml->addAttribute('value', (string) $value);
$discriminatorMappingXml->addAttribute('class', $className);
}
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public function exportClassMetadata(ClassMetadata $metadata)
$a1 = array_search(get_class($m1), $orderMap);
$a2 = array_search(get_class($m2), $orderMap);

return strcmp($a1, $a2);
return strcmp((string) $a1, (string) $a2);
});

foreach ($properties as $property) {
Expand Down Expand Up @@ -285,15 +285,15 @@ private function exportFieldMetadata(
}

if (is_int($property->getLength())) {
$fieldXml->addAttribute('length', $property->getLength());
$fieldXml->addAttribute('length', (string) $property->getLength());
}

if (is_int($property->getPrecision())) {
$fieldXml->addAttribute('precision', $property->getPrecision());
$fieldXml->addAttribute('precision', (string) $property->getPrecision());
}

if (is_int($property->getScale())) {
$fieldXml->addAttribute('scale', $property->getScale());
$fieldXml->addAttribute('scale', (string) $property->getScale());
}

if ($metadata->isVersioned() && $metadata->versionProperty->getName() === $property->getName()) {
Expand All @@ -308,7 +308,7 @@ private function exportFieldMetadata(
$optionsXml = $fieldXml->addChild('options');

foreach ($property->getOptions() as $key => $value) {
$optionXml = $optionsXml->addChild('option', $value);
$optionXml = $optionsXml->addChild('option', (string) $value);

$optionXml->addAttribute('name', $key);
}
Expand Down Expand Up @@ -420,18 +420,18 @@ private function exportJoinColumns(
}

if ($joinColumn->isNullable()) {
$joinColumnXml->addAttribute('nullable', $joinColumn->isNullable());
$joinColumnXml->addAttribute('nullable', (string) $joinColumn->isNullable());
}

if ($joinColumn->isUnique()) {
$joinColumnXml->addAttribute('unique', $joinColumn->isUnique());
$joinColumnXml->addAttribute('unique', (string) $joinColumn->isUnique());
}

if ($joinColumn->getOptions()) {
$optionsXml = $joinColumnXml->addChild('options');

foreach ($joinColumn->getOptions() as $key => $value) {
$optionXml = $optionsXml->addChild('option', $value);
$optionXml = $optionsXml->addChild('option', (string) $value);

$optionXml->addAttribute('name', $key);
}
Expand Down Expand Up @@ -509,7 +509,7 @@ private function exportSequenceInformation(\SimpleXMLElement $identifierXmlNode,
$sequenceGeneratorXml = $identifierXmlNode->addChild('sequence-generator');

$sequenceGeneratorXml->addAttribute('sequence-name', $sequenceDefinition['sequenceName']);
$sequenceGeneratorXml->addAttribute('allocation-size', $sequenceDefinition['allocationSize']);
$sequenceGeneratorXml->addAttribute('allocation-size', (string) $sequenceDefinition['allocationSize']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/ToolsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ class ToolsException extends ORMException
{
public static function schemaToolFailure(string $sql, Throwable $e) : self
{
return new self("Schema-Tool failed with Error '" . $e->getMessage() . "' while executing DDL: " . $sql, "0", $e);
return new self("Schema-Tool failed with Error '" . $e->getMessage() . "' while executing DDL: " . $sql, 0, $e);
}
}
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public function testBuildCachedEntityPersisterNonStrictException()
$persister = new BasicEntityPersister($em, $metadata);

$metadata->setCache(
new CacheMetadata(-1, 'doctrine_tests_models_cache_state')
new CacheMetadata('-1', 'doctrine_tests_models_cache_state')
);

$this->expectException(\InvalidArgumentException::class);
Expand All @@ -286,7 +286,7 @@ public function testBuildCachedCollectionPersisterException()
$persister = new OneToManyPersister($em);

$association->setCache(
new CacheMetadata(-1, 'doctrine_tests_models_cache_state__cities')
new CacheMetadata('-1', 'doctrine_tests_models_cache_state__cities')
);

$this->expectException(\InvalidArgumentException::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Cache/FileLockRegionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private function cleanTestDirectory($path)
foreach ($directoryIterator as $file) {
if ($file->isFile()) {
@unlink($file->getRealPath());
} else {
} elseif ($file->getRealPath() !== false) {
@rmdir($file->getRealPath());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function testOptimisticTimestampLockFailureThrowsException(OptimisticTime
$caughtException = null;

try {
$expectedVersionExpired = DateTime::createFromFormat('U', $test->version->getTimestamp()-3600);
$expectedVersionExpired = DateTime::createFromFormat('U', (string) ($test->version->getTimestamp()-3600));

$this->em->lock($test, LockMode::OPTIMISTIC, $expectedVersionExpired);
} catch (OptimisticLockException $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ protected function tearDown()

foreach ($iterator as $path) {
if ($path->isDir()) {
@rmdir($path);
@rmdir((string) $path);
} else {
@unlink($path);
@unlink((string) $path);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/OrmFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,8 @@ function($p) {
public static function assertSQLEquals($expectedSql, $actualSql)
{
self::assertEquals(
strtolower($expectedSql),
strtolower($actualSql),
strtolower((string) $expectedSql),
strtolower((string) $actualSql),
"Lowercase comparison of SQL statements failed."
);
}
Expand Down

0 comments on commit 17e7c2a

Please sign in to comment.