Skip to content

Commit 0bc844f

Browse files
committed
PHP 8.4: fix deprecation notice
1 parent bbb64a8 commit 0bc844f

File tree

9 files changed

+30
-25
lines changed

9 files changed

+30
-25
lines changed

src/Propel/Generator/Behavior/AggregateColumn/AggregateColumnRelationBehavior.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function objectFilter(string &$script, AbstractOMBuilder $builder): void
111111
$relationName = $this->getRelationName($builder);
112112
$aggregateName = $this->getParameter('aggregate_name');
113113
$relatedClass = $builder->getClassNameFromBuilder($builder->getNewStubObjectBuilder($this->getForeignTable()));
114-
$search = " public function set{$relationName}({$relatedClass} \$v = null)
114+
$search = " public function set{$relationName}(?{$relatedClass} \$v = null)
115115
{";
116116
$replace = $search . "
117117
// aggregate_column_relation behavior

src/Propel/Generator/Behavior/Delegate/DelegateBehavior.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function queryMethods(QueryBuilder $builder): string
342342
*
343343
* @return \$this The current object, for fluid interface
344344
*/
345-
public function filterBy(string \$column, \$value, string \$comparison = null)
345+
public function filterBy(string \$column, \$value, ?string \$comparison = null)
346346
{
347347
if (isset(\$this->delegatedFields[\$column])) {
348348
\$methodUse = \"use{\$this->delegatedFields[\$column]}Query\";

src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorObjectBuilderModifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ protected function addSetParent(string &$script): void
643643
* @param $objectClassName \$parent
644644
* @return \$this The current object, for fluid interface
645645
*/
646-
public function setParent($objectClassName \$parent = null)
646+
public function setParent(?$objectClassName \$parent = null)
647647
{
648648
\$this->aNestedSetParent = \$parent;
649649

src/Propel/Generator/Behavior/NestedSet/NestedSetBehaviorQueryBuilderModifier.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ protected function addFindRoot(string &$script): void
464464
*
465465
* @return {$this->objectClassName} The tree root object
466466
*/
467-
public function findRoot(" . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null)
467+
public function findRoot(" . ($useScope ? '$scope = null, ' : '') . "?ConnectionInterface \$con = null)
468468
{
469469
return \$this
470470
->addUsingAlias({$this->objectClassName}::LEFT_COL, 1, Criteria::EQUAL)";
@@ -524,7 +524,7 @@ protected function addFindTree(string &$script): void
524524
*
525525
* @return {$this->objectClassName}[]|ObjectCollection|mixed the list of results, formatted by the current formatter
526526
*/
527-
public function findTree(" . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null)
527+
public function findTree(" . ($useScope ? '$scope = null, ' : '') . "?ConnectionInterface \$con = null)
528528
{
529529
return \$this";
530530
if ($useScope) {
@@ -593,7 +593,7 @@ protected function addRetrieveRoot(string &$script): void
593593
* @param ConnectionInterface \$con Connection to use.
594594
* @return {$this->objectClassName} Propel object for root node
595595
*/
596-
static public function retrieveRoot(" . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null)
596+
static public function retrieveRoot(" . ($useScope ? '$scope = null, ' : '') . "?ConnectionInterface \$con = null)
597597
{
598598
\$c = new Criteria($tableMapClassName::DATABASE_NAME);
599599
\$c->add($objectClassName::LEFT_COL, 1, Criteria::EQUAL);";
@@ -633,7 +633,7 @@ protected function addRetrieveTree(string &$script): void
633633
* @param ConnectionInterface \$con Connection to use.
634634
* @return {$this->objectClassName}[]|ObjectCollection|mixed the list of results, formatted by the current formatter
635635
*/
636-
static public function retrieveTree(" . ($useScope ? '$scope = null, ' : '') . "Criteria \$criteria = null, ?ConnectionInterface \$con = null)
636+
static public function retrieveTree(" . ($useScope ? '$scope = null, ' : '') . "?Criteria \$criteria = null, ?ConnectionInterface \$con = null)
637637
{
638638
if (null === \$criteria) {
639639
\$criteria = new Criteria($tableMapClassName::DATABASE_NAME);
@@ -666,7 +666,7 @@ protected function addIsValid(string &$script): void
666666
* @param $objectClassName \$node Propel object for src node
667667
* @return bool
668668
*/
669-
static public function isValid($objectClassName \$node = null)
669+
static public function isValid(?$objectClassName \$node = null)
670670
{
671671
if (is_object(\$node) && \$node->getRightValue() > \$node->getLeftValue()) {
672672
return true;
@@ -701,7 +701,7 @@ protected function addDeleteTree(string &$script): void
701701
*
702702
* @return int The number of deleted nodes
703703
*/
704-
static public function deleteTree(" . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null)
704+
static public function deleteTree(" . ($useScope ? '$scope = null, ' : '') . "?ConnectionInterface \$con = null)
705705
{";
706706
if ($useScope) {
707707
$script .= "

src/Propel/Generator/Behavior/Sortable/SortableBehaviorQueryBuilderModifier.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ protected function addGetMaxRankArray(string &$script): void
445445
*
446446
* @return int|null Highest position
447447
*/
448-
public function getMaxRankArray(" . ($useScope ? '$scope, ' : '') . "ConnectionInterface \$con = null): ?int
448+
public function getMaxRankArray(" . ($useScope ? '$scope, ' : '') . "?ConnectionInterface \$con = null): ?int
449449
{
450450
if (\$con === null) {
451451
\$con = Propel::getConnection({$this->tableMapClassName}::DATABASE_NAME);
@@ -529,7 +529,7 @@ protected function addRetrieveByRank(string &$script): void
529529
*
530530
* @return {$this->objectClassName}
531531
*/
532-
static public function retrieveByRank(\$rank, " . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null)
532+
static public function retrieveByRank(\$rank, " . ($useScope ? '$scope = null, ' : '') . "?ConnectionInterface \$con = null)
533533
{
534534
if (null === \$con) {
535535
\$con = Propel::getServiceContainer()->getReadConnection({$this->tableMapClassName}::DATABASE_NAME);
@@ -693,7 +693,7 @@ protected function addShiftRank(string &$script): void
693693
$script .= "
694694
* @param ConnectionInterface \$con Connection to use.
695695
*/
696-
static public function sortableShiftRank(\$delta, \$first, \$last = null, " . ($useScope ? '$scope = null, ' : '') . "ConnectionInterface \$con = null)
696+
static public function sortableShiftRank(\$delta, \$first, \$last = null, " . ($useScope ? '$scope = null, ' : '') . "?ConnectionInterface \$con = null)
697697
{
698698
if (null === \$con) {
699699
\$con = Propel::getServiceContainer()->getWriteConnection({$this->tableMapClassName}::DATABASE_NAME);

src/Propel/Generator/Builder/Om/AbstractOMBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,11 @@ protected function getCrossFKAddMethodInformation(CrossForeignKeys $crossFKs, $c
806806
if ($crossFK instanceof ForeignKey) {
807807
$crossObjectName = '$' . lcfirst($this->getFKPhpNameAffix($crossFK));
808808
$crossObjectClassName = $this->getClassNameFromTable($crossFK->getForeignTableOrFail());
809-
$signature[] = "$crossObjectClassName $crossObjectName" . ($crossFK->isAtLeastOneLocalColumnRequired() ? '' : ' = null');
809+
if ($crossFK->isAtLeastOneLocalColumnRequired()) {
810+
$signature[] = "$crossObjectClassName $crossObjectName";
811+
} else {
812+
$signature[] = "?$crossObjectClassName $crossObjectName = null";
813+
}
810814
$shortSignature[] = $crossObjectName;
811815
$normalizedShortSignature[] = $crossObjectName;
812816
$phpDoc[] = "

src/Propel/Generator/Builder/Om/ObjectBuilder.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ public function addJsonAccessorOpen(string &$script, Column $column): void
11601160
$script .= "
11611161
" . $visibility . " function get$cfc(\$asArray = true";
11621162
if ($column->isLazyLoad()) {
1163-
$script .= ', ConnectionInterface $con = null';
1163+
$script .= ', ?ConnectionInterface $con = null';
11641164
}
11651165

11661166
$script .= ")
@@ -1278,7 +1278,7 @@ public function addBooleanAccessorOpen(string &$script, Column $column): void
12781278
$script .= "
12791279
" . $visibility . " function $name(";
12801280
if ($column->isLazyLoad()) {
1281-
$script .= 'ConnectionInterface $con = null';
1281+
$script .= '?ConnectionInterface $con = null';
12821282
}
12831283

12841284
$script .= ")
@@ -1483,7 +1483,7 @@ protected function addHasArrayElement(string &$script, Column $column): void
14831483
*/
14841484
$visibility function has$singularPhpName(\$value";
14851485
if ($column->isLazyLoad()) {
1486-
$script .= ', ConnectionInterface $con = null';
1486+
$script .= ', ?ConnectionInterface $con = null';
14871487
}
14881488

14891489
$script .= "): bool
@@ -1557,7 +1557,7 @@ public function addDefaultAccessorOpen(string &$script, Column $column): void
15571557
$script .= "
15581558
" . $visibility . " function get$cfc(";
15591559
if ($column->isLazyLoad()) {
1560-
$script .= 'ConnectionInterface $con = null';
1560+
$script .= '?ConnectionInterface $con = null';
15611561
}
15621562

15631563
$script .= ")
@@ -1852,6 +1852,7 @@ public function addMutatorOpenOpen(string &$script, Column $column): void
18521852
$typeHint .= ' ';
18531853

18541854
if (!$column->isNotNull()) {
1855+
$typeHint = '?' . $typeHint;
18551856
$null = ' = null';
18561857
}
18571858
}
@@ -2206,7 +2207,7 @@ protected function addAddArrayElement(string &$script, Column $col): void
22062207
*/
22072208
$visibility function add$singularPhpName(\$value";
22082209
if ($col->isLazyLoad()) {
2209-
$script .= ', ConnectionInterface $con = null';
2210+
$script .= ', ?ConnectionInterface $con = null';
22102211
}
22112212

22122213
$script .= ")
@@ -2254,7 +2255,7 @@ protected function addRemoveArrayElement(string &$script, Column $col): void
22542255
*/
22552256
$visibility function remove$singularPhpName(\$value";
22562257
if ($col->isLazyLoad()) {
2257-
$script .= ', ConnectionInterface $con = null';
2258+
$script .= ', ?ConnectionInterface $con = null';
22582259
}
22592260
// we want to reindex the array, so array_ functions are not the best choice
22602261
$script .= ")
@@ -4141,7 +4142,7 @@ protected function addFKMutator(string &$script, ForeignKey $fk): void
41414142
* @return \$this The current object (for fluent API support)
41424143
* @throws \Propel\Runtime\Exception\PropelException
41434144
*/
4144-
public function set" . $this->getFKPhpNameAffix($fk, false) . "($className \$v = null)
4145+
public function set" . $this->getFKPhpNameAffix($fk, false) . "(?$className \$v = null)
41454146
{";
41464147

41474148
foreach ($fk->getMapping() as $map) {
@@ -4958,11 +4959,11 @@ protected function addPKRefFKSet(string &$script, ForeignKey $refFK): void
49584959
/**
49594960
* Sets a single $className object as related to this object by a one-to-one relationship.
49604961
*
4961-
* @param $className \$v $className
4962+
* @param $className|null \$v $className
49624963
* @return \$this The current object (for fluent API support)
49634964
* @throws \Propel\Runtime\Exception\PropelException
49644965
*/
4965-
public function set" . $this->getRefFKPhpNameAffix($refFK, false) . "($className \$v = null)
4966+
public function set" . $this->getRefFKPhpNameAffix($refFK, false) . "(?$className \$v = null)
49664967
{
49674968
\$this->$varName = \$v;
49684969

src/Propel/Generator/Builder/Om/QueryBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ protected function addWithRelatedQuery(string &$script, Table $fkTable, string $
16721672
*/
16731673
public function with{$relationName}Query(
16741674
callable \$callable,
1675-
string \$relationAlias = null,
1675+
?string \$relationAlias = null,
16761676
?string \$joinType = {$joinType}
16771677
) {
16781678
\$relatedQuery = \$this->use{$relationName}Query(
@@ -1714,7 +1714,7 @@ protected function addFilterByCrossFK(string &$script, CrossForeignKeys $crossFK
17141714
*
17151715
* @return \$this The current query, for fluid interface
17161716
*/
1717-
public function filterBy{$relName}($objectName, string \$comparison = null)
1717+
public function filterBy{$relName}($objectName, ?string \$comparison = null)
17181718
{
17191719
\$this
17201720
->use{$relationName}Query()

templates/Behavior/Validate/objectValidate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @param ValidatorInterface|null $validator A Validator class instance
77
* @return bool Whether all objects pass validation.
88
*/
9-
public function validate(ValidatorInterface $validator = null)
9+
public function validate(?ValidatorInterface $validator = null)
1010
{
1111
if (null === $validator) {
1212
$validator = new RecursiveValidator(

0 commit comments

Comments
 (0)