Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<exclude name="Spryker.Internal.SprykerNoDemoshop"/>
<exclude name="Spryker.Internal.SprykerPreferStaticOverSelf"/>
<exclude name="Spryker.Commenting.DocBlockApiAnnotation"/> <!-- Another Spryker internal function. -->
<exclude name="Spryker.Commenting.DocBlockReturnSelf.InvalidChainable"/> <!-- methods with "@return $this" must end with "return $this", but cannot return $this through another method -->
<exclude name="Spryker.Commenting.DocBlockParamAllowDefaultValue.Typehint"/> <!-- fails to recognize array shapes (like `array{int, string})`-->
</rule>

<rule ref="Spryker.Internal.SprykerDisallowFunctions">
Expand Down
24 changes: 12 additions & 12 deletions src/Propel/Generator/Builder/Om/ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2086,11 +2086,11 @@ protected function addSetPrimaryKeySinglePK(string &$script): void
*
* @param $ctype|null \$key Primary key.
*
* @return void
* @return \$this
*/
public function setPrimaryKey(?$ctype \$key = null): void
public function setPrimaryKey(?$ctype \$key = null)
{
\$this->set{$phpName}(\$key);
return \$this->set{$phpName}(\$key);
}\n";
}

Expand All @@ -2103,25 +2103,25 @@ public function setPrimaryKey(?$ctype \$key = null): void
*/
protected function addSetPrimaryKeyMultiPK(string &$script): void
{
$docType = $this->getTable()->getPrimaryKeyDocType(false);
$script .= "
/**
* Set the [composite] primary key.
*
* @param array \$keys The elements of the composite key (order must match the order in XML file).
* @param $docType \$keys The elements of the composite key (order must match the order in XML file).
*
* @return void
* @return \$this
*/
public function setPrimaryKey(array \$keys): void
{";
$i = 0;
public function setPrimaryKey(array \$keys)
{
return \$this";
foreach ($this->getTable()->getPrimaryKey() as $i => $pk) {
$phpName = $pk->getPhpName();
$script .= "
\$this->set{$phpName}(\$keys[$i]);";
->set{$phpName}(\$keys[$i])";
}
$script .= "
}
";
$script .= ";
}\n";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Runtime/ActiveQuery/BaseModelCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function setWith(array $with)
*
* @throws \Propel\Runtime\Exception\InvalidArgumentException
*
* @return static
* @return $this
*/
public function setFormatter($formatter)
{
Expand Down
30 changes: 15 additions & 15 deletions src/Propel/Runtime/ActiveQuery/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ public function getUpdateValue(string $name)
* @param mixed $value
* @param string|int|null $comparison A String.
*
* @return static A modified Criteria object.
* @return $this
*/
public function add($columnOrClause, $value = null, $comparison = null)
{
Expand Down Expand Up @@ -841,7 +841,7 @@ public function addFilter($columnOrClause, $value = null, $comparison = null)
* @param mixed $value
* @param int|null $pdoType
*
* @return static
* @return $this
*/
public function setUpdateValue($columnIdentifierOrMap, $value, $pdoType = null)
{
Expand Down Expand Up @@ -872,7 +872,7 @@ public function setUpdateValue($columnIdentifierOrMap, $value, $pdoType = null)
* @param mixed $values Must match number of placeholders (`?`) in $expression.
* @param mixed $pdoTypes Must match number of values. If null, resolved ColumnMap will be used to determine type (and possibly unwrap value).
*
* @return static
* @return $this
*/
public function setUpdateExpression($columnIdentifierOrMap, string $expression, $values = null, $pdoTypes = null)
{
Expand Down Expand Up @@ -906,7 +906,7 @@ public function __toString(): string
*
* @throws \Propel\Runtime\Exception\PropelException
*
* @return static A modified Criteria object.
* @return $this
*/
public function addJoin($left, $right, ?string $joinType = null)
{
Expand Down Expand Up @@ -1124,7 +1124,7 @@ public function setDistinct()
* Adds a DISTINCT clause to the query
* Alias for Criteria::setDistinct()
*
* @return static
* @return $this
*/
public function distinct()
{
Expand Down Expand Up @@ -1289,7 +1289,7 @@ public function setLimit(int $limit)
*
* @param string|int $limit Maximum number of results to return by the query
*
* @return static
* @return $this
*/
public function limit($limit)
{
Expand Down Expand Up @@ -1326,7 +1326,7 @@ public function setOffset(int $offset)
*
* @param string|int $offset Offset of the first result to return
*
* @return static
* @return $this
*/
public function offset($offset)
{
Expand Down Expand Up @@ -1783,7 +1783,7 @@ public function mergeWith(Criteria $criteria, ?string $operator = null)
*
* @throws \Propel\Runtime\Exception\PropelException
*
* @return $this A modified Criteria object.
* @return $this
*/
public function addHaving($columnOrClause, $value = null, $comparison = null, ?int $pdoType = null)
{
Expand Down Expand Up @@ -1877,7 +1877,7 @@ protected function buildFilterForClause(string $clause, $value, ?int $bindingTyp
* @param mixed|null $condition
* @param bool $preferColumnCondition
*
* @return static A modified Criteria object.
* @return $this
*/
public function addAnd($columnOrClause, $value = null, $condition = null, bool $preferColumnCondition = true)
{
Expand All @@ -1900,7 +1900,7 @@ public function addAnd($columnOrClause, $value = null, $condition = null, bool $
* @param mixed $condition
* @param bool $preferColumnCondition
*
* @return static A modified Criteria object.
* @return $this
*/
public function addOr($columnOrClause, $value = null, $condition = null, bool $preferColumnCondition = true)
{
Expand All @@ -1914,7 +1914,7 @@ public function addOr($columnOrClause, $value = null, $condition = null, bool $p
* @param string|int|null $condition
* @param bool $preferColumnCondition
*
* @return static
* @return $this
*/
protected function addFilterWithConjunction(string $andOr, $columnOrClause, $value = null, $condition = null, bool $preferColumnCondition = true)
{
Expand All @@ -1931,7 +1931,7 @@ protected function addFilterWithConjunction(string $andOr, $columnOrClause, $val
*
* @param string|null $andOr Default Operator to combine filters.
*
* @return static
* @return $this
*/
public function combineFilters(?string $andOr = null)
{
Expand All @@ -1947,7 +1947,7 @@ public function combineFilters(?string $andOr = null)
*
* Call {@see static::combineFilters()} to open parentheses.
*
* @return static
* @return $this
*/
public function endCombineFilters()
{
Expand All @@ -1967,7 +1967,7 @@ public function endCombineFilters()
* (necessary for Propel 1.4 compatibility).
* If false, the condition is combined with the last existing condition.
*
* @return static A modified Criteria object.
* @return $this
*/
public function addUsingOperator($columnOrClause, $value = null, ?string $operator = null, bool $preferColumnCondition = true)
{
Expand Down Expand Up @@ -2416,7 +2416,7 @@ public function setIdentifierQuoting(bool $identifierQuoting)
*
* @param bool $doAutoAdd
*
* @return static
* @return $this
*/
public function setAutoAddTable(bool $doAutoAdd)
{
Expand Down
14 changes: 5 additions & 9 deletions src/Propel/Runtime/ActiveQuery/FilterExpression/ClauseList.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class ClauseList
*
* @var array<int, \Propel\Runtime\ActiveQuery\FilterExpression\ColumnFilterInterface>
*/
protected $clauses = [];
protected array $clauses = [];

/**
* Operators for connected filters
* Only self::UND and self::ODER are accepted
*
* @var array<int, string>
*/
protected $conjunctions = [];
protected array $conjunctions = [];

/**
* Get the list of clauses in this Filter.
Expand Down Expand Up @@ -63,7 +63,7 @@ public function getConjunctions(): array
* @param \Propel\Runtime\ActiveQuery\FilterExpression\ColumnFilterInterface $filter
* @param string $conjunction
*
* @return static
* @return $this
*/
public function addFilter(ColumnFilterInterface $filter, string $conjunction = self::AND_OPERATOR_LITERAL)
{
Expand All @@ -82,9 +82,7 @@ public function addFilter(ColumnFilterInterface $filter, string $conjunction = s
*/
public function addAnd(ColumnFilterInterface $filter)
{
$this->addFilter($filter, self::AND_OPERATOR_LITERAL);

return $this;
return $this->addFilter($filter, self::AND_OPERATOR_LITERAL);
}

/**
Expand All @@ -96,9 +94,7 @@ public function addAnd(ColumnFilterInterface $filter)
*/
public function addOr(ColumnFilterInterface $filter)
{
$this->addFilter($filter, self::OR_OPERATOR_LITERAL);

return $this;
return $this->addFilter($filter, self::OR_OPERATOR_LITERAL);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ public function equals(ColumnFilterInterface $filter): bool;
* @param \Propel\Runtime\ActiveQuery\FilterExpression\ColumnFilterInterface $filter
* @param string $conjunction
*
* @return static
* @return $this
*/
public function addFilter(ColumnFilterInterface $filter, string $conjunction = ClauseList::AND_OPERATOR_LITERAL);

/**
* @param \Propel\Runtime\ActiveQuery\FilterExpression\ColumnFilterInterface $filter
*
* @return static
* @return $this
*/
public function addAnd(ColumnFilterInterface $filter);

/**
* @param \Propel\Runtime\ActiveQuery\FilterExpression\ColumnFilterInterface $filter
*
* @return static
* @return $this
*/
public function addOr(ColumnFilterInterface $filter);

Expand Down
30 changes: 14 additions & 16 deletions src/Propel/Runtime/ActiveQuery/ModelCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ModelCriteria extends BaseModelCriteria
* @param mixed $value A value for the condition
* @param string|null $comparison What to use for the column comparison, defaults to Criteria::EQUAL or Criteria::IN for subqueries
*
* @return static
* @return $this
*/
public function filterBy(string $columnPhpName, $value, ?string $comparison = null)
{
Expand Down Expand Up @@ -211,7 +211,7 @@ public function filterByArray($conditions)
* @param mixed $value A value for the condition
* @param int|null $bindingType
*
* @return static
* @return $this
*/
public function where($clause, $value = null, ?int $bindingType = null)
{
Expand Down Expand Up @@ -243,7 +243,7 @@ public function where($clause, $value = null, ?int $bindingType = null)
* @param \Propel\Runtime\ActiveQuery\ModelCriteria $existsQueryCriteria the query object used in the EXISTS statement
* @param string $operator Either ExistsQueryCriterion::TYPE_EXISTS or ExistsQueryCriterion::TYPE_NOT_EXISTS. Defaults to EXISTS
*
* @return static
* @return $this
*/
public function whereExists(ActiveQueryModelCriteria $existsQueryCriteria, string $operator = ExistsQueryCriterion::TYPE_EXISTS)
{
Expand All @@ -257,7 +257,7 @@ public function whereExists(ActiveQueryModelCriteria $existsQueryCriteria, strin
*
* @param \Propel\Runtime\ActiveQuery\ModelCriteria $existsQueryCriteria
*
* @return static
* @return $this
*/
public function whereNotExists(ActiveQueryModelCriteria $existsQueryCriteria)
{
Expand All @@ -283,7 +283,7 @@ public function whereNotExists(ActiveQueryModelCriteria $existsQueryCriteria)
* @param mixed $value A value for the condition
* @param int|null $bindingType
*
* @return static
* @return $this
*/
public function having($clause, $value = null, ?int $bindingType = null)
{
Expand Down Expand Up @@ -313,22 +313,20 @@ public function having($clause, $value = null, ?int $bindingType = null)
*
* @throws \Propel\Runtime\Exception\UnexpectedValueException
*
* @return static
* @return $this
*/
public function orderBy(string $columnName, string $order = Criteria::ASC)
{
$resolvedColumn = $this->columnResolver->resolveColumn($columnName, true, false);
$qualifiedColumnName = $resolvedColumn->getColumnExpressionInQuery();

$order = strtoupper($order);
switch ($order) {
case Criteria::ASC:
return $this->addAscendingOrderByColumn($qualifiedColumnName);
case Criteria::DESC:
return $this->addDescendingOrderByColumn($qualifiedColumnName);
default:
throw new UnexpectedValueException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument');
}

return match ($order) {
Criteria::ASC => $this->addAscendingOrderByColumn($qualifiedColumnName),
Criteria::DESC => $this->addDescendingOrderByColumn($qualifiedColumnName),
default => throw new UnexpectedValueException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument'),
};
}

/**
Expand Down Expand Up @@ -1026,7 +1024,7 @@ public function clear()
* @param \Propel\Runtime\ActiveQuery\ModelCriteria $criteria The primary criteria
* @param \Propel\Runtime\ActiveQuery\Join|null $previousJoin The previousJoin for this ModelCriteria
*
* @return static
* @return $this
*/
public function setPrimaryCriteria(ModelCriteria $criteria, ?Join $previousJoin)
{
Expand Down Expand Up @@ -1099,7 +1097,7 @@ public function addSubquery(Criteria $subQuery, ?string $alias = null, bool $add
* @param string|null $alias alias for the subQuery
* @param bool $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns
*
* @return static
* @return $this
*/
public function addSelectQuery(Criteria $subQueryCriteria, ?string $alias = null, bool $addAliasAndSelectColumns = true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,11 @@ abstract class IdTable implements ActiveRecordInterface
*
* @param int|null $key Primary key.
*
* @return void
* @return $this
*/
public function setPrimaryKey(?int $key = null): void
public function setPrimaryKey(?int $key = null)
{
$this->setId($key);
return $this->setId($key);
}

/**
Expand Down
Loading
Loading