Skip to content

Commit

Permalink
Remove more CS issues and fix stan baseline.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Aug 6, 2020
1 parent 3cc71ba commit 1b0e50a
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 33 deletions.
18 changes: 4 additions & 14 deletions phpstan-baseline.neon

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

2 changes: 1 addition & 1 deletion src/Propel/Runtime/ActiveQuery/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ public function equals($crit)
}

$joins = $criteria->getJoins();
if (count($joins) != count($this->joins)) {
if (count($joins) !== count($this->joins)) {
return false;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Propel/Runtime/ActiveQuery/Criterion/BasicCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ protected function appendPsForUniqueClauseTo(&$sb, array &$params)
// default case, it is a normal col = value expression; value
// will be replaced w/ '?' and will be inserted later using PDO bindValue()
if ($this->ignoreStringCase) {
$sb .= $this->getAdapter()->ignoreCase($field) . $this->comparison . $this->getAdapter()->ignoreCase(':p' . count($params));
/** @var \Propel\Runtime\Adapter\SqlAdapterInterface $sqlAdapter */
$sqlAdapter = $this->getAdapter();
$sb .= $sqlAdapter->ignoreCase($field) . $this->comparison . $sqlAdapter->ignoreCase(':p' . count($params));
} else {
$sb .= $field . $this->comparison . ':p' . count($params);
}
Expand Down
9 changes: 7 additions & 2 deletions src/Propel/Runtime/ActiveQuery/ModelCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,12 @@ public function with($relation)
throw new UnknownRelationException('Unknown relation name or alias ' . $relation);
}

/** @var \Propel\Runtime\ActiveQuery\ModelJoin $join */
$join = $this->joins[$relation];
if ($join->getRelationMap()->getType() === RelationMap::MANY_TO_MANY) {
throw new PropelException(__METHOD__ . ' does not allow hydration for many-to-many relationships');
} elseif ($join->getRelationMap()->getType() === RelationMap::ONE_TO_MANY) {
}
if ($join->getRelationMap()->getType() === RelationMap::ONE_TO_MANY) {
// For performance reasons, the formatters will use a special routine in this case
$this->isWithOneToMany = true;
}
Expand Down Expand Up @@ -789,7 +791,9 @@ public function useQuery($relationName, $secondaryCriteriaClass = null)
throw new PropelException('Unknown class or alias ' . $relationName);
}

$className = $this->joins[$relationName]->getTableMap()->getClassName();
/** @var \Propel\Runtime\ActiveQuery\ModelJoin $modelJoin */
$modelJoin = $this->joins[$relationName];
$className = $modelJoin->getTableMap()->getClassName();
/** @var self $secondaryCriteriaClass */
if ($secondaryCriteriaClass === null) {
$secondaryCriteria = PropelQuery::from($className);
Expand Down Expand Up @@ -953,6 +957,7 @@ public function addSelfSelectColumns($force = false)
*/
public function addRelationSelectColumns($relation)
{
/** @var \Propel\Runtime\ActiveQuery\ModelJoin $join */
$join = $this->joins[$relation];
$join->getTableMap()->addSelectColumns($this, $join->getRelationAlias());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
*/
class ArchivableBehaviorTest extends TestCase
{
/**
* @var string
*/
protected static $generatedSQL;

/**
Expand Down Expand Up @@ -324,7 +327,7 @@ public function testGeneratedClassesWithTablePrefix($schema, $expectSQL, $expect
$builder->buildClasses();

foreach ($expectClasses as $expectClass) {
$this->assertTrue(class_exists($expectClass), sprintf('expect class "%s" is not exists', $expectClass));
$this->assertTrue(class_exists($expectClass), sprintf('expected class "%s" not exists', $expectClass));
}
}
}
24 changes: 23 additions & 1 deletion tests/Propel/Tests/Generator/Behavior/Archivable/FooArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@

class FooArchive
{
public $id, $title, $age;
/**
* @var mixed
*/
public $id;

/**
* @var mixed
*/
public $title;

/**
* @var mixed
*/
public $age;

/**
* @param mixed $value
*
* @return void
*/
public function setId($value)
Expand All @@ -21,6 +36,8 @@ public function setId($value)
}

/**
* @param mixed $value
*
* @return void
*/
public function setTitle($value)
Expand All @@ -29,13 +46,18 @@ public function setTitle($value)
}

/**
* @param mixed $value
*
* @return void
*/
public function setAge($value)
{
$this->age = $value;
}

/**
* @return $this
*/
public function save()
{
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@

class FooArchiveCollection
{
/**
* @var \Propel\Tests\Generator\Behavior\Archivable\FooArchive
*/
protected static $instance;

/**
* @return \Propel\Tests\Generator\Behavior\Archivable\FooArchive
*/
public static function getArchiveSingleton()
{
if (null === self::$instance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,34 @@

class FooArchiveQuery
{
/**
* @var mixed
*/
protected $pk;

/**
* @return \Propel\Tests\Generator\Behavior\Archivable\FooArchiveQuery
*/
public static function create()
{
return new self();
}

/**
* @param mixed $pk
*
* @return $this
*/
public function filterByPrimaryKey($pk)
{
$this->pk = $pk;

return $this;
}

/**
* @return \Propel\Tests\Generator\Behavior\Archivable\FooArchive
*/
public function findOne()
{
$archive = FooArchiveCollection::getArchiveSingleton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@

class ModelCriteriaForUseQuery extends ModelCriteria
{
/**
* @param string $dbName
* @param string $modelName
* @param string|null $modelAlias
*/
public function __construct($dbName = 'bookstore', $modelName = 'Propel\Tests\Bookstore\Author', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}

/**
* @return \Propel\Tests\Runtime\ActiveQuery\ModelCriteriaForUseQuery
*/
public function withNoName()
{
return $this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ModelCriteriaGroupByArrayTest extends BookstoreEmptyTestBase
*
* @expectedException \Propel\Runtime\Exception\PropelException
*
* @param mixed $groupBy
*
* @return void
*/
public function testGroupByArrayThrowException($groupBy)
Expand All @@ -35,7 +37,7 @@ public function testGroupByArrayThrowException($groupBy)
->orderByLastName()
->find();
}

/**
* @return void
*/
Expand All @@ -50,13 +52,13 @@ public function testGroupByArray()
$byron->setFirstName('George');
$byron->setLastName('Byron');
$byron->save();

$phoenix = new Book();
$phoenix->setTitle('Harry Potter and the Order of the Phoenix');
$phoenix->setISBN('043935806X');
$phoenix->setAuthor($stephenson);
$phoenix->save();

$qs = new Book();
$qs->setISBN('0380977427');
$qs->setTitle('Quicksilver');
Expand All @@ -74,28 +76,31 @@ public function testGroupByArray()
$td->setTitle('The Tin Drum');
$td->setAuthor($byron);
$td->save();

$authors = AuthorQuery::create()
->leftJoinBook()
->select(['FirstName', 'LastName'])
->withColumn('COUNT(Book.Id)', 'nbBooks')
->groupBy(['FirstName', 'LastName'])
->orderByLastName()
->find();

$expectedSql = 'SELECT COUNT(book.id) AS nbBooks, author.first_name AS "FirstName", author.last_name AS "LastName" FROM author LEFT JOIN book ON (author.id=book.author_id) GROUP BY author.first_name,author.last_name ORDER BY author.last_name ASC';

$this->assertEquals($expectedSql, $this->con->getLastExecutedQuery());

$this->assertEquals(2, count($authors));

$this->assertEquals('George', $authors[0]['FirstName']);
$this->assertEquals(1, $authors[0]['nbBooks']);

$this->assertEquals('Neal', $authors[1]['FirstName']);
$this->assertEquals(3, $authors[1]['nbBooks']);
}


/**
* @return array
*/
public function dataForTestException()
{
return [
Expand Down
2 changes: 1 addition & 1 deletion tests/Propel/Tests/Runtime/ActiveQuery/PropelQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testFrom()
$this->assertEquals($expected, $q, 'from() sets the model alias if found after the blank');

$q = PropelQuery::from('\Propel\Tests\Runtime\ActiveQuery\myBook');
$expected = new myBookQuery();
$expected = new MyBookQuery();
$this->assertEquals($expected, $q, 'from() can find custom query classes');

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

use Propel\Tests\Bookstore\BookQuery;

class myBookQuery extends BookQuery
class MyBookQuery extends BookQuery
{
}
5 changes: 5 additions & 0 deletions tests/Propel/Tests/Runtime/ActiveQuery/SubQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ protected function setUp(): void
}

/**
* @param \Propel\Runtime\ActiveQuery\Criteria $criteria
* @param mixed $expectedSql
* @param mixed $expectedParams
* @param string $message
*
* @return void
*/
protected function assertCriteriaTranslation($criteria, $expectedSql, $expectedParams, $message = '')
Expand Down
3 changes: 3 additions & 0 deletions tests/Propel/Tests/Runtime/Map/GeneratedRelationMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
*/
class GeneratedRelationMapTest extends TestCaseFixtures
{
/**
* @var \Propel\Runtime\Map\DatabaseMap
*/
protected $databaseMap;

/**
Expand Down
15 changes: 14 additions & 1 deletion tests/Propel/Tests/Runtime/Map/RelationMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@
*/
class RelationMapTest extends TestCase
{
protected $databaseMap, $relationName, $rmap;
/**
* @var \Propel\Runtime\Map\DatabaseMap
*/
protected $databaseMap;

/**
* @var string
*/
protected $relationName;

/**
* @var \Propel\Runtime\Map\RelationMap
*/
protected $rmap;

/**
* @return void
Expand Down

0 comments on commit 1b0e50a

Please sign in to comment.