Skip to content

Commit

Permalink
Merge pull request propelorm#1810 from propelorm/bugfix/cleanup
Browse files Browse the repository at this point in the history
Fix some code smells reported by PHPStorm.
  • Loading branch information
dereuromark authored Dec 7, 2021
2 parents 7f5c1a3 + fd1eb6c commit 4f4ef1b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 23 deletions.
27 changes: 21 additions & 6 deletions phpstan-baseline.neon

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

1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ parameters:
- '%rootDir%/../../../src/Propel/Generator/Command/InitCommand.php'
ignoreErrors:
- '#Call to an undefined method .+Collection::.+Array\(\)#'
- '#Return type \(void\) of method .+CollectionIterator::.+\(\) should be compatible with return type \(bool\) of method ArrayIterator<\(int\|string\),mixed>::.+\(\)#'
-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#"
path: src/Propel/Common/Config/PropelConfiguration.php
13 changes: 9 additions & 4 deletions src/Propel/Generator/Builder/DataModelBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Propel\Generator\Builder;

use BadMethodCallException;
use Propel\Generator\Config\GeneratorConfigInterface;
use Propel\Generator\Model\Inheritance;
use Propel\Generator\Model\Table;
Expand Down Expand Up @@ -443,10 +444,16 @@ public function setTable(Table $table)
/**
* Returns the current Table object.
*
* @throws \BadMethodCallException
*
* @return \Propel\Generator\Model\Table
*/
public function getTable()
{
if ($this->table === null) {
throw new BadMethodCallException('No $table set to return.');
}

return $this->table;
}

Expand All @@ -459,7 +466,7 @@ public function getPlatform()
{
if ($this->platform === null) {
// try to load the platform from the table
$table = $this->getTable();
$table = $this->table;
if ($table && $database = $table->getDatabase()) {
$this->setPlatform($database->getPlatform());
}
Expand Down Expand Up @@ -507,9 +514,7 @@ public function quoteIdentifier($text)
*/
public function getDatabase()
{
if ($this->getTable()) {
return $this->getTable()->getDatabase();
}
return $this->getTable()->getDatabase();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Propel/Runtime/ActiveQuery/InstancePoolTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function addInstanceToPool($object, $key = null)
/**
* @param mixed $value
*
* @return string
* @return string|null
*/
public static function getInstanceKey($value)
{
Expand All @@ -61,6 +61,8 @@ public static function getInstanceKey($value)
// assume we've been passed a primary key
return (string)$value;
}

return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Runtime/Collection/OnDemandCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class OnDemandCollection extends Collection
{
/**
* @var \Iterator
* @var \Propel\Runtime\Collection\OnDemandIterator
*/
private $lastIterator;

Expand Down
6 changes: 0 additions & 6 deletions tests/Propel/Tests/Generator/Command/InitCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ class InitCommandTest extends TestCaseFixtures
*/
private $dir;

/**
* @var string
*/
private $currentDir;

/**
* @return void
*/
Expand All @@ -48,7 +43,6 @@ public function setUp(): void
}
$filesystem->mkdir($this->dir);

$this->currentDir = getcwd();
chdir($this->dir);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ protected function setUp(): void
$currentDriverName = $this->con->getAttribute(PDO::ATTR_DRIVER_NAME);
if ($currentDriverName !== $expectedDriverName) {
$this->markTestSkipped("This test is designed for $expectedDriverName and cannot be run with $currentDriverName");

return;
}

if ($this->parser === null) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Propel/Tests/Runtime/Util/PropelDateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function provideValidNewInstanceValues()
'unix_timestamp' => ['1312960848', '2011-08-10 07:20:48'],
'Y-m-d H:is' => ['2011-08-10 10:22:15', '2011-08-10 10:22:15'],
'Ymd' => ['20110810', '2011-08-10 00:00:00'],
'Ymd' => ['20110720', '2011-07-20 00:00:00'],
'Ymd2' => ['20110720', '2011-07-20 00:00:00'],
'datetime_object' => [new DateTime('2011-08-10 10:23:10'), '2011-08-10 10:23:10'],
'datetimeimmutable_object' => [new DateTimeImmutable('2011-08-10 10:23:10'), '2011-08-10 10:23:10'],
];
Expand All @@ -224,7 +224,7 @@ public function provideValidNewInstanceValuesGmt1()
'unix_timestamp' => ['1312960848', '2011-08-10 09:20:48'],
// "1323517115" : Sat, 10 Dec 2011 11:38:35 GMT
// "2011-12-10 12:38:35" : GMT +1
'unix_timestamp' => ['1323517115', '2011-12-10 12:38:35'],
'unix_timestamp2' => ['1323517115', '2011-12-10 12:38:35'],
];
}

Expand Down

0 comments on commit 4f4ef1b

Please sign in to comment.