Skip to content

Commit

Permalink
naming alignments, AS to as in foreach, dirname(__FILE__) => __DIR__
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Nov 17, 2011
1 parent 0970226 commit 3b26bec
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 99 deletions.
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ cscope.out
doc/config/phpdoc.ini
doc/html

/tests/phpunit_jackrabbit.xml
/tests/phpunit_doctrinedbal.xml
/tests/fixtures/doctrine
/tests/phpunit.xml
tests/phpunit_jackrabbit.xml
tests/phpunit_doctrine_dbal.xml
tests/fixtures/doctrine
tests/phpunit.xml


jackrabbit/
jackrabbit-standalone*.jar
tests/vendor/doctrine-dbal
tests/vendor/doctrine-common
tests/vendor/jackrabbit-standalone*.jar
tests/vendor/jackrabbit
2 changes: 1 addition & 1 deletion README.DOCTRINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ You need both Jackalope with the DoctrineDBAL branch and Doctrine Common+DBAL in

// only necessary on the first run, creates the database:
$schema = \Jackalope\Transport\DoctrineDBAL\RepositorySchema::create();
foreach ($schema->toSQL($dbConn->getDatabasePlatform()) AS $sql) {
foreach ($schema->toSQL($dbConn->getDatabasePlatform()) as $sql) {
$dbConn->exec($sql);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Jackalope/NodeType/NodeTypeDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ protected function fromArray(array $data)
$this->primaryItemName = $data['primaryItemName'] ?: null;
$this->declaredSuperTypeNames = (isset($data['declaredSuperTypeNames']) && count($data['declaredSuperTypeNames'])) ? $data['declaredSuperTypeNames'] : array();
$this->declaredPropertyDefinitions = new ArrayObject();
foreach ($data['declaredPropertyDefinitions'] AS $propertyDef) {
foreach ($data['declaredPropertyDefinitions'] as $propertyDef) {
$this->declaredPropertyDefinitions[] = $this->factory->get(
'NodeType\PropertyDefinition',
array($propertyDef, $this->nodeTypeManager)
);
}
$this->declaredNodeDefinitions = new ArrayObject();
foreach ($data['declaredNodeDefinitions'] AS $nodeDef) {
foreach ($data['declaredNodeDefinitions'] as $nodeDef) {
$this->declaredNodeDefinitions[] = $this->factory->get(
'NodeType\NodeDefinition',
array($nodeDef, $this->nodeTypeManager)
Expand Down
56 changes: 28 additions & 28 deletions src/Jackalope/Transport/DoctrineDBAL/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function getNamespaces()
$data = $this->conn->fetchAll('SELECT * FROM phpcr_namespaces');
$this->fetchedUserNamespaces = true;

foreach ($data AS $row) {
foreach ($data as $row) {
$this->namespaces[$row['prefix']] = $row['uri'];
}
}
Expand Down Expand Up @@ -438,8 +438,8 @@ private function syncUserIndexes()

private function syncBinaryData($nodeId, $binaryData)
{
foreach ($binaryData AS $propertyName => $binaryValues) {
foreach ($binaryValues AS $idx => $data) {
foreach ($binaryData as $propertyName => $binaryValues) {
foreach ($binaryValues as $idx => $data) {
$this->conn->delete('phpcr_binarydata', array(
'node_id' => $nodeId,
'property_name' => $propertyName,
Expand All @@ -461,12 +461,12 @@ private function syncForeignKeys($nodeId, $path, $props)
$this->conn->delete('phpcr_nodes_foreignkeys', array(
'source_id' => $nodeId,
));
foreach ($props AS $property) {
foreach ($props as $property) {
$type = $property->getType();
if ($type == \PHPCR\PropertyType::REFERENCE || $type == \PHPCR\PropertyType::WEAKREFERENCE) {
$values = array_unique( $property->isMultiple() ? $property->getString() : array($property->getString()) );

foreach ($values AS $value) {
foreach ($values as $value) {
$targetId = $this->pathExists($this->getNodePathForIdentifier($value));
if (!$targetId) {
if ($type == \PHPCR\PropertyType::REFERENCE) {
Expand Down Expand Up @@ -515,7 +515,7 @@ static public function propsToXML($properties, $inlineBinaries = false)
$dom->appendChild($rootNode);

$binaryData = null;
foreach ($properties AS $property) {
foreach ($properties as $property) {
/* @var $prop \PHPCR\PropertyInterface */
$propertyNode = $dom->createElement('sv:property');
$propertyNode->setAttribute('sv:name', $property->getName());
Expand All @@ -542,7 +542,7 @@ static public function propsToXML($properties, $inlineBinaries = false)
break;
case \PHPCR\PropertyType::BINARY:
if ($property->isMultiple()) {
foreach ((array)$property->getBinary() AS $binary) {
foreach ((array)$property->getBinary() as $binary) {
$binary = stream_get_contents($binary);
$binaryData[$property->getName()][] = $binary;
$values[] = strlen($binary);
Expand All @@ -562,7 +562,7 @@ static public function propsToXML($properties, $inlineBinaries = false)
break;
}

foreach ((array)$values AS $value) {
foreach ((array)$values as $value) {
$propertyNode->appendChild($dom->createElement('sv:value', $value));
}

Expand All @@ -576,7 +576,7 @@ static public function propsToXML($properties, $inlineBinaries = false)
public function getAccessibleWorkspaceNames()
{
$workspaceNames = array();
foreach ($this->conn->fetchAll("SELECT name FROM phpcr_workspaces") AS $row) {
foreach ($this->conn->fetchAll("SELECT name FROM phpcr_workspaces") as $row) {
$workspaceNames[] = $row['name'];
}
return $workspaceNames;
Expand All @@ -602,7 +602,7 @@ public function getNode($path)
$sql = "SELECT path FROM phpcr_nodes WHERE parent = ? AND workspace_id = ?";
$children = $this->conn->fetchAll($sql, array($path, $this->workspaceId));

foreach ($children AS $child) {
foreach ($children as $child) {
$childName = explode("/", $child['path']);
$childName = end($childName);
$data->{$childName} = new \stdClass();
Expand All @@ -611,11 +611,11 @@ public function getNode($path)
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->loadXML($row['props']);

foreach ($dom->getElementsByTagNameNS('http://www.jcp.org/jcr/sv/1.0', 'property') AS $propertyNode) {
foreach ($dom->getElementsByTagNameNS('http://www.jcp.org/jcr/sv/1.0', 'property') as $propertyNode) {
$name = $propertyNode->getAttribute('sv:name');
$values = array();
$type = (int)$propertyNode->getAttribute('sv:type');
foreach ($propertyNode->childNodes AS $valueNode) {
foreach ($propertyNode->childNodes as $valueNode) {
switch ($type) {
case \PHPCR\PropertyType::NAME:
case \PHPCR\PropertyType::URI:
Expand Down Expand Up @@ -736,7 +736,7 @@ public function deleteNode($path)
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->loadXml($xml);

foreach ($dom->getElementsByTagNameNS('http://www.jcp.org/jcr/sv/1.0', 'property') AS $propertyNode) {
foreach ($dom->getElementsByTagNameNS('http://www.jcp.org/jcr/sv/1.0', 'property') as $propertyNode) {
if ($propertyName == $propertyNode->getAttribute('sv:name')) {
$propertyNode->parentNode->removeChild($propertyNode);
break;
Expand Down Expand Up @@ -808,7 +808,7 @@ private function getParentPath($path)
*/
private function validateNode($node, $def)
{
foreach ($def->getDeclaredChildNodeDefinitions() AS $childDef) {
foreach ($def->getDeclaredChildNodeDefinitions() as $childDef) {
/* @var $childDef \PHPCR\NodeType\NodeDefinitionInterface */
if (!$node->hasNode($childDef->getName())) {
if ($childDef->getName() === '*') {
Expand All @@ -834,7 +834,7 @@ private function validateNode($node, $def)
}
}

foreach ($def->getDeclaredPropertyDefinitions() AS $propertyDef) {
foreach ($def->getDeclaredPropertyDefinitions() as $propertyDef) {
/* @var $propertyDef \PHPCR\NodeType\PropertyDefinitionInterface */
if ($propertyDef->getName() == '*') {
continue;
Expand Down Expand Up @@ -874,7 +874,7 @@ private function getResponsibleNodeTypes($node)
array_unshift($nodeTypes, $nodeDef);
foreach ($nodeTypes as $nodeType) {
/* @var $nodeType \PHPCR\NodeType\NodeTypeDefinitionInterface */
foreach ($nodeType->getDeclaredSupertypes() AS $superType) {
foreach ($nodeType->getDeclaredSupertypes() as $superType) {
$nodeTypes[] = $superType;
}
}
Expand All @@ -889,7 +889,7 @@ public function storeNode(\PHPCR\NodeInterface $node)

$nodeTypes = $this->getResponsibleNodeTypes($node);
$popertyDefs = array();
foreach ($nodeTypes AS $nodeType) {
foreach ($nodeTypes as $nodeType) {
/* @var $nodeType \PHPCR\NodeType\NodeTypeDefinitionInterface */
$this->validateNode($node, $nodeType);
}
Expand Down Expand Up @@ -980,13 +980,13 @@ public function getNodeTypes($nodeTypes = array())

$data = PHPCR2StandardNodeTypes::getNodeTypeData();
$filteredData = array();
foreach ($data AS $nodeTypeData) {
foreach ($data as $nodeTypeData) {
if (isset($nodeTypes[$nodeTypeData['name']])) {
$filteredData[$nodeTypeData['name']] = $nodeTypeData;
}
}

foreach ($nodeTypes AS $type => $val) {
foreach ($nodeTypes as $type => $val) {
if (!isset($filteredData[$type]) && $result = $this->fetchUserNodeType($type)) {
$filteredData[$type] = $result;
}
Expand Down Expand Up @@ -1030,7 +1030,7 @@ private function fetchUserNodeType($name)
$query = "SELECT * FROM phpcr_type_props WHERE node_type_id = ?";
$props = $this->conn->fetchAll($query, array($data['node_type_id']));

foreach ($props AS $propertyData) {
foreach ($props as $propertyData) {
$result['declaredPropertyDefinitions'][] = array(
'declaringNodeType' => $data['name'],
'name' => $propertyData['name'],
Expand Down Expand Up @@ -1058,7 +1058,7 @@ private function fetchUserNodeType($name)
$query = "SELECT * FROM phpcr_type_childs WHERE node_type_id = ?";
$childs = $this->conn->fetchAll($query, array($data['node_type_id']));

foreach ($childs AS $childData) {
foreach ($childs as $childData) {
$result['declaredNodeDefinitions'][] = array(
'declaringNodeType' => $data['name'],
'name' => $childData['name'],
Expand Down Expand Up @@ -1086,7 +1086,7 @@ public function registerNodeTypesCnd($cnd, $allowUpdate)
// inherit all doc
public function registerNodeTypes($types, $allowUpdate)
{
foreach ($types AS $type) {
foreach ($types as $type) {
/* @var $type \Jackalope\NodeType\NodeTypeDefinition */
$this->conn->insert('phpcr_type_nodes', array(
'name' => $type->getName(),
Expand All @@ -1100,7 +1100,7 @@ public function registerNodeTypes($types, $allowUpdate)
$nodeTypeId = $this->conn->lastInsertId($this->sequenceTypeName);

if ($propDefs = $type->getDeclaredPropertyDefinitions()) {
foreach ($propDefs AS $propertyDef) {
foreach ($propDefs as $propertyDef) {
/* @var $propertyDef \Jackalope\NodeType\PropertyDefinition */
$this->conn->insert('phpcr_type_props', array(
'node_type_id' => $nodeTypeId,
Expand All @@ -1120,7 +1120,7 @@ public function registerNodeTypes($types, $allowUpdate)
}

if ($childDefs = $type->getDeclaredChildNodeDefinitions()) {
foreach ($childDefs AS $childDef) {
foreach ($childDefs as $childDef) {
/* @var $propertyDef \PHPCR\NodeType\NodeDefinitionInterface */
$this->conn->insert('phpcr_type_childs', array(
'node_type_id' => $nodeTypeId,
Expand Down Expand Up @@ -1168,7 +1168,7 @@ public function getBinaryStream($path)
return fopen("data://text/plain,".$data[0]['data'], "r");
} else {
$streams = array();
foreach ($data AS $row) {
foreach ($data as $row) {
$streams[$row['idx']] = fopen("data://text/plain,".$row['data'], "r");
}
return $streams;
Expand Down Expand Up @@ -1201,7 +1201,7 @@ public function query(\PHPCR\Query\QueryInterface $query)
$data = $this->conn->fetchAll($sql, array($this->workspaceId));

$result = array();
foreach ($data AS $row) {
foreach ($data as $row) {
$result[] = array(
array('dcr:name' => 'jcr:primaryType', 'dcr:value' => $row['type']),
array('dcr:name' => 'jcr:path', 'dcr:value' => $row['path'], 'dcr:selectorName' => $row['type']),
Expand Down Expand Up @@ -1251,13 +1251,13 @@ protected function getNodeReferences($path, $name = null, $weakReference = false

$type = $weakReference ? \PHPCR\PropertyType::WEAKREFERENCE : \PHPCR\PropertyType::REFERENCE;

$sql = "SELECT CONCAT(n.path, '/', fk.source_property_name) AS path, fk.source_property_name FROM phpcr_nodes n " .
$sql = "SELECT CONCAT(n.path, '/', fk.source_property_name) as path, fk.source_property_name FROM phpcr_nodes n " .
"INNER JOIN phpcr_nodes_foreignkeys fk ON n.id = fk.source_id ".
"WHERE fk.target_id = ? AND fk.type = ?";
$properties = $this->conn->fetchAll($sql, array($targetId, $type));

$references = array();
foreach ($properties AS $property) {
foreach ($properties as $property) {
if ($name === null || $property['source_property_name'] == $name) {
$references[] = $property['path'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Jackalope/Transport/DoctrineDBAL/Query/QOMWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function walkOperand(QOM\OperandInterface $operand)
public function walkOrderings(array $orderings)
{
$sql = "ORDER BY ";
foreach ($orderings AS $ordering) {
foreach ($orderings as $ordering) {
$sql .= $this->walkOrdering($ordering);
}
return $sql;
Expand Down
6 changes: 3 additions & 3 deletions tests/Jackalope/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function setUp()
$this->credentials = new \PHPCR\SimpleCredentials($this->config['user'], $this->config['pass']);
}

protected function getTransportStub($path)
protected function getTransportStub()
{
$factory = new \Jackalope\Factory;
$transport = $this->getMock('\Jackalope\Transport\Jackrabbit\Client', array('getNode', 'getNodeTypes', 'getNodePathForIdentifier'), array($factory, 'http://example.com'));
Expand All @@ -29,7 +29,7 @@ protected function getTransportStub($path)
->will($this->returnValue(json_decode($this->JSON)));

$dom = new \DOMDocument();
$dom->load(dirname(__FILE__) . '/../fixtures/nodetypes.xml');
$dom->load(__DIR__ . '/../fixtures/nodetypes.xml');
$transport->expects($this->any())
->method('getNodeTypes')
->will($this->returnValue($dom));
Expand Down Expand Up @@ -91,7 +91,7 @@ protected function getNodeTypeManager()
{
$factory = new \Jackalope\Factory;
$dom = new \DOMDocument();
$dom->load(dirname(__FILE__) . '/../fixtures/nodetypes.xml');
$dom->load(__DIR__ . '/../fixtures/nodetypes.xml');
$converter = new \Jackalope\NodeType\NodeTypeXmlConverter($factory);
$om = $this->getObjectManagerMock();
$om->expects($this->any())
Expand Down
4 changes: 2 additions & 2 deletions tests/Jackalope/Transport/DoctrineDBAL/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public function setUp()
$conn = $this->getConnection();
$schema = RepositorySchema::create();

foreach ($schema->toDropSql($conn->getDatabasePlatform()) AS $statement) {
foreach ($schema->toDropSql($conn->getDatabasePlatform()) as $statement) {
try {
$conn->exec($statement);
} catch(\Exception $e) {

}
}

foreach ($schema->toSql($conn->getDatabasePlatform()) AS $statement) {
foreach ($schema->toSql($conn->getDatabasePlatform()) as $statement) {
$conn->exec($statement);
}

Expand Down
Loading

0 comments on commit 3b26bec

Please sign in to comment.