From d37ae91346aee32f52966e73dedb99e2372af182 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 20 Sep 2023 19:10:58 +0200 Subject: [PATCH] cs --- src/Jackalope/Jackrabbit/Factory.php | 3 - .../Query/QOM/QueryObjectModelFactory.php | 4 - src/Jackalope/RepositoryFactoryJackrabbit.php | 2 - .../Tools/Console/Helper/JackrabbitHelper.php | 1 + src/Jackalope/Transport/Jackrabbit/Client.php | 218 ++---------------- .../Transport/Jackrabbit/EventBuffer.php | 33 ++- .../Jackrabbit/HTTPErrorException.php | 4 +- .../Jackrabbit/JackrabbitClientInterface.php | 2 - .../Transport/Jackrabbit/LoggingClient.php | 72 ------ .../Transport/Jackrabbit/Request.php | 8 +- src/Jackalope/Transport/Jackrabbit/curl.php | 3 +- tests/ImplementationLoader.php | 2 +- .../Transport/Jackrabbit/ClientTest.php | 19 +- .../Transport/Jackrabbit/RequestTest.php | 3 +- 14 files changed, 45 insertions(+), 329 deletions(-) diff --git a/src/Jackalope/Jackrabbit/Factory.php b/src/Jackalope/Jackrabbit/Factory.php index a12a166b..9f84bc04 100644 --- a/src/Jackalope/Jackrabbit/Factory.php +++ b/src/Jackalope/Jackrabbit/Factory.php @@ -10,9 +10,6 @@ */ class Factory extends \Jackalope\Factory { - /** - * {@inheritDoc} - */ public function get($name, array $params = []) { switch ($name) { diff --git a/src/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactory.php b/src/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactory.php index 29ccb1a8..73116b00 100644 --- a/src/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactory.php +++ b/src/Jackalope/Jackrabbit/Query/QOM/QueryObjectModelFactory.php @@ -20,8 +20,6 @@ use PHPCR\Query\QOM\UpperCaseInterface; /** - * {@inheritDoc} - * * @license http://www.apache.org/licenses Apache License Version 2.0, January 2004 * @license http://opensource.org/licenses/MIT MIT License * @@ -30,8 +28,6 @@ class QueryObjectModelFactory extends BaseQueryObjectModelFactory { /** - * {@inheritDoc} - * * @api */ public function createQuery( diff --git a/src/Jackalope/RepositoryFactoryJackrabbit.php b/src/Jackalope/RepositoryFactoryJackrabbit.php index ffaa67e1..8349308b 100644 --- a/src/Jackalope/RepositoryFactoryJackrabbit.php +++ b/src/Jackalope/RepositoryFactoryJackrabbit.php @@ -129,8 +129,6 @@ public function getRepository(array $parameters = null) } /** - * {@inheritDoc} - * * @api */ public function getConfigurationKeys() diff --git a/src/Jackalope/Tools/Console/Helper/JackrabbitHelper.php b/src/Jackalope/Tools/Console/Helper/JackrabbitHelper.php index 21bce3b5..e03ad572 100644 --- a/src/Jackalope/Tools/Console/Helper/JackrabbitHelper.php +++ b/src/Jackalope/Tools/Console/Helper/JackrabbitHelper.php @@ -67,6 +67,7 @@ public function isServerRunning() public function getServerPid() { $pid = trim(shell_exec("pgrep -f -n 'java \-jar {$this->jackrabbit_jar}'")); + // TODO: check it's a valid pid return $pid; } diff --git a/src/Jackalope/Transport/Jackrabbit/Client.php b/src/Jackalope/Transport/Jackrabbit/Client.php index 40827ed4..378d9f76 100644 --- a/src/Jackalope/Transport/Jackrabbit/Client.php +++ b/src/Jackalope/Transport/Jackrabbit/Client.php @@ -3,9 +3,6 @@ namespace Jackalope\Transport\Jackrabbit; use DOMDocument; -use DOMElement; -use DOMXPath; -use InvalidArgumentException; use Jackalope\FactoryInterface; use Jackalope\Lock\Lock; use Jackalope\Node; @@ -19,7 +16,6 @@ use Jackalope\Transport\QueryInterface as QueryTransport; use Jackalope\Transport\VersioningInterface; use Jackalope\Transport\WritingInterface; -use LogicException; use PHPCR\CredentialsInterface; use PHPCR\ItemExistsException; use PHPCR\ItemNotFoundException; @@ -142,7 +138,7 @@ class Client extends BaseTransport implements JackrabbitClientInterface * * "$server/$workspace" without trailing slash * - * @var string + * @var string */ protected $workspaceUri; @@ -173,7 +169,7 @@ class Client extends BaseTransport implements JackrabbitClientInterface * * @var curl */ - protected $curl = null; + protected $curl; /** * A list of additional HTTP headers to be sent on each request. @@ -214,7 +210,7 @@ class Client extends BaseTransport implements JackrabbitClientInterface * * @var string[] as returned by getRepositoryDescriptors */ - protected $descriptors = null; + protected $descriptors; protected $jsopBody = []; @@ -232,7 +228,7 @@ class Client extends BaseTransport implements JackrabbitClientInterface * * @var string|null */ - private $version = null; + private $version; /** * Create a transport pointing to a server url. @@ -261,25 +257,16 @@ public function __destruct() $this->logout(); } - /** - * {@inheritDoc} - */ public function addDefaultHeader($header) { $this->defaultHeaders[] = $header; } - /** - * {@inheritDoc} - */ public function sendExpect($send = true) { $this->sendExpect = $send; } - /** - * {@inheritDoc} - */ public function forceHttpVersion10($forceHttpVersion10 = true) { if ($forceHttpVersion10) { @@ -289,9 +276,6 @@ public function forceHttpVersion10($forceHttpVersion10 = true) } } - /** - * {@inheritDoc} - */ public function addCurlOptions(array $options) { return $this->curlOptions += $options; @@ -340,15 +324,12 @@ protected function getCurl() $this->curl = new curl(); } elseif (false === $this->curl) { // but do not re-connect, rather report the error if trying to access a closed connection - throw new LogicException('Tried to start a request on a closed transport.'); + throw new \LogicException('Tried to start a request on a closed transport.'); } return $this->curl; } - /** - * {@inheritDoc} - */ public function getWorkspaceUri() { return $this->workspaceUri; @@ -356,9 +337,6 @@ public function getWorkspaceUri() // CoreInterface // - /** - * {@inheritDoc} - */ public function login(CredentialsInterface $credentials = null, $workspaceName = null) { if ($this->credentials) { @@ -408,9 +386,6 @@ public function login(CredentialsInterface $credentials = null, $workspaceName = return $workspaceName; } - /** - * {@inheritDoc} - */ public function logout() { if (!empty($this->curl)) { @@ -419,17 +394,11 @@ public function logout() $this->curl = false; } - /** - * {@inheritDoc} - */ public function setCheckLoginOnServer($bool) { $this->checkLoginOnServer = $bool; } - /** - * {@inheritDoc} - */ public function getRepositoryDescriptors() { if (null == $this->descriptors) { @@ -498,9 +467,6 @@ public function getRepositoryDescriptors() return $this->descriptors; } - /** - * {@inheritDoc} - */ public function getAccessibleWorkspaceNames() { $request = $this->getRequest(Request::PROPFIND, $this->server); @@ -518,9 +484,6 @@ public function getAccessibleWorkspaceNames() return array_unique($workspaces); } - /** - * {@inheritDoc} - */ public function getNode($path) { $path = $this->encodeAndValidatePathForDavex($path); @@ -534,9 +497,6 @@ public function getNode($path) } } - /** - * {@inheritDoc} - */ public function getNodes($paths, $query = ':include') { if (0 == count($paths)) { @@ -572,9 +532,6 @@ public function getNodes($paths, $query = ':include') } } - /** - * {@inheritDoc} - */ public function getNodesByIdentifier($identifiers) { // OPTIMIZE get paths for UUID's via a single query @@ -593,9 +550,6 @@ public function getNodesByIdentifier($identifiers) return $this->getNodes($paths); } - /** - * {@inheritDoc} - */ public function getNodeByIdentifier($uuid) { // OPTIMIZE get nodes directly by uuid from backend. needs implementation on jackrabbit @@ -606,9 +560,6 @@ public function getNodeByIdentifier($uuid) return $data; } - /** - * {@inheritDoc} - */ public function getNodePathForIdentifier($uuid, $workspace = null) { if (null !== $workspace && $workspace != $this->workspace) { @@ -644,9 +595,6 @@ public function getNodePathForIdentifier($uuid, $workspace = null) return $this->stripServerRootFromUri(substr(urldecode($fullPath), 0, -1)); } - /** - * {@inheritDoc} - */ public function getProperty($path) { throw new NotImplementedException(); @@ -658,9 +606,6 @@ public function getProperty($path) */ } - /** - * {@inheritDoc} - */ public function getBinaryStream($path) { $path = $this->encodeAndValidatePathForDavex($path); @@ -699,7 +644,7 @@ public function getBinaryStream($path) */ private function decodeBinaryDom($xml) { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); if (!$dom->loadXML($xml)) { throw new RepositoryException("Failed to load xml data:\n\n$xml"); } @@ -721,17 +666,11 @@ private function decodeBinaryDom($xml) return $ret; } - /** - * {@inheritDoc} - */ public function getReferences($path, $name = null) { return $this->getNodeReferences($path, $name); } - /** - * {@inheritDoc} - */ public function getWeakReferences($path, $name = null) { return $this->getNodeReferences($path, $name, true); @@ -792,9 +731,6 @@ private function removeTrailingSlash($path) // VersioningInterface // - /** - * {@inheritDoc} - */ public function addVersionLabel($versionPath, $label, $moveLabel) { $versionPath = $this->encodeAndValidatePathForDavex($versionPath); @@ -821,9 +757,6 @@ public function addVersionLabel($versionPath, $label, $moveLabel) return; } - /** - * {@inheritDoc} - */ public function removeVersionLabel($versionPath, $label) { $versionPath = $this->encodeAndValidatePathForDavex($versionPath); @@ -837,9 +770,6 @@ public function removeVersionLabel($versionPath, $label) return; } - /** - * {@inheritDoc} - */ public function checkinItem($path) { $path = $this->encodeAndValidatePathForDavex($path); @@ -861,9 +791,6 @@ public function checkinItem($path) throw new RepositoryException(); } - /** - * {@inheritDoc} - */ public function checkoutItem($path) { $path = $this->encodeAndValidatePathForDavex($path); @@ -881,9 +808,6 @@ public function checkoutItem($path) return; } - /** - * {@inheritDoc} - */ public function restoreItem($removeExisting, $versionPath, $path) { $path = $this->encodeAndValidatePathForDavex($path); @@ -904,9 +828,6 @@ public function restoreItem($removeExisting, $versionPath, $path) $request->execute(); // errors are checked in request } - /** - * {@inheritDoc} - */ public function removeVersion($versionPath, $versionName) { $path = $this->encodeAndValidatePathForDavex($versionPath.'/'.$versionName); @@ -918,9 +839,6 @@ public function removeVersion($versionPath, $versionName) // QueryTransport // - /** - * {@inheritDoc} - */ public function query(Query $query) { // TODO handle bind variables @@ -969,9 +887,9 @@ public function query(Query $query) $rawData = $request->execute(); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->loadXML($rawData); - $domXpath = new DOMXPath($dom); + $domXpath = new \DOMXPath($dom); $rows = []; foreach ($domXpath->query('D:response') as $row) { @@ -1006,9 +924,6 @@ public function query(Query $query) return $rows; } - /** - * {@inheritDoc} - */ public function getSupportedQueryLanguages() { return [ @@ -1028,12 +943,11 @@ public function getSupportedQueryLanguages() * * false * - * @param DOMElement $node a dcr:value xml element - * @param string $attribute the attribute name + * @param \DOMElement $node a dcr:value xml element * * @return mixed the node value converted to the specified type */ - private function getDcrValue(DOMElement $node) + private function getDcrValue(\DOMElement $node) { $type = $node->getAttribute('dcr:type'); if (PropertyType::TYPENAME_BOOLEAN == $type && 'false' == $node->nodeValue) { @@ -1045,9 +959,6 @@ private function getDcrValue(DOMElement $node) // WritingInterface // - /** - * {@inheritDoc} - */ public function deleteNodes(array $operations) { // Reverse sort the batch; work-around for problem with @@ -1078,9 +989,6 @@ public function deleteNodes(array $operations) } } - /** - * {@inheritDoc} - */ public function deleteProperties(array $operations) { foreach ($operations as $operation) { @@ -1088,9 +996,6 @@ public function deleteProperties(array $operations) } } - /** - * {@inheritDoc} - */ public function deleteNodeImmediately($path) { $this->prepareSave(); @@ -1098,9 +1003,6 @@ public function deleteNodeImmediately($path) $this->finishSave(); } - /** - * {@inheritDoc} - */ public function deletePropertyImmediately($path) { $this->prepareSave(); @@ -1120,9 +1022,6 @@ protected function deleteItem($path) $this->setJsopBody('-'.$path.' : '); } - /** - * {@inheritDoc} - */ public function copyNode($srcAbsPath, $dstAbsPath, $srcWorkspace = null) { if ($srcWorkspace) { @@ -1135,9 +1034,7 @@ public function copyNode($srcAbsPath, $dstAbsPath, $srcWorkspace = null) /** * For copy within the same workspace, this is a COPY request. * - * @param string $srcAbsPath Absolute source path to the node - * @param string $destAbsPath Absolute destination path including the new - * node name + * @param string $srcAbsPath Absolute source path to the node */ private function copyNodeSameWorkspace($srcAbsPath, $dstAbsPath) { @@ -1156,8 +1053,6 @@ private function copyNodeSameWorkspace($srcAbsPath, $dstAbsPath) * As seen with jackrabbit 2.6 * * @param string $srcAbsPath Absolute source path to the node - * @param string $destAbsPath Absolute destination path including the new - * node name * @param string $srcWorkspace The workspace where the source node can be * found or null for current workspace */ @@ -1169,9 +1064,6 @@ private function copyNodeOtherWorkspace($srcAbsPath, $dstAbsPath, $srcWorkspace) $request->execute(); } - /** - * {@inheritDoc} - */ public function moveNodes(array $operations) { foreach ($operations as $operation) { @@ -1182,9 +1074,6 @@ public function moveNodes(array $operations) } } - /** - * {@inheritDoc} - */ public function moveNodeImmediately($srcAbsPath, $dstAbsPath) { $request = $this->getRequest(Request::MOVE, $srcAbsPath); @@ -1193,9 +1082,6 @@ public function moveNodeImmediately($srcAbsPath, $dstAbsPath) $request->execute(); } - /** - * {@inheritDoc} - */ public function reorderChildren(Node $node) { $reorders = $node->getOrderCommands(); @@ -1217,9 +1103,6 @@ public function reorderChildren(Node $node) $this->setJsopBody(trim($body)); } - /** - * {@inheritDoc} - */ public function cloneFrom($srcWorkspace, $srcAbsPath, $destAbsPath, $removeExisting) { $srcAbsPath = $this->encodeAndValidatePathForDavex($srcAbsPath); @@ -1242,10 +1125,6 @@ public function cloneFrom($srcWorkspace, $srcAbsPath, $destAbsPath, $removeExist * * Jackrabbit supports them, but jackalope does not. * - * @param $srcWorkspace - * @param $srcAbsPath - * @param $destAbsPath - * * @throws \PHPCR\ItemExistsException */ protected function checkForExistingNode($srcWorkspace, $srcAbsPath, $destAbsPath) @@ -1275,9 +1154,6 @@ protected function checkForExistingNode($srcWorkspace, $srcAbsPath, $destAbsPath } } - /** - * {@inheritDoc} - */ public function updateNode(Node $node, $srcWorkspace) { $path = $this->encodeAndValidatePathForDavex($node->getPath()); @@ -1299,9 +1175,6 @@ public function updateNode(Node $node, $srcWorkspace) $request->execute(); } - /** - * {@inheritDoc} - */ public function storeNodes(array $operations) { /** @var $operation \Jackalope\Transport\AddNodeOperation */ @@ -1371,9 +1244,6 @@ protected function isStringValid($string) return 0 === preg_match($regex, $string, $matches); } - /** - * {@inheritDoc} - */ public function updateProperties(Node $node) { $this->updateLastModified($node); @@ -1453,9 +1323,6 @@ protected function createNodeJsop($path, $properties) /** * This method is used when building a JSOP of the properties. * - * @param $value - * @param $type - * * @return mixed|string */ protected function propertyToJsopString(Property $property) @@ -1484,9 +1351,6 @@ protected function propertyToJsopString(Property $property) return $property->getValueForStorage(); } - /** - * {@inheritDoc} - */ public function getNamespaces() { $request = $this->getRequest(Request::REPORT, $this->workspaceUri); @@ -1508,9 +1372,6 @@ public function getNamespaces() return $mappings; } - /** - * {@inheritDoc} - */ public function registerNamespace($prefix, $uri) { // seems jackrabbit always expects full list of namespaces @@ -1543,9 +1404,6 @@ public function registerNamespace($prefix, $uri) $request->execute(); } - /** - * {@inheritDoc} - */ public function unregisterNamespace($prefix) { throw new UnsupportedRepositoryOperationException('Unregistering namespace not supported by jackrabbit backend'); @@ -1560,9 +1418,6 @@ public function unregisterNamespace($prefix) */ } - /** - * {@inheritDoc} - */ public function getNodeTypes($nodeTypes = []) { $request = $this->getRequest(Request::REPORT, $this->workspaceUriRoot); @@ -1582,9 +1437,6 @@ public function getNodeTypes($nodeTypes = []) // NodeTypeCndManagementInterface // - /** - * {@inheritDoc} - */ public function registerNodeTypesCnd($cnd, $allowUpdate) { $request = $this->getRequest(Request::PROPPATCH, $this->workspaceUri); @@ -1596,9 +1448,6 @@ public function registerNodeTypesCnd($cnd, $allowUpdate) // PermissionInterface // - /** - * {@inheritDoc} - */ public function getPermissions($path) { // TODO: OPTIMIZE - once we have ACL this might be done without any server request @@ -1634,9 +1483,6 @@ public function getPermissions($path) return $result; } - /** - * {@inheritDoc} - */ public function lockNode($absPath, $isDeep, $isSessionScoped, $timeoutHint = PHP_INT_MAX, $ownerInfo = null) { $timeout = PHP_INT_MAX === $timeoutHint ? 'infinite' : $timeoutHint; @@ -1662,9 +1508,6 @@ public function lockNode($absPath, $isDeep, $isSessionScoped, $timeoutHint = PHP return $this->generateLockFromDavResponse($dom, true, $absPath); } - /** - * {@inheritDoc} - */ public function isLocked($absPath) { $request = $this->getRequest(Request::PROPFIND, $absPath); @@ -1677,9 +1520,6 @@ public function isLocked($absPath) return $lockInfo->childNodes->length > 0; } - /** - * {@inheritDoc} - */ public function unlock($absPath, $lockToken) { $request = $this->getRequest(Request::UNLOCK, $absPath); @@ -1687,9 +1527,6 @@ public function unlock($absPath, $lockToken) $request->execute(); } - /** - * {@inheritDoc} - */ public function getEvents($date, EventFilterInterface $filter, SessionInterface $session) { return $this->factory->get('Jackalope\Transport\Jackrabbit\EventBuffer', [ @@ -1701,9 +1538,6 @@ public function getEvents($date, EventFilterInterface $filter, SessionInterface ]); } - /** - * {@inheritDoc} - */ public function fetchEventData($date) { $path = $this->workspaceUri.self::JCR_JOURNAL_PATH; @@ -1711,7 +1545,7 @@ public function fetchEventData($date) $request->addHeader(sprintf('If-None-Match: "%s"', base_convert($date, 10, 16))); $curl = $request->execute(true); // create new DOMDocument and load the response text. - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->loadXML($curl->getResponse()); $next = base_convert(trim($curl->getHeader('ETag'), '"'), 16, 10); @@ -1727,25 +1561,16 @@ public function fetchEventData($date) ]; } - /** - * {@inheritDoc} - */ public function setUserData($userData) { $this->userData = $userData; } - /** - * {@inheritDoc} - */ public function getUserData() { return $this->userData; } - /** - * {@inheritDoc} - */ public function createWorkspace($name, $srcWorkspace = null) { if (null != $srcWorkspace) { @@ -1769,9 +1594,6 @@ public function createWorkspace($name, $srcWorkspace = null) $request->execute(); } - /** - * {@inheritDoc} - */ public function deleteWorkspace($name) { // https://issues.apache.org/jira/browse/JCR-3144 @@ -1819,8 +1641,6 @@ protected function buildRegisterNamespaceRequest($mappings) /** * Returns the XML required to request nodetypes. * - * @param array $nodesType the list of nodetypes you want to request for - * * @return string XML with the request information */ protected function buildNodeTypesRequest(array $nodeTypes) @@ -1891,9 +1711,6 @@ protected function buildLocateRequest($uuid) ''; } - /** - * {@inheritDoc} - */ public function setNodeTypeManager($nodeTypeManager) { $this->nodeTypeManager = $nodeTypeManager; @@ -2068,7 +1885,7 @@ protected function getRequiredDomElementByTagNameNS($dom, $namespace, $element, * @return int the expire timestamp to be used with Lock::setExpireTime, * that is when this lock expires in seconds since 1970 or null for inifinite * - * @throws InvalidArgumentException if the timeout value can not be parsed + * @throws \InvalidArgumentException if the timeout value can not be parsed */ protected function parseTimeout($timeoutValue) { @@ -2104,16 +1921,10 @@ protected function setJsopBody($value, $key = ':diff', $type = null) } } - /** - * {@inheritDoc} - */ public function prepareSave() { } - /** - * {@inheritDoc} - */ public function finishSave() { if (count($this->jsopBody) > 0) { @@ -2156,9 +1967,6 @@ public function finishSave() $this->jsopBody = []; } - /** - * {@inheritDoc} - */ public function rollbackSave() { } diff --git a/src/Jackalope/Transport/Jackrabbit/EventBuffer.php b/src/Jackalope/Transport/Jackrabbit/EventBuffer.php index 596c106c..b8a1f81b 100644 --- a/src/Jackalope/Transport/Jackrabbit/EventBuffer.php +++ b/src/Jackalope/Transport/Jackrabbit/EventBuffer.php @@ -2,10 +2,7 @@ namespace Jackalope\Transport\Jackrabbit; -use ArrayIterator; -use DOMDocument; use DOMElement; -use DOMNode; use Jackalope\FactoryInterface; use Jackalope\Observation\Event; use Jackalope\Observation\EventFilter; @@ -39,7 +36,7 @@ class EventBuffer implements \Iterator /** * Buffered events. * - * @var ArrayIterator + * @var \ArrayIterator */ protected $events; @@ -163,7 +160,7 @@ protected function fetchNextPage() * * @return Event[] */ - protected function constructEventJournal(DOMDocument $data) + protected function constructEventJournal(\DOMDocument $data) { $events = []; $entries = $data->getElementsByTagName('entry'); @@ -174,7 +171,7 @@ protected function constructEventJournal(DOMDocument $data) $events = array_merge($events, $moreEvents); } - return new ArrayIterator($events); + return new \ArrayIterator($events); } /** @@ -185,7 +182,7 @@ protected function constructEventJournal(DOMDocument $data) * * @return Event[] */ - protected function extractEvents(DOMElement $entry, $currentUserId) + protected function extractEvents(\DOMElement $entry, $currentUserId) { $events = []; $domEvents = $entry->getElementsByTagName('event'); @@ -261,7 +258,7 @@ protected function extractEvents(DOMElement $entry, $currentUserId) * * @throws RepositoryException */ - protected function extractUserId(DOMElement $entry) + protected function extractUserId(\DOMElement $entry) { $authors = $entry->getElementsByTagName('author'); @@ -271,7 +268,7 @@ protected function extractUserId(DOMElement $entry) $userId = null; foreach ($authors->item(0)->childNodes as $child) { - if ($child instanceof DOMElement) { + if ($child instanceof \DOMElement) { return $child->nodeValue; } } @@ -286,7 +283,7 @@ protected function extractUserId(DOMElement $entry) * * @throws RepositoryException */ - protected function extractEventType(DOMElement $event) + protected function extractEventType(\DOMElement $event) { $list = $event->getElementsByTagName('eventtype'); @@ -297,7 +294,7 @@ protected function extractEventType(DOMElement $event) // Here we cannot simply take the first child as the tag might contain // text fragments (i.e. newlines) that will be returned as DOMText elements. foreach ($list->item(0)->childNodes as $el) { - if ($el instanceof DOMElement) { + if ($el instanceof \DOMElement) { return $this->getEventTypeFromTagName($el->tagName); } } @@ -308,16 +305,16 @@ protected function extractEventType(DOMElement $event) /** * Extract a given DOMElement from the children of another DOMElement. * - * @param DOMElement $event The DOMElement containing the searched tag - * @param string $tagName The name of the searched tag - * @param string $errorMessage The error message when the tag was not - * found or null if the tag is not required + * @param \DOMElement $event The DOMElement containing the searched tag + * @param string $tagName The name of the searched tag + * @param string $errorMessage The error message when the tag was not + * found or null if the tag is not required * - * @return DOMNode + * @return \DOMNode * * @throws RepositoryException */ - protected function getDomElement(DOMElement $event, $tagName, $errorMessage = null) + protected function getDomElement(\DOMElement $event, $tagName, $errorMessage = null) { $list = $event->getElementsByTagName($tagName); @@ -364,7 +361,7 @@ protected function getEventTypeFromTagName($tagName) * * @return string */ - protected function getEventDom(DOMElement $event) + protected function getEventDom(\DOMElement $event) { return $event->ownerDocument->saveXML($event); } diff --git a/src/Jackalope/Transport/Jackrabbit/HTTPErrorException.php b/src/Jackalope/Transport/Jackrabbit/HTTPErrorException.php index 9d2ce84e..485dd8b5 100644 --- a/src/Jackalope/Transport/Jackrabbit/HTTPErrorException.php +++ b/src/Jackalope/Transport/Jackrabbit/HTTPErrorException.php @@ -2,12 +2,10 @@ namespace Jackalope\Transport\Jackrabbit; -use RuntimeException; - /** * @license http://www.apache.org/licenses Apache License Version 2.0, January 2004 * @license http://opensource.org/licenses/MIT MIT License */ -class HTTPErrorException extends RuntimeException +class HTTPErrorException extends \RuntimeException { } diff --git a/src/Jackalope/Transport/Jackrabbit/JackrabbitClientInterface.php b/src/Jackalope/Transport/Jackrabbit/JackrabbitClientInterface.php index 0f2bc751..75b29144 100644 --- a/src/Jackalope/Transport/Jackrabbit/JackrabbitClientInterface.php +++ b/src/Jackalope/Transport/Jackrabbit/JackrabbitClientInterface.php @@ -76,8 +76,6 @@ public function setCheckLoginOnServer($bool); /** * Internal method to fetch event data. * - * @param $date - * * @return array hashmap with 'data' containing unfiltered DOM of xml atom * feed of events, 'nextMillis' is the next timestamp if there are * more events to be found, false otherwise diff --git a/src/Jackalope/Transport/Jackrabbit/LoggingClient.php b/src/Jackalope/Transport/Jackrabbit/LoggingClient.php index c4f6a1a0..40b6dc2f 100644 --- a/src/Jackalope/Transport/Jackrabbit/LoggingClient.php +++ b/src/Jackalope/Transport/Jackrabbit/LoggingClient.php @@ -77,49 +77,31 @@ public function setCheckLoginOnServer($bool) // VersioningInterface // - /** - * {@inheritDoc} - */ public function addVersionLabel($versionPath, $label, $moveLabel) { $this->transport->addVersionLabel($versionPath, $label, $moveLabel); } - /** - * {@inheritDoc} - */ public function removeVersionLabel($versionPath, $label) { $this->transport->removeVersionLabel($versionPath, $label); } - /** - * {@inheritDoc} - */ public function checkinItem($path) { return $this->transport->checkinItem($path); } - /** - * {@inheritDoc} - */ public function checkoutItem($path) { $this->transport->checkoutItem($path); } - /** - * {@inheritDoc} - */ public function restoreItem($removeExisting, $versionPath, $path) { $this->transport->restoreItem($removeExisting, $versionPath, $path); } - /** - * {@inheritDoc} - */ public function removeVersion($versionPath, $versionName) { return $this->transport->removeVersion($versionPath, $versionName); @@ -127,9 +109,6 @@ public function removeVersion($versionPath, $versionName) // QueryTransport // - /** - * {@inheritDoc} - */ public function query(Query $query) { $this->logger->startCall(__FUNCTION__, func_get_args(), ['fetchDepth' => $this->transport->getFetchDepth()]); @@ -139,137 +118,86 @@ public function query(Query $query) return $result; } - /** - * {@inheritDoc} - */ public function getSupportedQueryLanguages() { return $this->transport->getSupportedQueryLanguages(); } - /** - * {@inheritDoc} - */ public function registerNamespace($prefix, $uri) { $this->transport->registerNamespace($prefix, $uri); } - /** - * {@inheritDoc} - */ public function unregisterNamespace($prefix) { $this->transport->unregisterNamespace($prefix); } - /** - * {@inheritDoc} - */ public function registerNodeTypesCnd($cnd, $allowUpdate) { return $this->transport->registerNodeTypesCnd($cnd, $allowUpdate); } - /** - * {@inheritDoc} - */ public function getPermissions($path) { return $this->transport->getPermissions($path); } - /** - * {@inheritDoc} - */ public function lockNode($absPath, $isDeep, $isSessionScoped, $timeoutHint = PHP_INT_MAX, $ownerInfo = null) { return $this->transport->lockNode($absPath, $isDeep, $isSessionScoped, $timeoutHint, $ownerInfo); } - /** - * {@inheritDoc} - */ public function isLocked($absPath) { return $this->transport->isLocked($absPath); } - /** - * {@inheritDoc} - */ public function unlock($absPath, $lockToken) { $this->transport->unlock($absPath, $lockToken); } - /** - * {@inheritDoc} - */ public function getEvents($date, EventFilterInterface $filter, SessionInterface $session) { return $this->transport->getEvents($date, $filter, $session); } - /** - * {@inheritDoc} - */ public function fetchEventData($date) { return $this->transport->fetchEventData($date); } - /** - * {@inheritDoc} - */ public function setUserData($userData) { $this->transport->setUserData($userData); } - /** - * {@inheritDoc} - */ public function getUserData() { return $this->transport->getUserData(); } - /** - * {@inheritDoc} - */ public function createWorkspace($name, $srcWorkspace = null) { $this->transport->createWorkspace($name, $srcWorkspace); } - /** - * {@inheritDoc} - */ public function deleteWorkspace($name) { $this->transport->deleteWorkspace($name); } - /** - * {@inheritDoc} - */ public function forceHttpVersion10($forceHttpVersion10 = true) { $this->transport->forceHttpVersion10($forceHttpVersion10); } - /** - * {@inheritDoc} - */ public function addCurlOptions(array $options) { return $this->transport->addCurlOptions($options); } - /** - * {@inheritDoc} - */ public function getWorkspaceUri() { return $this->transport->getWorkspaceUri(); diff --git a/src/Jackalope/Transport/Jackrabbit/Request.php b/src/Jackalope/Transport/Jackrabbit/Request.php index 2397ac35..8abdf9a3 100644 --- a/src/Jackalope/Transport/Jackrabbit/Request.php +++ b/src/Jackalope/Transport/Jackrabbit/Request.php @@ -610,7 +610,7 @@ protected function handleError(curl $curl, $response, $httpCode) // use XML error response if it's there if ('loadXML($response); $err = $dom->getElementsByTagNameNS(Client::NS_DCR, 'exception'); if ($err->length > 0) { @@ -737,14 +737,14 @@ protected function getLongErrorString($curl, $response) * * @param bool $forceMultiple whether to force parallel requests or not * - * @return DOMDocument the loaded XML response text + * @return \DOMDocument the loaded XML response text */ public function executeDom($forceMultiple = false) { $xml = $this->execute(null, $forceMultiple); // create new DOMDocument and load the response text. - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->loadXML($xml); return $dom; @@ -757,8 +757,6 @@ public function executeDom($forceMultiple = false) * * @param bool $forceMultiple whether to force parallel requests or not * - * @return mixed - * * @throws RepositoryException if the json response is not valid */ public function executeJson($forceMultiple = false) diff --git a/src/Jackalope/Transport/Jackrabbit/curl.php b/src/Jackalope/Transport/Jackrabbit/curl.php index 4f6c4d23..fd922e64 100644 --- a/src/Jackalope/Transport/Jackrabbit/curl.php +++ b/src/Jackalope/Transport/Jackrabbit/curl.php @@ -50,8 +50,7 @@ public function __construct($url = null) /** * Sets the options to be used for the request. * - * @param int $option - * @param mixed $value + * @param int $option * * @see curl_setopt */ diff --git a/tests/ImplementationLoader.php b/tests/ImplementationLoader.php index f3c60414..699e4f67 100644 --- a/tests/ImplementationLoader.php +++ b/tests/ImplementationLoader.php @@ -5,7 +5,7 @@ */ class ImplementationLoader extends \PHPCR\Test\AbstractLoader { - private static $instance = null; + private static $instance; private $necessaryConfigValues = ['jackrabbit.uri', 'phpcr.user', 'phpcr.pass', 'phpcr.workspace', 'phpcr.additionalWorkspace', 'phpcr.defaultWorkspace']; diff --git a/tests/Jackalope/Transport/Jackrabbit/ClientTest.php b/tests/Jackalope/Transport/Jackrabbit/ClientTest.php index 530af8d3..ac754bed 100644 --- a/tests/Jackalope/Transport/Jackrabbit/ClientTest.php +++ b/tests/Jackalope/Transport/Jackrabbit/ClientTest.php @@ -2,7 +2,6 @@ namespace Jackalope\Transport\Jackrabbit; -use DOMDocument; use Jackalope\Factory; use Jackalope\Node; use Jackalope\NodeType\NodeTypeManager; @@ -110,7 +109,7 @@ public function testBuildReportRequest(): void */ public function testGetRepositoryDescriptorsEmptyBackendResponse(): void { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/empty.xml'); $t = $this->getTransportMock(); $request = $this->getRequestMock($dom, ['setBody']); @@ -127,7 +126,7 @@ public function testGetRepositoryDescriptorsEmptyBackendResponse(): void public function testGetRepositoryDescriptors(): void { $reportRequest = $this->getTransportMock()->buildReportRequestMock('dcr:repositorydescriptors'); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/repositoryDescriptors.xml'); $t = $this->getTransportMock(); $request = $this->getRequestMock($dom, ['setBody']); @@ -218,7 +217,7 @@ public function testLoginUnsportedCredentials(): void */ public function testLoginEmptyBackendResponse(): void { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/empty.xml'); $t = $this->getTransportMock(); $request = $this->getRequestMock($dom, ['setBody']); @@ -234,7 +233,7 @@ public function testLoginEmptyBackendResponse(): void */ public function testLoginWrongWorkspace(): void { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/wrongWorkspace.xml'); $t = $this->getTransportMock(); $request = $this->getRequestMock($dom, ['setBody']); @@ -251,7 +250,7 @@ public function testLoginWrongWorkspace(): void public function testLogin(): void { $propfindRequest = $this->getTransportMock()->buildPropfindRequestMock(['D:workspace', 'dcr:workspaceName']); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/loginResponse.xml'); $t = $this->getTransportMock(); @@ -333,7 +332,7 @@ public function testBuildLocateRequestMock(): void */ public function testGetNamespacesEmptyResponse(): void { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/empty.xml'); $t = $this->getTransportMock($this->config['url']); @@ -352,7 +351,7 @@ public function testGetNamespacesEmptyResponse(): void public function testGetNamespaces(): void { $reportRequest = $this->getTransportMock()->buildReportRequestMock('dcr:registerednamespaces'); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/registeredNamespaces.xml'); $t = $this->getTransportMock($this->config['url']); @@ -376,7 +375,7 @@ public function testGetNamespaces(): void /** START TESTING NODE TYPES **/ protected function setUpNodeTypeMock($params, $fixture) { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load($fixture); $requestStr = $this->getTransportMock()->buildNodeTypesRequestMock($params); @@ -456,7 +455,7 @@ public function testEmptyGetNodeTypes(): void */ public function testGetAccessibleWorkspaceNames(): void { - $dom = new DOMDocument(); + $dom = new \DOMDocument(); $dom->load(__DIR__.'/../../../fixtures/accessibleWorkspaces.xml'); $t = $this->getTransportMock('testuri'); diff --git a/tests/Jackalope/Transport/Jackrabbit/RequestTest.php b/tests/Jackalope/Transport/Jackrabbit/RequestTest.php index 3e086c3f..4a4adf4e 100644 --- a/tests/Jackalope/Transport/Jackrabbit/RequestTest.php +++ b/tests/Jackalope/Transport/Jackrabbit/RequestTest.php @@ -2,7 +2,6 @@ namespace Jackalope\Transport\Jackrabbit; -use DOMDocument; use Jackalope\Factory; use Jackalope\Test\JackrabbitTestCase; use PHPCR\SimpleCredentials; @@ -64,7 +63,7 @@ public function testExecuteDom() ->method('execute') ->willReturn(''); - $this->assertInstanceOf(DOMDocument::class, $request->executeDom()); + $this->assertInstanceOf(\DOMDocument::class, $request->executeDom()); } /**