1
0
mirror of synced 2024-12-14 23:26:04 +03:00

fix CS and use php constants

This commit is contained in:
Fabio B. Silva 2011-12-24 11:45:51 -02:00
parent 8bdb713073
commit 1eddb53d6c
6 changed files with 51 additions and 49 deletions

View File

@ -23,6 +23,7 @@ use ReflectionClass, ReflectionProperty;
use Doctrine\Common\Persistence\Mapping\ClassMetadata AS IClassMetadata;
use Doctrine\ORM\DefaultNamingStrategy;
use Doctrine\ORM\NamingStrategy;
/**
* A <tt>ClassMetadata</tt> instance holds all the object-relational mapping metadata
* of an entity and it's associations.

View File

@ -30,7 +30,6 @@ namespace Doctrine\ORM;
*/
interface NamingStrategy
{
/**
* Return a table name for an entity class
*
@ -58,24 +57,26 @@ interface NamingStrategy
* Return a join column name for a property
*
* @param string $propertyName A property
* @return string A column name
* @return string A join column name
*/
function joinColumnName($propertyName);
/**
* Return a join table name
*
* @param string $sourceEntity
* @param string $targetEntity
* @param string $propertyName
* @param string $sourceEntity The source entity
* @param string $targetEntity The target entity
* @param string $propertyName A property
* @return string A join table name
*/
function joinTableName($sourceEntity, $targetEntity, $propertyName = null);
/**
* Return the foreign key column name for the given parameters
*
* @param string $entityName
* @param string $referencedColumnName
* @param string $entityName A entity
* @param string $referencedColumnName A property
* @return string A join column name
*/
function joinKeyColumnName($entityName, $referencedColumnName = null);
}

View File

@ -30,24 +30,23 @@ namespace Doctrine\ORM;
*/
class UnderscoreNamingStrategy implements NamingStrategy
{
const CASE_LOWER = 'lower';
const CASE_UPPER = 'upper';
/**
* @var string
*/
private $case;
/**
* @param string $case
* Underscore naming strategy construct
*
* @param integer $case CASE_LOWER | CASE_UPPER
*/
public function __construct($case = self::CASE_LOWER)
public function __construct($case = CASE_LOWER)
{
$this->case = $case;
}
/**
* @return string
* @return integer
*/
public function getCase()
{
@ -55,7 +54,10 @@ class UnderscoreNamingStrategy implements NamingStrategy
}
/**
* @param string $case
* Sets string case CASE_LOWER | CASE_UPPER
* Alphabetic characters converted to lowercase or uppercase
*
* @param integer $case
*/
public function setCase($case)
{
@ -87,7 +89,7 @@ class UnderscoreNamingStrategy implements NamingStrategy
*/
public function referenceColumnName()
{
return $this->case == self::CASE_UPPER ? 'ID' : 'id';
return $this->case === CASE_UPPER ? 'ID' : 'id';
}
/**
@ -123,7 +125,7 @@ class UnderscoreNamingStrategy implements NamingStrategy
{
$string = preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $string);
if ($this->case == self::CASE_UPPER) {
if ($this->case === CASE_UPPER) {
return strtoupper($string);
}

View File

@ -406,7 +406,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$this->assertInstanceOf('Doctrine\ORM\DefaultNamingStrategy', $em->getConfiguration()->getNamingStrategy());
$em->getConfiguration()->setNamingStrategy(new \Doctrine\ORM\UnderscoreNamingStrategy('upper'));
$em->getConfiguration()->setNamingStrategy(new \Doctrine\ORM\UnderscoreNamingStrategy(CASE_UPPER));
$this->assertInstanceOf('Doctrine\ORM\UnderscoreNamingStrategy', $em->getConfiguration()->getNamingStrategy());
$class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType');

View File

@ -298,7 +298,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
*/
public function testUnderscoreNamingStrategyDefaults()
{
$namingStrategy = new \Doctrine\ORM\UnderscoreNamingStrategy(\Doctrine\ORM\UnderscoreNamingStrategy::CASE_UPPER);
$namingStrategy = new \Doctrine\ORM\UnderscoreNamingStrategy(CASE_UPPER);
$oneToOneMetadata = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', $namingStrategy);
$manyToManyMetadata = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', $namingStrategy);

View File

@ -26,7 +26,7 @@ class NamingStrategyTest extends \Doctrine\Tests\OrmTestCase
*/
static private function underscoreNamingLower()
{
return new UnderscoreNamingStrategy(UnderscoreNamingStrategy::CASE_LOWER);
return new UnderscoreNamingStrategy(CASE_LOWER);
}
/**
@ -34,7 +34,7 @@ class NamingStrategyTest extends \Doctrine\Tests\OrmTestCase
*/
static private function underscoreNamingUpper()
{
return new UnderscoreNamingStrategy(UnderscoreNamingStrategy::CASE_UPPER);
return new UnderscoreNamingStrategy(CASE_UPPER);
}
/**
@ -149,8 +149,6 @@ class NamingStrategyTest extends \Doctrine\Tests\OrmTestCase
*
* @param NamingStrategy $strategy
* @param string $expected
* @param string $joinedColumn
* @param string $joinedTable
*/
public function testReferenceColumnName(NamingStrategy $strategy, $expected)
{