Skip to content

Commit

Permalink
fix stan
Browse files Browse the repository at this point in the history
  • Loading branch information
mringler committed Apr 7, 2021
1 parent 094b03d commit 5d34063
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 41 deletions.
20 changes: 0 additions & 20 deletions phpstan-baseline.neon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@ public function getModelShortName()
return static::getShortName($this->modelName);
}

/**
* Return the short ClassName for class with namespace
*
* @param string $fullyQualifiedClassName The fully qualified class name
*
* @return string The short class name
*/
public static function getShortName($fullyQualifiedClassName)
{
$namespaceParts = explode('\\', $fullyQualifiedClassName);

return array_pop($namespaceParts);
}

/**
* Returns the TableMap object for this Criteria
*
Expand Down
8 changes: 5 additions & 3 deletions src/Propel/Runtime/ActiveQuery/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,7 @@ public function doInsert(?ConnectionInterface $con = null)
$this->add($pk->getFullyQualifiedName(), $id);
}

$sql = null;
try {
$qualifiedCols = $this->keys(); // we need table.column cols when populating values
$columns = []; // but just 'column' cols for the SQL
Expand Down Expand Up @@ -2577,6 +2578,8 @@ public function doUpdate($updateValues, ConnectionInterface $con)
$whereClause = [];
$params = [];
$stmt = null;
$sql = null;

try {
$sql = 'UPDATE ';
$queryComment = $this->getComment();
Expand Down Expand Up @@ -2655,9 +2658,7 @@ public function doUpdate($updateValues, ConnectionInterface $con)

$stmt = null; // close
} catch (Exception $e) {
if ($stmt !== null) {
$stmt = null; // close
}
$stmt = null; // close
Propel::log($e->getMessage(), Propel::LOG_ERR);

throw new PropelException(sprintf('Unable to execute UPDATE statement [%s]', $sql), 0, $e);
Expand Down Expand Up @@ -2808,6 +2809,7 @@ public function doDelete(?ConnectionInterface $con = null)
$whereClause = [];
$params = [];
$stmt = null;
$sql = null;
try {
$sql = $adapter->getDeleteFromClause($this, $tableName);

Expand Down
23 changes: 5 additions & 18 deletions src/Propel/Runtime/ActiveQuery/ModelCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public function join($relation, $joinType = Criteria::INNER_JOIN)
$tableMap = $this->getTableMap();
} else {
[$leftName, $relationName] = explode('.', $fullName);
$shortLeftName = self::getShortName($leftName);
$shortLeftName = static::getShortName($leftName);
// find the TableMap for the left table using the $leftName
if ($leftName === $this->getModelAliasOrName() || $leftName === $this->getModelShortName()) {
$previousJoin = $this->getPreviousJoin();
Expand Down Expand Up @@ -1725,9 +1725,10 @@ public function doDeleteAll(?ConnectionInterface $con = null)

$affectedRows = 0; // initialize this in case the next loop has no iterations.

$tableName = $this->quoteIdentifierTable($tableName);
$sql = 'DELETE FROM ' . $tableName;

try {
$tableName = $this->quoteIdentifierTable($tableName);
$sql = 'DELETE FROM ' . $tableName;
$stmt = $con->prepare($sql);

$stmt->execute();
Expand Down Expand Up @@ -2061,7 +2062,7 @@ protected function getColumnFromName($phpName, $failSilently = true)
[$prefix, $phpName] = explode('.', $phpName);
}

$shortClass = self::getShortName($prefix);
$shortClass = static::getShortName($prefix);

if ($prefix === $this->getModelAliasOrName()) {
// column of the Criteria's model
Expand Down Expand Up @@ -2264,20 +2265,6 @@ public function getAliasedColName($colName)
return $colName;
}

/**
* Return the short ClassName for class with namespace
*
* @param string $fullyQualifiedClassName The fully qualified class name
*
* @return string The short class name
*/
public static function getShortName($fullyQualifiedClassName)
{
$namespaceParts = explode('\\', $fullyQualifiedClassName);

return array_pop($namespaceParts);
}

/**
* Overrides Criteria::add() to force the use of a true table alias if it exists
*
Expand Down

0 comments on commit 5d34063

Please sign in to comment.