Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Feb 25, 2014
1 parent 3db5195 commit 81a7125
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
10 changes: 4 additions & 6 deletions generator/lib/builder/om/PHP5ObjectBuilder.php
Expand Up @@ -1986,15 +1986,14 @@ protected function addDefaultMutator(&$script, Column $col)
// Perform type-casting to ensure that we can use type-sensitive
// checking in mutators.
if ($col->isPhpPrimitiveType()) {
if($col->isTextType()) {
if ($col->isTextType()) {
$script .= "
if (\$v !== null) {";
} else {
$script .= "
if (\$v !== null && is_numeric(\$v)) {";
if (\$v !== null && is_numeric(\$v)) {";
}



$script .= "
\$v = (" . $col->getPhpType() . ") \$v;
}
Expand Down Expand Up @@ -4644,8 +4643,7 @@ protected function doAdd{$relatedObjectClassName}({$relatedObjectName} \${$lower
{
// set the back reference to this object directly as using provided method either results
// in endless loop or in multiple relations
if (!\${$lowerRelatedObjectClassName}->get{$selfRelationNamePlural}()->contains(\$this)) {
{$foreignObjectName} = new {$className}();
if (!\${$lowerRelatedObjectClassName}->get{$selfRelationNamePlural}()->contains(\$this)) { {$foreignObjectName} = new {$className}();
{$foreignObjectName}->set{$relatedObjectClassName}(\${$lowerRelatedObjectClassName});
\$this->add{$refKObjectClassName}({$foreignObjectName});
Expand Down
5 changes: 4 additions & 1 deletion runtime/lib/om/BaseObject.php
Expand Up @@ -115,12 +115,13 @@ public function isNew()
* Setter for the isNew attribute. This method will be called
* by Propel-generated children and Peers.
*
* @param boolean $b the state of the object.
* @param boolean $b the state of the object.
* @return self
*/
public function setNew($b)
{
$this->_new = (boolean) $b;

return $this;
}

Expand All @@ -144,6 +145,7 @@ public function isDeleted()
public function setDeleted($b)
{
$this->_deleted = (boolean) $b;

return $this;
}

Expand Down Expand Up @@ -256,6 +258,7 @@ public function resetModified($col = null)
} else {
$this->modifiedColumns = array();
}

return $this;
}

Expand Down
30 changes: 15 additions & 15 deletions test/testsuite/generator/builder/om/GeneratedObjectTest.php
Expand Up @@ -100,44 +100,44 @@ public function testDefaultValues()
$acct->setPassword("testpass");
$this->assertTrue($acct->isModified());
}


public function testTypeHintingValues()
{
$test_name = 'test name';
$a = new Author();
$a2 = new Author();
$a2->setFirstName($test_name);


$a->setAge(2);
$this->assertEquals(2, $a->getAge());
$this->assertTrue(is_int($a->getAge()));


$a->clear();
$a->setAge('2');
$this->assertEquals(2, $a->getAge());
$this->assertTrue(is_int($a->getAge()));


$a->clear();
$a->setAge('wrong integer');
$this->assertTrue(!is_int($a->getAge()));


$a->clear();
$a->setFirstName($test_name);
$this->assertEquals($test_name, $a->getFirstName());
$this->assertTrue(is_string($a->getFirstName()));


$a->clear();
$a->setFirstName($a2);
$this->assertTrue(is_string($a->getFirstName()));
$this->assertEquals($a->getFirstName(), (string)$a2);
$this->assertEquals($a->getFirstName(), (string) $a2);


$a->clear();
$a->setFirstName(true);
$this->assertTrue(is_string($a->getFirstName()));
Expand Down
Expand Up @@ -80,7 +80,7 @@ public function testFormatOneWithOneRowAndValueBooleanEqualsFalse()

$book = $formatter->formatOne($stmt);
$this->assertNotNull($book);
$this->assertSame(false, (bool)$book);
$this->assertSame(false, (bool) $book);
}

public function testFormatWithOneRowAndValueBooleanEqualsFalse()
Expand All @@ -94,6 +94,6 @@ public function testFormatWithOneRowAndValueBooleanEqualsFalse()
$books = $formatter->format($stmt);
$this->assertInstanceOf('PropelCollection', $books);
$this->assertCount(4, $books);
$this->assertSame(false, (bool)$books[0]);
$this->assertSame(false, (bool) $books[0]);
}
}
6 changes: 3 additions & 3 deletions test/testsuite/runtime/om/BaseObjectTest.php
Expand Up @@ -60,21 +60,21 @@ public function testSetVirtualColumn()
$this->assertEquals('baz', $b->getVirtualColumn('foo'), 'setVirtualColumn() can modify the value of an existing virtual column');
$this->assertEquals($b, $b->setVirtualColumn('foo', 'bar'), 'setVirtualColumn() returns the current object');
}

public function testSetNewReturnsSelf()
{
$b = new TestableBaseObject();
$this->assertInstanceOf('TestableBaseObject', $b->setNew(false));
$this->assertInstanceOf('TestableBaseObject', $b->setNew(true));
}

public function testSetDeletedReturnsSelf()
{
$b = new TestableBaseObject();
$this->assertInstanceOf('TestableBaseObject', $b->setDeleted(false));
$this->assertInstanceOf('TestableBaseObject', $b->setDeleted(true));
}

public function testResetModifiedReturnsSelf()
{
$b = new TestableBaseObject();
Expand Down

0 comments on commit 81a7125

Please sign in to comment.