Skip to content

Commit

Permalink
Merge pull request #1954 from michbeck/bugfix/fix-cs-redundant-type-c…
Browse files Browse the repository at this point in the history
…asts

Fix up redundant type casts
  • Loading branch information
dereuromark committed Jan 25, 2023
2 parents 912ddae + e5f55db commit 011aaa7
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Propel/Generator/Builder/Om/ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected function getDefaultValueString(Column $column): string
}
$defaultValue = (string)array_search($val, $valueSet);
} elseif ($column->isSetType()) {
$defaultValue = (string)SetColumnConverter::convertToInt($val, $column->getValueSet());
$defaultValue = SetColumnConverter::convertToInt($val, $column->getValueSet());
} elseif ($column->isPhpPrimitiveType()) {
settype($val, $column->getPhpType());
$defaultValue = var_export($val, true);
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Generator/Command/TestPrepareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected function buildFixtures(string $fixturesDir, array $connections, InputI
$command->run($in, $output);
}

if (0 < count((array)$this->getSchemas('.'))) {
if (0 < count($this->getSchemas('.'))) {
$in = new ArrayInput([
'command' => 'model:build',
'--schema-dir' => '.',
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Generator/Manager/AbstractManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function getDatabase(string $name): ?Database
*/
public function setValidate(bool $validate): void
{
$this->validate = (bool)$validate;
$this->validate = $validate;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Propel/Generator/Manager/ReverseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function setDatabaseName(string $databaseName): void
*/
public function setSamePhpName(bool $samePhpName): void
{
$this->samePhpName = (bool)$samePhpName;
$this->samePhpName = $samePhpName;
}

/**
Expand All @@ -162,7 +162,7 @@ public function setSamePhpName(bool $samePhpName): void
*/
public function setAddVendorInfo(bool $addVendorInfo): void
{
$this->addVendorInfo = (bool)$addVendorInfo;
$this->addVendorInfo = $addVendorInfo;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Generator/Manager/SqlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function isOverwriteSqlMap(): bool
*/
public function setOverwriteSqlMap(bool $overwriteSqlMap): void
{
$this->overwriteSqlMap = (bool)$overwriteSqlMap;
$this->overwriteSqlMap = $overwriteSqlMap;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Propel/Generator/Model/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ public function getNotNullString(): string
*/
public function setPrimaryString(bool $isPrimaryString): void
{
$this->isPrimaryString = (bool)$isPrimaryString;
$this->isPrimaryString = $isPrimaryString;
}

/**
Expand Down Expand Up @@ -973,7 +973,7 @@ public function isPrimaryKey(): bool
*/
public function setNodeKey(bool $isNodeKey): void
{
$this->isNodeKey = (bool)$isNodeKey;
$this->isNodeKey = $isNodeKey;
}

/**
Expand All @@ -995,7 +995,7 @@ public function isNodeKey(): bool
*/
public function setNodeKeySep(string $sep): void
{
$this->nodeKeySep = (string)$sep;
$this->nodeKeySep = $sep;
}

/**
Expand All @@ -1017,7 +1017,7 @@ public function getNodeKeySep(): string
*/
public function setNestedSetLeftKey(bool $isNestedSetLeftKey): void
{
$this->isNestedSetLeftKey = (bool)$isNestedSetLeftKey;
$this->isNestedSetLeftKey = $isNestedSetLeftKey;
}

/**
Expand All @@ -1039,7 +1039,7 @@ public function isNestedSetLeftKey(): bool
*/
public function setNestedSetRightKey(bool $isNestedSetRightKey): void
{
$this->isNestedSetRightKey = (bool)$isNestedSetRightKey;
$this->isNestedSetRightKey = $isNestedSetRightKey;
}

/**
Expand All @@ -1061,7 +1061,7 @@ public function isNestedSetRightKey(): bool
*/
public function setTreeScopeKey(bool $isTreeScopeKey): void
{
$this->isTreeScopeKey = (bool)$isTreeScopeKey;
$this->isTreeScopeKey = $isTreeScopeKey;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Generator/Model/ForeignKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ public function isLocalPrimaryKey(): bool
*/
public function setSkipSql(bool $skip): void
{
$this->skipSql = (bool)$skip;
$this->skipSql = $skip;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Generator/Model/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function addColumn($data): void
{
if ($data instanceof Column) {
$column = $data;
$this->columns[] = (string)$column->getName();
$this->columns[] = $column->getName();
if ($column->getSize()) {
$this->columnsSize[$column->getName()] = (int)$column->getSize();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Propel/Generator/Model/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function setupObject(): void
// retrieves the method for converting from specified name to a PHP name.
$this->phpNamingMethod = $this->getAttribute('phpNamingMethod', $this->database->getDefaultPhpNamingMethod());

$this->phpName = $this->getAttribute('phpName', $this->buildPhpName((string)$this->getStdSeparatedName()));
$this->phpName = $this->getAttribute('phpName', $this->buildPhpName($this->getStdSeparatedName()));

if ($this->database->getTablePrefix()) {
$this->commonName = $this->database->getTablePrefix() . $this->commonName;
Expand Down Expand Up @@ -944,7 +944,7 @@ public function getOtherRequiredPrimaryKeys(array $primaryKeys): array
*/
public function setContainsForeignPK(bool $containsForeignPK): void
{
$this->containsForeignPK = (bool)$containsForeignPK;
$this->containsForeignPK = $containsForeignPK;
}

/**
Expand Down Expand Up @@ -1248,7 +1248,7 @@ public function setDescription(string $description): void
public function getPhpName(): string
{
if ($this->phpName === null) {
$this->phpName = $this->buildPhpName((string)$this->getStdSeparatedName());
$this->phpName = $this->buildPhpName($this->getStdSeparatedName());
}

return $this->phpName;
Expand Down Expand Up @@ -1416,7 +1416,7 @@ public function isSkipSql(): bool
*/
public function setSkipSql(bool $skip): void
{
$this->skipSql = (bool)$skip;
$this->skipSql = $skip;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Propel/Runtime/ActiveQuery/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ public function hasWhereClause(): bool
*/
public function setUseTransaction(bool $v)
{
$this->useTransaction = (bool)$v;
$this->useTransaction = $v;

return $this;
}
Expand Down Expand Up @@ -1444,7 +1444,7 @@ public function withoutLock()
*/
public function setIgnoreCase(bool $b)
{
$this->ignoreCase = (bool)$b;
$this->ignoreCase = $b;

return $this;
}
Expand Down Expand Up @@ -1474,7 +1474,7 @@ public function isIgnoreCase(): bool
*/
public function setSingleRecord(bool $b)
{
$this->singleRecord = (bool)$b;
$this->singleRecord = $b;

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(Criteria $outer, $column, $value, ?string $compariso
*/
public function setIgnoreCase(bool $b)
{
$this->ignoreStringCase = (bool)$b;
$this->ignoreStringCase = $b;

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(Criteria $outer, string $value)
protected function appendPsForUniqueClauseTo(string &$sb, array &$params): void
{
if ($this->value !== '') {
$sb .= (string)$this->value;
$sb .= $this->value;
}
}
}
2 changes: 1 addition & 1 deletion src/Propel/Runtime/ActiveQuery/Criterion/LikeCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(Criteria $outer, $column, $value, string $comparison
*/
public function setIgnoreCase(bool $b)
{
$this->ignoreStringCase = (bool)$b;
$this->ignoreStringCase = $b;

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LikeModelCriterion extends BasicModelCriterion
*/
public function setIgnoreCase(bool $b)
{
$this->ignoreStringCase = (bool)$b;
$this->ignoreStringCase = $b;

return $this;
}
Expand Down
3 changes: 0 additions & 3 deletions src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ public function quoteIdentifierTable(string $table): string
*/
public function applyLimit(string &$sql, int $offset, int $limit, ?Criteria $criteria = null): void
{
$offset = (int)$offset;
$limit = (int)$limit;

if ($limit >= 0) {
$sql .= ' LIMIT ' . ($offset > 0 ? $offset . ', ' : '') . $limit;
} elseif ($offset > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Runtime/Collection/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ public function __call(string $name, $params)
*/
public function __toString(): string
{
return (string)$this->exportTo($this->getTableMapClass()::DEFAULT_STRING_FORMAT, false);
return $this->exportTo($this->getTableMapClass()::DEFAULT_STRING_FORMAT, false);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Runtime/Collection/OnDemandIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@ public function rewind(): void
*/
public function valid(): bool
{
return (bool)$this->isValid;
return $this->isValid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function isForcePrimaryConnection(): bool
*/
public function setForcePrimaryConnection(bool $isForceMasterConnection): void
{
$this->isForcePrimaryConnection = (bool)$isForceMasterConnection;
$this->isForcePrimaryConnection = $isForceMasterConnection;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Runtime/Connection/ConnectionWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public function forceRollBack(): bool
*/
public function inTransaction(): bool
{
return (bool)$this->connection->inTransaction();
return $this->connection->inTransaction();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Propel/Runtime/Map/ColumnMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public function getSize(): int
*/
public function setPrimaryKey(bool $pk): void
{
$this->pk = (bool)$pk;
$this->pk = $pk;
}

/**
Expand All @@ -357,7 +357,7 @@ public function isPrimaryKey(): bool
*/
public function setNotNull(bool $nn): void
{
$this->notNull = (bool)$nn;
$this->notNull = $nn;
}

/**
Expand Down Expand Up @@ -592,7 +592,7 @@ public static function normalizeName(string $name): string
*/
public function setPrimaryString(bool $pkString): void
{
$this->isPkString = (bool)$pkString;
$this->isPkString = $pkString;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Runtime/Map/TableMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function getPackage(): ?string
*/
public function setUseIdGenerator(bool $bit): void
{
$this->useIdGenerator = (bool)$bit;
$this->useIdGenerator = $bit;
}

/**
Expand Down

0 comments on commit 011aaa7

Please sign in to comment.