Skip to content

Commit

Permalink
fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
smhg committed Dec 10, 2024
1 parent e129a04 commit ed0a54d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Propel\Generator\Behavior\Timestampable;

use Propel\Generator\Builder\Om\AbstractOMBuilder;
use Propel\Generator\Builder\Om\ObjectBuilder;
use Propel\Generator\Model\Behavior;

/**
Expand Down Expand Up @@ -102,7 +103,12 @@ public function preUpdate(AbstractOMBuilder $builder): string
{
if ($this->withUpdatedAt()) {
$updateColumn = $this->getTable()->getColumn($this->getParameter('update_column'));
$dateTimeClass = $builder->getDateTimeClass($updateColumn);

$dateTimeClass = 'DateTime';

if ($builder instanceof ObjectBuilder) {
$dateTimeClass = $builder->getDateTimeClass($updateColumn);
}

$valueSource = strtoupper($updateColumn->getType()) === 'INTEGER'
? 'time()'
Expand Down Expand Up @@ -130,7 +136,12 @@ public function preInsert(AbstractOMBuilder $builder): string

if ($this->withCreatedAt()) {
$createColumn = $this->getTable()->getColumn($this->getParameter('create_column'));
$dateTimeClass = $builder->getDateTimeClass($createColumn);

$dateTimeClass = 'DateTime';

if ($builder instanceof ObjectBuilder) {
$dateTimeClass = $builder->getDateTimeClass($createColumn);
}

$script .= "
\$highPrecisionCreate = PropelDateTime::createHighPrecision(\$mtime, '$dateTimeClass');";
Expand All @@ -146,7 +157,12 @@ public function preInsert(AbstractOMBuilder $builder): string

if ($this->withUpdatedAt()) {
$updateColumn = $this->getTable()->getColumn($this->getParameter('update_column'));
$dateTimeClass = $builder->getDateTimeClass($updateColumn);

$dateTimeClass = 'DateTime';

if ($builder instanceof ObjectBuilder) {
$dateTimeClass = $builder->getDateTimeClass($updateColumn);
}

$script .= "
\$highPrecisionUpdate = PropelDateTime::createHighPrecision(\$mtime, '$dateTimeClass');";
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Runtime/Util/PropelDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected static function isTimestamp($value): bool
*
* @throws \InvalidArgumentException
*
* @return mixed An instance of $dateTimeClass
* @return DateTimeInterface An instance of $dateTimeClass
*/
public static function createHighPrecision(?string $time = null, string $dateTimeClass = 'DateTime'): DateTimeInterface
{
Expand Down

0 comments on commit ed0a54d

Please sign in to comment.