Skip to content

Commit

Permalink
Implement review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Dec 11, 2023
1 parent 0b89580 commit 919dcdb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/Jackalope/Transport/DoctrineDBAL/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,7 @@ public function deleteProperties(array $operations)
}

// Doing the actual removal
$this->assertLoggedIn();
foreach ($nodesByPath as $nodePath => $propertiesToDelete) {
$this->removePropertiesFromNode($nodePath, $propertiesToDelete);
}
Expand Down Expand Up @@ -1840,18 +1841,18 @@ protected function deleteProperty($path)
{
$nodePath = PathHelper::getParentPath($path);
$propertyName = PathHelper::getNodeName($path);
$this->assertLoggedIn();
$this->removePropertiesFromNode($nodePath, [$propertyName]);
}

/**
* Removes a list of properties from a given node.
*
* @param string $nodeId
* @param array<string> $paths Path belonging to that node that should be deleted
* @param string $nodePath
* @param array<string> $propertiesToDelete Path belonging to that node that should be deleted
*/
private function removePropertiesFromNode($nodePath, array $propertiesToDelete): void
{
$this->assertLoggedIn();
$nodeId = $this->getSystemIdForNode($nodePath);
if (!$nodeId) {
// no we really don't know that path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ public function __construct(string $xml, array $propertyNames)
}

/**
* @example [$xml, $references] = $xmlPropsRemover->removeProps($xml, $propertiesToDelete);
*
* @return array{
* 0: string,
* 1: array{
* reference: string[],
* weakreference: string[],
* },
* }
* } An array with the new xml (0) and the references (1) which requires to be removed.
*/
public function removeProps(): array
{
Expand Down Expand Up @@ -143,7 +145,7 @@ private function endHandler($parser, $name): void
}

if ($this->newStartTag) {
// if the tag is not rendered to newXml it can be a self closing tag
// if the tag is not rendered to newXml it can be a self-closing tag
$this->newXml .= \substr($this->newStartTag, 0.0, -1) . '/>';
$this->newStartTag = '';

Expand All @@ -160,9 +162,9 @@ private function dataHandler($parser, $data): void
}

if ($data !== '') {
$this->newXml .= $this->newStartTag; // none empty data means no self closing tag so render tag now
$this->newXml .= $this->newStartTag; // non-empty data means no self closing tag so render tag now
$this->newStartTag = '';
$this->newXml .= htmlspecialchars($data, ENT_XML1, 'UTF-8');
$this->newXml .= \htmlspecialchars($data, ENT_XML1, 'UTF-8');
}
}
}

0 comments on commit 919dcdb

Please sign in to comment.