Skip to content

Commit

Permalink
Fix code style, remove extra whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
thePanz committed Jun 26, 2024
1 parent a552724 commit 5ef8287
Show file tree
Hide file tree
Showing 28 changed files with 192 additions and 192 deletions.
106 changes: 53 additions & 53 deletions lib/Doctrine/Import/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Doctrine_Import_Schema

/**
* Returns an array of definition keys that can be applied at the global level.
*
*
* @return array
*/
public static function getGlobalDefinitionKeys()
Expand All @@ -165,7 +165,7 @@ public static function getGlobalDefinitionKeys()
/**
* getOption
*
* @param string $name
* @param string $name
* @return void
*/
public function getOption($name)
Expand All @@ -188,8 +188,8 @@ public function getOptions()
/**
* setOption
*
* @param string $name
* @param string $value
* @param string $name
* @param string $value
* @return void
*/
public function setOption($name, $value)
Expand All @@ -198,11 +198,11 @@ public function setOption($name, $value)
$this->_options[$name] = $value;
}
}

/**
* setOptions
*
* @param string $options
* @param array $options
* @return void
*/
public function setOptions($options)
Expand Down Expand Up @@ -230,7 +230,7 @@ public function buildSchema($schema, $format)
$e = explode('.', $s);
if (end($e) === $format) {
$array = array_merge($array, $this->parseSchema($s, $format));
}
}
} else if (is_dir($s)) {
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($s),
RecursiveIteratorIterator::LEAVES_ONLY);
Expand Down Expand Up @@ -270,20 +270,20 @@ public function importSchema($schema, $format = 'yml', $directory = null, $model
$builder = new Doctrine_Import_Builder();
$builder->setTargetPath($directory);
$builder->setOptions($this->getOptions());

$array = $this->buildSchema($schema, $format);

if (count($array) == 0) {
if (count($array) == 0) {
throw new Doctrine_Import_Exception(
sprintf('No ' . $format . ' schema found in ' . implode(", ", $schema))
);
);
}

foreach ($array as $name => $definition) {
if ( ! empty($models) && !in_array($definition['className'], $models)) {
continue;
}

$builder->buildRecord($definition);
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ public function parseSchema($schema, $type)
'package' => null,
'inheritance' => array(),
'detect_relations' => false);

$array = Doctrine_Parser::load($schema, $type);

// Loop over and build up all the global values and remove them from the array
Expand Down Expand Up @@ -431,14 +431,14 @@ public function parseSchema($schema, $type)
$build[$className][$key] = isset($build[$className][$key]) ? $build[$className][$key]:$defaultValue;
}
}

$build[$className]['className'] = $className;
$build[$className]['tableName'] = $tableName;
$build[$className]['columns'] = $columns;

// Make sure that anything else that is specified in the schema makes it to the final array
$build[$className] = Doctrine_Lib::arrayDeepMerge($table, $build[$className]);

// We need to keep track of the className for the connection
$build[$className]['connectionClassName'] = $build[$className]['className'];
}
Expand All @@ -448,11 +448,11 @@ public function parseSchema($schema, $type)

/**
* _processInheritance
*
*
* Perform some processing on inheritance.
* Sets the default type and sets some default values for certain types
*
* @param string $array
* @param string $array
* @return void
*/
protected function _processInheritance($array)
Expand All @@ -472,9 +472,9 @@ protected function _processInheritance($array)
if ($array[$className]['inheritance']['type'] == 'column_aggregation') {
// Set the keyField to 'type' by default
if ( ! isset($array[$className]['inheritance']['keyField'])) {
$array[$className]['inheritance']['keyField'] = 'type';
$array[$className]['inheritance']['keyField'] = 'type';
}

// Set the keyValue to the name of the child class if it does not exist
if ( ! isset($array[$className]['inheritance']['keyValue'])) {
$array[$className]['inheritance']['keyValue'] = $className;
Expand Down Expand Up @@ -510,22 +510,22 @@ protected function _processInheritance($array)

// Populate the parents subclasses
if ($definition['inheritance']['type'] == 'column_aggregation') {
// Fix for 2015: loop through superclasses' inheritance to the base-superclass to
// make sure we collect all keyFields needed (and not only the first)
$inheritanceFields = array($definition['inheritance']['keyField'] => $definition['inheritance']['keyValue']);
// Fix for 2015: loop through superclasses' inheritance to the base-superclass to
// make sure we collect all keyFields needed (and not only the first)
$inheritanceFields = array($definition['inheritance']['keyField'] => $definition['inheritance']['keyValue']);

$superClass = $definition['inheritance']['extends'];
$multiInheritanceDef = $array[$superClass];
$superClass = $definition['inheritance']['extends'];
$multiInheritanceDef = $array[$superClass];

while (count($multiInheritanceDef['inheritance']) > 0 && array_key_exists('extends', $multiInheritanceDef['inheritance']) && $multiInheritanceDef['inheritance']['type'] == 'column_aggregation') {
while (count($multiInheritanceDef['inheritance']) > 0 && array_key_exists('extends', $multiInheritanceDef['inheritance']) && $multiInheritanceDef['inheritance']['type'] == 'column_aggregation') {
$superClass = $multiInheritanceDef['inheritance']['extends'];

// keep original keyField with it's keyValue
if ( ! isset($inheritanceFields[$multiInheritanceDef['inheritance']['keyField']])) {
if ( ! isset($inheritanceFields[$multiInheritanceDef['inheritance']['keyField']])) {
$inheritanceFields[$multiInheritanceDef['inheritance']['keyField']] = $multiInheritanceDef['inheritance']['keyValue'];
}
$multiInheritanceDef = $array[$superClass];
}
}
$multiInheritanceDef = $array[$superClass];
}

$array[$parent]['inheritance']['subclasses'][$definition['className']] = $inheritanceFields;
}
Expand Down Expand Up @@ -555,10 +555,10 @@ protected function _findBaseSuperClass($array, $class)
* buildRelationships
*
* Loop through an array of schema information and build all the necessary relationship information
* Will attempt to auto complete relationships and simplify the amount of information required
* Will attempt to auto complete relationships and simplify the amount of information required
* for defining a relationship
*
* @param string $array
* @param string $array
* @return void
*/
protected function _buildRelationships($array)
Expand Down Expand Up @@ -591,18 +591,18 @@ protected function _buildRelationships($array)
if ( ! isset($properties['relations'])) {
continue;
}

$className = $properties['className'];
$relations = $properties['relations'];

foreach ($relations as $alias => $relation) {
$class = isset($relation['class']) ? $relation['class']:$alias;
if ( ! isset($array[$class])) {
continue;
}
$relation['class'] = $class;
$relation['alias'] = isset($relation['alias']) ? $relation['alias'] : $alias;

// Attempt to guess the local and foreign
if (isset($relation['refClass'])) {
$relation['local'] = isset($relation['local']) ? $relation['local']:Doctrine_Inflector::tableize($name) . '_id';
Expand All @@ -611,11 +611,11 @@ protected function _buildRelationships($array)
$relation['local'] = isset($relation['local']) ? $relation['local']:Doctrine_Inflector::tableize($relation['class']) . '_id';
$relation['foreign'] = isset($relation['foreign']) ? $relation['foreign']:'id';
}

if (isset($relation['refClass'])) {
$relation['type'] = 'many';
}

if (isset($relation['type']) && $relation['type']) {
$relation['type'] = $relation['type'] === 'one' ? Doctrine_Relation::ONE:Doctrine_Relation::MANY;
} else {
Expand All @@ -625,26 +625,26 @@ protected function _buildRelationships($array)
if (isset($relation['foreignType']) && $relation['foreignType']) {
$relation['foreignType'] = $relation['foreignType'] === 'one' ? Doctrine_Relation::ONE:Doctrine_Relation::MANY;
}

$relation['key'] = $this->_buildUniqueRelationKey($relation);

$this->_validateSchemaElement('relation', array_keys($relation), $className . '->relation->' . $relation['alias']);

$this->_relations[$className][$alias] = $relation;
}
}

// Now we auto-complete opposite ends of relationships
$this->_autoCompleteOppositeRelations();

// Make sure we do not have any duplicate relations
$this->_fixDuplicateRelations();

// Set the full array of relationships for each class to the final array
foreach ($this->_relations as $className => $relations) {
$array[$className]['relations'] = $relations;
}

return $array;
}

Expand All @@ -663,22 +663,22 @@ protected function _autoCompleteOppositeRelations()
if ((isset($relation['equal']) && $relation['equal']) || (isset($relation['autoComplete']) && $relation['autoComplete'] === false)) {
continue;
}

$newRelation = array();
$newRelation['foreign'] = $relation['local'];
$newRelation['local'] = $relation['foreign'];
$newRelation['class'] = isset($relation['foreignClass']) ? $relation['foreignClass']:$className;
$newRelation['alias'] = isset($relation['foreignAlias']) ? $relation['foreignAlias']:$className;
$newRelation['foreignAlias'] = $alias;

// this is so that we know that this relation was autogenerated and
// that we do not need to include it if it is explicitly declared in the schema by the users.
$newRelation['autogenerated'] = true;
$newRelation['autogenerated'] = true;

if (isset($relation['refClass'])) {
$newRelation['refClass'] = $relation['refClass'];
$newRelation['type'] = isset($relation['foreignType']) ? $relation['foreignType']:$relation['type'];
} else {
} else {
if (isset($relation['foreignType'])) {
$newRelation['type'] = $relation['foreignType'];
} else {
Expand Down Expand Up @@ -720,7 +720,7 @@ protected function _fixDuplicateRelations()
}
}
}

$this->_relations[$className] = $uniqueRelations;
}
}
Expand All @@ -731,7 +731,7 @@ protected function _fixDuplicateRelations()
* Build a unique key to identify a relationship by
* Md5 hash of all the relationship parameters
*
* @param string $relation
* @param string $relation
* @return void
*/
protected function _buildUniqueRelationKey($relation)
Expand All @@ -742,8 +742,8 @@ protected function _buildUniqueRelationKey($relation)
/**
* _validateSchemaElement
*
* @param string $name
* @param string $value
* @param string $name
* @param string $value
* @return void
*/
protected function _validateSchemaElement($name, $element, $path)
Expand All @@ -768,4 +768,4 @@ protected function _validateSchemaElement($name, $element, $path)
}
}
}
}
}
6 changes: 3 additions & 3 deletions lib/Doctrine/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ abstract public function dumpData($array, $path = null, $charset = null);
* Get instance of the specified parser
*
* @param string $type
* @return void
* @return Doctrine_Parser
* @author Jonathan H. Wage
*/
static public function getParser($type)
Expand Down Expand Up @@ -94,7 +94,7 @@ static public function load($path, $type = 'xml', $charset = 'UTF-8')
*
* Interface for pulling and dumping data to a file
*
* @param string $array
* @param array $array
* @param string $path
* @param string $type
* @param string $charset The charset of the data being dumped
Expand All @@ -115,7 +115,7 @@ static public function dump($array, $type = 'xml', $path = null, $charset = null
* Either should allow php code in it.
*
* @param string $path
* @return void
* @return false|string
*/
public function doLoad($path)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testAggressiveModelLoading()

// Make sure it does not include the base classes
$this->assertTrue( ! isset($models['BaseAggressiveModelLoadingUser']));

$filteredModels = Doctrine_Core::filterInvalidModels($models);

// Make sure filterInvalidModels filters out base abstract classes
Expand Down Expand Up @@ -85,7 +85,7 @@ public function testModelLoadingCacheInformation()
$this->assertTrue(in_array('AggressiveModelLoadingUser', $models));
$this->assertTrue(in_array('ConservativeModelLoadingProfile', $models));
$this->assertTrue(in_array('ConservativeModelLoadingContact', $models));

$modelFiles = Doctrine_Core::getLoadedModelFiles();
$this->assertTrue(file_exists($modelFiles['ConservativeModelLoadingUser']));
$this->assertTrue(file_exists($modelFiles['ConservativeModelLoadingProfile']));
Expand Down
Loading

0 comments on commit 5ef8287

Please sign in to comment.