Skip to content

Commit e1f0cdd

Browse files
committed
fix phpdoc and some bugs
1 parent 206f8cd commit e1f0cdd

19 files changed

+137
-113
lines changed

src/PHPCR/Shell/Console/.gitignore

-1
This file was deleted.
Binary file not shown.

src/PHPCR/Shell/Console/Command/BaseCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function setContainer(ContainerInterface $container = null): void
2828
$this->container = $container;
2929
}
3030

31-
protected function get($serviceId)
31+
public function get($serviceId)
3232
{
3333
if (null === $this->container) {
3434
throw new \RuntimeException(

src/PHPCR/Shell/DependencyInjection/Container.php

+59-30
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,35 @@
1515
use PHPCR\Shell\PhpcrShell;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use PHPCR\Shell\Transport\Transport\DoctrineDbal;
19+
use PHPCR\Shell\Transport\Transport\Jackrabbit;
20+
use PHPCR\Shell\Transport\Transport\JackalopeFs;
21+
use PHPCR\Shell\Query\UpdateProcessor;
22+
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
23+
use PHPCR\Shell\Console\Input\AutoComplete;
24+
use PHPCR\Shell\Console\Application\EmbeddedApplication;
25+
use PHPCR\Shell\Console\Application\ShellApplication;
26+
use Symfony\Component\EventDispatcher\EventDispatcher;
27+
use PHPCR\Shell\Subscriber\ExceptionSubscriber;
28+
use PHPCR\Shell\Subscriber\AliasSubscriber;
29+
use PHPCR\Shell\Subscriber\ConfigInitSubscriber;
30+
use PHPCR\Shell\Subscriber\ProfileWriterSubscriber;
31+
use PHPCR\Shell\Subscriber\ProfileLoaderSubscriber;
32+
use PHPCR\Shell\Subscriber\ProfileFromSessionInputSubscriber;
33+
use DTL\Glob\GlobHelper;
34+
use PHPCR\Shell\Phpcr\SessionManager;
35+
use PHPCR\Shell\Transport\TransportRegistry;
36+
use PHPCR\Shell\Config\Config;
37+
use PHPCR\Shell\Config\ProfileLoader;
38+
use PHPCR\Shell\Config\Profile;
39+
use PHPCR\Shell\Config\ConfigManager;
40+
use PHPCR\Shell\Console\Helper\ResultFormatterHelper;
41+
use PHPCR\Shell\Console\Helper\NodeHelper;
42+
use PHPCR\Shell\Console\Helper\TextHelper;
43+
use PHPCR\Shell\Console\Helper\RepositoryHelper;
44+
use PHPCR\Shell\Console\Helper\PathHelper;
45+
use PHPCR\Shell\Console\Helper\EditorHelper;
46+
use Symfony\Component\Console\Helper\QuestionHelper;
1847

1948
class Container extends ContainerBuilder
2049
{
@@ -24,9 +53,9 @@ class Container extends ContainerBuilder
2453
* @var array Transports
2554
*/
2655
protected $transports = [
27-
'transport.transport.doctrinedbal' => 'PHPCR\Shell\Transport\Transport\DoctrineDbal',
28-
'transport.transport.jackrabbit' => 'PHPCR\Shell\Transport\Transport\Jackrabbit',
29-
'transport.transport.fs' => 'PHPCR\Shell\Transport\Transport\JackalopeFs',
56+
'transport.transport.doctrinedbal' => DoctrineDbal::class,
57+
'transport.transport.jackrabbit' => Jackrabbit::class,
58+
'transport.transport.fs' => JackalopeFs::class,
3059
];
3160

3261
public function __construct($mode = PhpcrShell::MODE_STANDALONE)
@@ -46,27 +75,27 @@ public function __construct($mode = PhpcrShell::MODE_STANDALONE)
4675

4776
public function registerHelpers()
4877
{
49-
$this->register('helper.question', 'Symfony\Component\Console\Helper\QuestionHelper');
50-
$this->register('helper.editor', 'PHPCR\Shell\Console\Helper\EditorHelper');
51-
$this->register('helper.path', 'PHPCR\Shell\Console\Helper\PathHelper');
52-
$this->register('helper.repository', 'PHPCR\Shell\Console\Helper\RepositoryHelper')
78+
$this->register('helper.question', QuestionHelper::class);
79+
$this->register('helper.editor', EditorHelper::class);
80+
$this->register('helper.path', PathHelper::class);
81+
$this->register('helper.repository', RepositoryHelper::class)
5382
->addArgument(new Reference('phpcr.session_manager'));
54-
$this->register('helper.text', 'PHPCR\Shell\Console\Helper\TextHelper');
55-
$this->register('helper.node', 'PHPCR\Shell\Console\Helper\NodeHelper');
56-
$this->register('helper.result_formatter', 'PHPCR\Shell\Console\Helper\ResultFormatterHelper')
83+
$this->register('helper.text', TextHelper::class);
84+
$this->register('helper.node', NodeHelper::class);
85+
$this->register('helper.result_formatter', ResultFormatterHelper::class)
5786
->addArgument(new Reference('helper.text'))
5887
->addArgument(new Reference('config.config.phpcrsh'));
5988
}
6089

6190
public function registerConfig()
6291
{
63-
$this->register('config.manager', 'PHPCR\Shell\Config\ConfigManager')
92+
$this->register('config.manager', ConfigManager::class)
6493
->addArgument(new Reference('helper.question'));
6594

66-
$this->register('config.profile', 'PHPCR\Shell\Config\Profile');
67-
$this->register('config.profile_loader', 'PHPCR\Shell\Config\ProfileLoader')
95+
$this->register('config.profile', Profile::class);
96+
$this->register('config.profile_loader', ProfileLoader::class)
6897
->addArgument(new Reference('config.manager'));
69-
$this->register('config.config.phpcrsh', 'PHPCR\Shell\Config\Config')
98+
$this->register('config.config.phpcrsh', Config::class)
7099
->setFactory([new Reference('config.manager'), 'getPhpcrshConfig']);
71100
}
72101

@@ -77,17 +106,17 @@ public function registerPhpcr()
77106
$this->register($id, $class)->addArgument(new Reference('config.profile'));
78107
}
79108

80-
$registry = $this->register('phpcr.transport_registry', 'PHPCR\Shell\Transport\TransportRegistry');
109+
$registry = $this->register('phpcr.transport_registry', TransportRegistry::class);
81110

82111
foreach (array_keys($this->transports) as $transportId) {
83112
$registry->addMethodCall('register', [new Reference($transportId)]);
84113
}
85114

86-
$this->register('phpcr.session_manager.active', 'PHPCR\Shell\Phpcr\SessionManager')
115+
$this->register('phpcr.session_manager.active', SessionManager::class)
87116
->addArgument(new Reference('phpcr.transport_registry'))
88117
->addArgument(new Reference('config.profile'));
89118

90-
$this->register('phpcr.session_manager.passive', 'PHPCR\Shell\Phpcr\SessionManager')
119+
$this->register('phpcr.session_manager.passive', SessionManager::class)
91120
->addArgument(new Reference('phpcr.transport_registry'))
92121
->addArgument(new Reference('config.profile'));
93122

@@ -99,54 +128,54 @@ public function registerPhpcr()
99128
$repositoryDefinition->setFactory([new Reference('phpcr.session_manager'), 'getRepository']);
100129
$sessionDefinition->setFactory([new Reference('phpcr.session_manager'), 'getSession']);
101130

102-
$this->register('dtl.glob.helper', 'DTL\Glob\GlobHelper');
131+
$this->register('dtl.glob.helper', GlobHelper::class);
103132
}
104133

105134
public function registerEvent()
106135
{
107136
if ($this->mode === PhpcrShell::MODE_STANDALONE) {
108137
$this->register(
109138
'event.subscriber.profile_from_session_input',
110-
'PHPCR\Shell\Subscriber\ProfileFromSessionInputSubscriber'
139+
ProfileFromSessionInputSubscriber::class
111140
)->addTag('event.subscriber');
112141

113142
$this->register(
114143
'event.subscriber.profile_loader',
115-
'PHPCR\Shell\Subscriber\ProfileLoaderSubscriber'
144+
ProfileLoaderSubscriber::class
116145
)
117146
->addArgument(new Reference('config.profile_loader'))
118147
->addArgument(new Reference('helper.question'))
119148
->addTag('event.subscriber');
120149

121150
$this->register(
122151
'event.subscriber.profile_writer',
123-
'PHPCR\Shell\Subscriber\ProfileWriterSubscriber'
152+
ProfileWriterSubscriber::class
124153
)
125154
->addArgument(new Reference('config.profile_loader'))
126155
->addArgument(new Reference('helper.question'))
127156
->addTag('event.subscriber');
128157

129158
$this->register(
130159
'event.subscriber.config_init',
131-
'PHPCR\Shell\Subscriber\ConfigInitSubscriber'
160+
ConfigInitSubscriber::class
132161
)
133162
->addArgument(new Reference('config.manager'))
134163
->addTag('event.subscriber');
135164
}
136165

137166
$this->register(
138167
'event.subscriber.alias',
139-
'PHPCR\Shell\Subscriber\AliasSubscriber'
168+
AliasSubscriber::class
140169
)
141170
->addArgument(new Reference('config.manager'))
142171
->addTag('event.subscriber');
143172

144173
$this->register(
145174
'event.subscriber.exception',
146-
'PHPCR\Shell\Subscriber\ExceptionSubscriber'
175+
ExceptionSubscriber::class
147176
)->addTag('event.subscriber');
148177

149-
$dispatcher = $this->register('event.dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher');
178+
$dispatcher = $this->register('event.dispatcher', EventDispatcher::class);
150179

151180
foreach (array_keys($this->findTaggedServiceIds('event.subscriber')) as $id) {
152181
$dispatcher->addMethodCall('addSubscriber', [new Reference($id)]);
@@ -156,22 +185,22 @@ public function registerEvent()
156185
public function registerConsole()
157186
{
158187
if ($this->mode === PhpcrShell::MODE_STANDALONE) {
159-
$this->register('application', 'PHPCR\Shell\Console\Application\ShellApplication')
188+
$this->register('application', ShellApplication::class)
160189
->addArgument(new Reference('container'));
161190
} else {
162-
$this->register('application', 'PHPCR\Shell\Console\Application\EmbeddedApplication')
191+
$this->register('application', EmbeddedApplication::class)
163192
->addArgument(new Reference('container'));
164193
}
165194

166-
$this->register('console.input.autocomplete', 'PHPCR\Shell\Console\Input\AutoComplete')
195+
$this->register('console.input.autocomplete', AutoComplete::class)
167196
->addArgument(new Reference('application'))
168197
->addArgument(new Reference('phpcr.session'));
169198
}
170199

171200
public function registerQuery()
172201
{
173-
$this->register('query.update.expression_language', 'Symfony\Component\ExpressionLanguage\ExpressionLanguage');
174-
$this->register('query.update.processor', 'PHPCR\Shell\Query\UpdateProcessor')
202+
$this->register('query.update.expression_language', ExpressionLanguage::class);
203+
$this->register('query.update.processor', UpdateProcessor::class)
175204
->addArgument(new Reference('query.update.expression_language'));
176205
}
177206

src/PHPCR/Shell/Event/Event.php

+2-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,8 @@
22

33
namespace PHPCR\Shell\Event;
44

5-
use Symfony\Component\EventDispatcher\Event as OldEvent;
65
use Symfony\Contracts\EventDispatcher\Event as ContractEvent;
76

8-
if (class_exists(ContractEvent::class)) {
9-
class Event extends ContractEvent
10-
{
11-
}
12-
} else {
13-
class Event extends OldEvent
14-
{
15-
}
7+
class Event extends ContractEvent
8+
{
169
}

src/PHPCR/Shell/Phpcr/PhpcrSession.php

+38-40
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
use DTL\Glob\Finder\PhpcrTraversalFinder;
1616
use PHPCR\CredentialsInterface;
17+
use PHPCR\ItemNotFoundException;
18+
use PHPCR\NodeInterface;
1719
use PHPCR\PathNotFoundException;
1820
use PHPCR\SessionInterface;
1921
use PHPCR\Util\UUIDHelper;
@@ -93,16 +95,14 @@ public function chdir($path)
9395
$newPath = $node->getPath();
9496
} else {
9597
// absolute path
96-
if (substr($path, 0, 1) == '/') {
98+
if (str_starts_with($path, '/')) {
9799
$newPath = $path;
98-
} elseif ($path == '..') {
100+
} elseif ($path === '..') {
99101
$newPath = dirname($cwd);
102+
} else if ($this->cwd === '/') {
103+
$newPath = sprintf('/%s', $path);
100104
} else {
101-
if ($this->cwd == '/') {
102-
$newPath = sprintf('/%s', $path);
103-
} else {
104-
$newPath = sprintf('%s/%s', $cwd, $path);
105-
}
105+
$newPath = sprintf('%s/%s', $cwd, $path);
106106
}
107107

108108
if ($newPath !== '/') {
@@ -238,54 +238,54 @@ public function getNodesByIdentifier($ids)
238238
return $this->session->getNodesByIdentifier($ids);
239239
}
240240

241-
public function getItem($path)
241+
public function getItem($absPath)
242242
{
243-
return $this->session->getItem($this->getAbsPath($path));
243+
return $this->session->getItem($this->getAbsPath($absPath));
244244
}
245245

246-
public function getNode($path, $depthHint = -1)
246+
public function getNode($absPath, $depthHint = -1)
247247
{
248-
return $this->session->getNode($this->getAbsPath($path), $depthHint);
248+
return $this->session->getNode($this->getAbsPath($absPath), $depthHint);
249249
}
250250

251-
public function getNodes($paths)
251+
public function getNodes($absPaths)
252252
{
253-
return $this->session->getNodes($this->getAbsPaths($paths));
253+
return $this->session->getNodes($this->getAbsPaths($absPaths));
254254
}
255255

256-
public function getProperty($path)
256+
public function getProperty($absPath)
257257
{
258-
return $this->session->getProperty($this->getAbsPath($path));
258+
return $this->session->getProperty($this->getAbsPath($absPath));
259259
}
260260

261-
public function getProperties($paths)
261+
public function getProperties($absPaths)
262262
{
263-
return $this->session->getProperties($this->getAbsPaths($paths));
263+
return $this->session->getProperties($this->getAbsPaths($absPaths));
264264
}
265265

266-
public function itemExists($path)
266+
public function itemExists($absPath)
267267
{
268-
return $this->session->itemExists($this->getAbsPath($path));
268+
return $this->session->itemExists($this->getAbsPath($absPath));
269269
}
270270

271-
public function nodeExists($path)
271+
public function nodeExists($absPath)
272272
{
273-
return $this->session->nodeExists($this->getAbsPath($path));
273+
return $this->session->nodeExists($this->getAbsPath($absPath));
274274
}
275275

276-
public function propertyExists($path)
276+
public function propertyExists($absPath)
277277
{
278-
return $this->session->propertyExists($this->getAbsPath($path));
278+
return $this->session->propertyExists($this->getAbsPath($absPath));
279279
}
280280

281-
public function move($srcPath, $destPath)
281+
public function move($srcAbsPath, $destAbsPath)
282282
{
283-
return $this->session->move($this->getAbsPath($srcPath), $this->getAbsTargetPath($srcPath, $destPath));
283+
return $this->session->move($this->getAbsPath($srcAbsPath), $this->getAbsTargetPath($srcAbsPath, $destAbsPath));
284284
}
285285

286-
public function removeItem($path)
286+
public function removeItem($absPath)
287287
{
288-
return $this->session->removeItem($this->getAbsPath($path));
288+
return $this->session->removeItem($this->getAbsPath($absPath));
289289
}
290290

291291
public function save()
@@ -303,34 +303,34 @@ public function hasPendingChanges()
303303
return $this->session->hasPendingChanges();
304304
}
305305

306-
public function hasPermission($path, $actions)
306+
public function hasPermission($absPath, $actions)
307307
{
308-
return $this->session->hasPermission($this->getAbsPath($path), $actions);
308+
return $this->session->hasPermission($this->getAbsPath($absPath), $actions);
309309
}
310310

311-
public function checkPermission($path, $actions)
311+
public function checkPermission($absPath, $actions)
312312
{
313-
return $this->session->checkPermission($this->getAbsPath($path), $actions);
313+
return $this->session->checkPermission($this->getAbsPath($absPath), $actions);
314314
}
315315

316-
public function hasCapability($methodNames, $target, array $arguments)
316+
public function hasCapability($methodName, $target, array $arguments)
317317
{
318-
return $this->session->hasCapability($methodNames, $target, $arguments);
318+
return $this->session->hasCapability($methodName, $target, $arguments);
319319
}
320320

321321
public function importXML($parentAbsPath, $uri, $uuidBehavior)
322322
{
323323
return $this->session->importXML($this->getAbsPath($parentAbsPath), $uri, $uuidBehavior);
324324
}
325325

326-
public function exportSystemView($path, $stream, $skipBinary, $noRecurse)
326+
public function exportSystemView($absPath, $stream, $skipBinary, $noRecurse)
327327
{
328-
return $this->session->exportSystemView($this->getAbsPath($path), $stream, $skipBinary, $noRecurse);
328+
return $this->session->exportSystemView($this->getAbsPath($absPath), $stream, $skipBinary, $noRecurse);
329329
}
330330

331-
public function exportDocumentView($path, $stream, $skipBinary, $noRecurse)
331+
public function exportDocumentView($absPath, $stream, $skipBinary, $noRecurse)
332332
{
333-
return $this->session->exportDocumentView($this->getAbsPath($path), $stream, $skipBinary, $noRecurse);
333+
return $this->session->exportDocumentView($this->getAbsPath($absPath), $stream, $skipBinary, $noRecurse);
334334
}
335335

336336
public function setNamespacePrefix($prefix, $uri)
@@ -379,8 +379,6 @@ public function findNodes($patternOrId)
379379
return $this->getNodeByIdentifier($patternOrId);
380380
}
381381

382-
$res = $this->finder->find($this->getAbsPath($patternOrId));
383-
384-
return $res;
382+
return $this->finder->find($this->getAbsPath($patternOrId));
385383
}
386384
}

0 commit comments

Comments
 (0)