diff --git a/CHANGELOG.md b/CHANGELOG.md
index a2434b6a..cfbbc4a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,11 @@ Changelog
Version 1
=========
+2.0.0 (unreleased)
+------------------
+
+* Renamed cli-config.php.dist to cli-config.dist.php and cleaned up to be better documented.
+
1.4.4
-----
diff --git a/cli-config.dist.php b/cli-config.dist.php
new file mode 100644
index 00000000..f8629a84
--- /dev/null
+++ b/cli-config.dist.php
@@ -0,0 +1,56 @@
+getRepository([
+ "jackalope.jackrabbit_uri" => $jackrabbitUrl,
+ ]);
+}
+
+/* Only create a session if this is not about the jackrabbit server startup command */
+if (!array_key_exists(1, $argv[1])) {
+ return;
+}
+if(!in_array($argv[1], ['jackalope:run:jackrabbit', 'list', 'help'], true)) {
+ $repository = bootstrapJackrabbit();
+ $credentials = new SimpleCredentials($user, $pass);
+ $session = $repository->login($credentials, $workspace);
+
+ $helperSet = new HelperSet(array(
+ 'phpcr' => new PhpcrHelper($session),
+ 'phpcr_console_dumper' => new PhpcrConsoleDumperHelper(),
+ ));
+ if (class_exists(QuestionHelper::class)) {
+ $helperSet->set(new QuestionHelper(), 'question');
+ } else {
+ // legacy support for old Symfony versions
+ $helperSet->set(new DialogHelper(), 'dialog');
+ }
+}
diff --git a/cli-config.php.dist b/cli-config.php.dist
deleted file mode 100644
index fd7cec04..00000000
--- a/cli-config.php.dist
+++ /dev/null
@@ -1,40 +0,0 @@
-getRepository(array("jackalope.jackrabbit_uri" => $jackrabbit_url));
-}
-
-$repository = bootstrapJackrabbit();
-
-$credentials = new \PHPCR\SimpleCredentials($user, $pass);
-
-/* only create a session if this is not about the server control command */
-if (isset($argv[1])
- && $argv[1] != 'jackalope:run:jackrabbit'
- && $argv[1] != 'list'
- && $argv[1] != 'help'
-) {
- $session = $repository->login($credentials, $workspace);
-
- $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
- 'dialog' => new \Symfony\Component\Console\Helper\DialogHelper(),
- 'phpcr' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session),
- 'phpcr_console_dumper' => new \PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper(),
- ));
-}
diff --git a/src/Jackalope/Transport/Jackrabbit/Client.php b/src/Jackalope/Transport/Jackrabbit/Client.php
index 40827ed4..ac11cfed 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;
@@ -340,7 +336,7 @@ 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;
@@ -699,7 +695,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");
}
@@ -969,9 +965,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) {
@@ -1028,12 +1024,12 @@ 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
+ * @param string $attribute the attribute name
*
* @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) {
@@ -1242,10 +1238,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)
@@ -1711,7 +1703,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);
@@ -2068,7 +2060,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)
{
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/Request.php b/src/Jackalope/Transport/Jackrabbit/Request.php
index 2397ac35..75c3d9fc 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 ('' === substr($response, 0, 2)) {
- $dom = new DOMDocument();
+ $dom = new \DOMDocument();
$dom->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;
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());
}
/**