Skip to content

Commit 8e30712

Browse files
authored
Merge pull request #219 from phpcr/doc-tweaks
more phpdoc cleanup
2 parents 4ee2510 + 09fa1a7 commit 8e30712

24 files changed

+106
-261
lines changed

src/PHPCR/Util/CND/Parser/AbstractParser.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
*/
2424
abstract class AbstractParser
2525
{
26-
/**
27-
* The token queue.
28-
*/
2926
protected TokenQueue $tokenQueue;
3027

3128
/**
@@ -105,7 +102,7 @@ protected function expectToken(int $type, string $data = null): Token
105102
* @param int $type The expected token type
106103
* @param string|null $data The expected token data or null
107104
*/
108-
protected function checkAndExpectToken(int $type, string $data = null): bool|Token
105+
protected function checkAndExpectToken(int $type, string $data = null): false|Token
109106
{
110107
if ($this->checkToken($type, $data)) {
111108
$token = $this->tokenQueue->peek();

src/PHPCR/Util/CND/Parser/CndParser.php

+20-23
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ final class CndParser extends AbstractParser
6868
/**
6969
* @var string[]
7070
*/
71-
protected array $namespaces = [];
71+
private array $namespaces = [];
7272

7373
/**
7474
* @var string[]
7575
*/
76-
protected array $nodeTypes = [];
76+
private array $nodeTypes = [];
7777

7878
public function __construct(NodeTypeManagerInterface $ntm)
7979
{
@@ -142,7 +142,7 @@ private function parse(ReaderInterface $reader): array
142142
* Prefix ::= String
143143
* Uri ::= String
144144
*/
145-
protected function parseNamespaceMapping(): void
145+
private function parseNamespaceMapping(): void
146146
{
147147
$this->expectToken(Token::TK_SYMBOL, '<');
148148
$prefix = $this->parseCndString();
@@ -162,7 +162,7 @@ protected function parseNamespaceMapping(): void
162162
* [NodeTypeAttribute {NodeTypeAttribute}]
163163
* {PropertyDef | ChildNodeDef}
164164
*/
165-
protected function parseNodeType(): void
165+
private function parseNodeType(): void
166166
{
167167
$nodeType = $this->ntm->createNodeTypeTemplate();
168168
$this->parseNodeTypeName($nodeType);
@@ -183,7 +183,7 @@ protected function parseNodeType(): void
183183
*
184184
* NodeTypeName ::= '[' String ']'
185185
*/
186-
protected function parseNodeTypeName(NodeTypeTemplateInterface $nodeType): void
186+
private function parseNodeTypeName(NodeTypeTemplateInterface $nodeType): void
187187
{
188188
$this->expectToken(Token::TK_SYMBOL, '[');
189189
$name = $this->parseCndString();
@@ -200,7 +200,7 @@ protected function parseNodeTypeName(NodeTypeTemplateInterface $nodeType): void
200200
*
201201
* Supertypes ::= '>' (StringList | '?')
202202
*/
203-
protected function parseSupertypes(NodeTypeTemplateInterface $nodeType): void
203+
private function parseSupertypes(NodeTypeTemplateInterface $nodeType): void
204204
{
205205
$this->expectToken(Token::TK_SYMBOL, '>');
206206

@@ -243,7 +243,7 @@ protected function parseSupertypes(NodeTypeTemplateInterface $nodeType): void
243243
* Query ::= ('noquery' | 'nq') | ('query' | 'q' )
244244
* PrimaryItem ::= ('primaryitem'| '!')(String | '?')
245245
*/
246-
protected function parseNodeTypeAttributes(NodeTypeTemplateInterface $nodeType): void
246+
private function parseNodeTypeAttributes(NodeTypeTemplateInterface $nodeType): void
247247
{
248248
while (true) {
249249
if ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->ORDERABLE)) {
@@ -284,7 +284,7 @@ protected function parseNodeTypeAttributes(NodeTypeTemplateInterface $nodeType):
284284
*
285285
* {PropertyDef | ChildNodeDef}
286286
*/
287-
protected function parseChildrenAndAttributes(NodeTypeTemplateInterface $nodeType): void
287+
private function parseChildrenAndAttributes(NodeTypeTemplateInterface $nodeType): void
288288
{
289289
while (true) {
290290
if ($this->checkToken(Token::TK_SYMBOL, '-')) {
@@ -310,7 +310,7 @@ protected function parseChildrenAndAttributes(NodeTypeTemplateInterface $nodeTyp
310310
* [ValueConstraints]
311311
* PropertyName ::= '-' String
312312
*/
313-
protected function parsePropDef(NodeTypeTemplateInterface $nodeType): void
313+
private function parsePropDef(NodeTypeTemplateInterface $nodeType): void
314314
{
315315
$this->expectToken(Token::TK_SYMBOL, '-');
316316

@@ -364,7 +364,7 @@ protected function parsePropDef(NodeTypeTemplateInterface $nodeType): void
364364
* 'DECIMAL' | 'URI' | 'UNDEFINED' | '*' |
365365
* '?') ')'
366366
*/
367-
protected function parsePropertyType(PropertyDefinitionTemplateInterface $property): void
367+
private function parsePropertyType(PropertyDefinitionTemplateInterface $property): void
368368
{
369369
$types = ['STRING', 'BINARY', 'LONG', 'DOUBLE', 'BOOLEAN', 'DATE', 'NAME', 'PATH',
370370
'REFERENCE', 'WEAKREFERENCE', 'DECIMAL', 'URI', 'UNDEFINED', '*', '?', ];
@@ -388,7 +388,7 @@ protected function parsePropertyType(PropertyDefinitionTemplateInterface $proper
388388
*
389389
* DefaultValues ::= '=' (StringList | '?')
390390
*/
391-
protected function parseDefaultValue(PropertyDefinitionTemplateInterface $property): void
391+
private function parseDefaultValue(PropertyDefinitionTemplateInterface $property): void
392392
{
393393
if ($this->checkAndExpectToken(Token::TK_SYMBOL, '?')) {
394394
$list = ['?'];
@@ -406,7 +406,7 @@ protected function parseDefaultValue(PropertyDefinitionTemplateInterface $proper
406406
*
407407
* ValueConstraints ::= '<' (StringList | '?')
408408
*/
409-
protected function parseValueConstraints(PropertyDefinitionTemplateInterface $property): void
409+
private function parseValueConstraints(PropertyDefinitionTemplateInterface $property): void
410410
{
411411
$this->expectToken(Token::TK_SYMBOL, '<');
412412

@@ -473,7 +473,7 @@ protected function parseValueConstraints(PropertyDefinitionTemplateInterface $pr
473473
* NoFullText ::= ('nofulltext' | 'nof') ['?']
474474
* NoQueryOrder ::= ('noqueryorder' | 'nqord') ['?']
475475
*/
476-
protected function parsePropertyAttributes(NodeTypeTemplateInterface $parentType, PropertyDefinitionTemplateInterface $property): void
476+
private function parsePropertyAttributes(NodeTypeTemplateInterface $parentType, PropertyDefinitionTemplateInterface $property): void
477477
{
478478
$opvSeen = false;
479479
while (true) {
@@ -527,7 +527,7 @@ protected function parsePropertyAttributes(NodeTypeTemplateInterface $parentType
527527
* RequiredTypes ::= '(' (StringList | '?') ')'
528528
* DefaultType ::= '=' (String | '?')
529529
*/
530-
protected function parseChildNodeDef(NodeTypeTemplateInterface $nodeType): void
530+
private function parseChildNodeDef(NodeTypeTemplateInterface $nodeType): void
531531
{
532532
$this->expectToken(Token::TK_SYMBOL, '+');
533533
$childType = $this->ntm->createNodeDefinitionTemplate();
@@ -593,7 +593,7 @@ protected function parseChildNodeDef(NodeTypeTemplateInterface $nodeType): void
593593
* 'IGNORE' | 'ABORT' | ('OPV' '?')
594594
* Sns ::= ('sns' | '*') ['?']
595595
*/
596-
protected function parseChildNodeAttributes(
596+
private function parseChildNodeAttributes(
597597
NodeTypeTemplateInterface $parentType,
598598
NodeDefinitionTemplateInterface $childType
599599
): void {
@@ -627,7 +627,7 @@ protected function parseChildNodeAttributes(
627627
*
628628
* @return string[]
629629
*/
630-
protected function parseCndStringList(): array
630+
private function parseCndStringList(): array
631631
{
632632
$strings = [];
633633

@@ -658,7 +658,7 @@ protected function parseCndStringList(): array
658658
*
659659
* TODO: check \n, \r, \t are valid in CND strings!
660660
*/
661-
protected function parseCndString(): string
661+
private function parseCndString(): string
662662
{
663663
$string = '';
664664
$lastType = null;
@@ -714,9 +714,9 @@ protected function parseCndString(): string
714714
* (('''Operator {','Operator}''') | '?')
715715
* Operator ::= '=' | '<>' | '<' | '<=' | '>' | '>=' | 'LIKE'
716716
*
717-
* @return array
717+
* @return array<bool|string>
718718
*/
719-
protected function parseQueryOpsAttribute()
719+
private function parseQueryOpsAttribute(): array
720720
{
721721
if ($this->checkAndExpectToken(Token::TK_SYMBOL, '?')) {
722722
// this denotes a variant, whatever that is
@@ -732,10 +732,7 @@ protected function parseQueryOpsAttribute()
732732
return $ops;
733733
}
734734

735-
/**
736-
* Parse a query operator.
737-
*/
738-
protected function parseQueryOperator(): bool|string
735+
private function parseQueryOperator(): bool|string
739736
{
740737
$token = $this->tokenQueue->peek();
741738
$data = $token->getData();

src/PHPCR/Util/CND/Scanner/GenericScanner.php

+2-23
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ protected function consumeNewLine(ReaderInterface $reader): bool
9393
return false;
9494
}
9595

96-
/**
97-
* Detect and consume strings.
98-
*
99-
* @throws ScannerException
100-
*/
10196
protected function consumeString(ReaderInterface $reader): bool
10297
{
10398
$curDelimiter = $reader->currentChar();
@@ -121,9 +116,6 @@ protected function consumeString(ReaderInterface $reader): bool
121116
return false;
122117
}
123118

124-
/**
125-
* Detect and consume comments.
126-
*/
127119
protected function consumeComments(ReaderInterface $reader): bool
128120
{
129121
if ($this->consumeBlockComments($reader)) {
@@ -133,11 +125,6 @@ protected function consumeComments(ReaderInterface $reader): bool
133125
return $this->consumeLineComments($reader);
134126
}
135127

136-
/**
137-
* Detect and consume block comments.
138-
*
139-
* @throws ScannerException
140-
*/
141128
protected function consumeBlockComments(ReaderInterface $reader): bool
142129
{
143130
$nextChar = $reader->currentChar();
@@ -184,15 +171,13 @@ protected function consumeBlockComments(ReaderInterface $reader): bool
184171
return false;
185172
}
186173

187-
/**
188-
* Detect and consume line comments.
189-
*/
190174
protected function consumeLineComments(ReaderInterface $reader): bool
191175
{
192176
$nextChar = $reader->currentChar();
193177
foreach ($this->context->getLineCommentDelimiters() as $delimiter) {
194178
if ($delimiter && $nextChar === $delimiter[0]) {
195-
for ($i = 1; $i <= strlen($delimiter); ++$i) {
179+
$delimiterLength = strlen($delimiter);
180+
for ($i = 1; $i <= $delimiterLength; ++$i) {
196181
$reader->forward();
197182
}
198183

@@ -218,9 +203,6 @@ protected function consumeLineComments(ReaderInterface $reader): bool
218203
return false;
219204
}
220205

221-
/**
222-
* Detect and consume identifiers.
223-
*/
224206
protected function consumeIdentifiers(ReaderInterface $reader): bool
225207
{
226208
$nextChar = $reader->currentChar();
@@ -239,9 +221,6 @@ protected function consumeIdentifiers(ReaderInterface $reader): bool
239221
return false;
240222
}
241223

242-
/**
243-
* Detect and consume symbols.
244-
*/
245224
protected function consumeSymbols(ReaderInterface $reader): bool
246225
{
247226
$found = false;

src/PHPCR/Util/CND/Scanner/GenericToken.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public static function getTypeName(int $type): string
3636

3737
public function __toString()
3838
{
39-
return sprintf("TOKEN(%s, '%s', %s, %s)", self::getTypeName($this->getType()), trim($this->data), $this->line, $this->row);
39+
return sprintf("TOKEN(%s, '%s', %s, %s)", self::getTypeName($this->getType()), trim($this->getData()), $this->getLine(), $this->getRow());
4040
}
4141
}

src/PHPCR/Util/CND/Scanner/Token.php

+9-29
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,15 @@
1515
*/
1616
class Token
1717
{
18-
/**
19-
* The type of token.
20-
*/
21-
public int $type;
22-
23-
/**
24-
* The token raw data.
25-
*/
26-
public string $data;
27-
28-
/**
29-
* The line where the token appears.
30-
*/
31-
protected int $line;
32-
33-
/**
34-
* The column where the token appears.
35-
*/
36-
protected int $row;
37-
38-
/**
39-
* Constructor.
40-
*/
41-
public function __construct(int $type = 0, string $data = '', int $line = 0, int $row = 0)
42-
{
43-
$this->type = $type;
44-
$this->data = $data;
45-
$this->line = $line;
46-
$this->row = $row;
18+
public function __construct(
19+
private int $type = 0,
20+
/**
21+
* The token raw data.
22+
*/
23+
private string $data = '',
24+
private int $line = 0,
25+
private int $row = 0
26+
) {
4727
}
4828

4929
public function getData(): string

src/PHPCR/Util/CND/Writer/CndWriter.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
*/
2828
class CndWriter
2929
{
30-
private NamespaceRegistryInterface $ns;
31-
32-
/** @var array<string, string> hashmap of prefix => namespace uri */
30+
/**
31+
* @var array<string, string> hashmap of prefix => namespace uri
32+
*/
3333
private array $namespaces = [];
3434

35-
public function __construct(NamespaceRegistryInterface $ns)
36-
{
37-
$this->ns = $ns;
35+
public function __construct(
36+
private NamespaceRegistryInterface $ns
37+
) {
3838
}
3939

4040
/**
@@ -232,7 +232,7 @@ private function writeChildren(?array $children): string
232232
if ($child->isProtected()) {
233233
$attributes .= 'protected ';
234234
}
235-
if (OnParentVersionAction::COPY != $child->getOnParentVersion()) {
235+
if (OnParentVersionAction::COPY !== $child->getOnParentVersion()) {
236236
$attributes .= OnParentVersionAction::nameFromValue($child->getOnParentVersion()).' ';
237237
}
238238
if ($child->allowsSameNameSiblings()) {

src/PHPCR/Util/Console/Command/NodeRemoveCommand.php

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace PHPCR\Util\Console\Command;
66

7-
use PHPCR\NodeInterface;
87
use Symfony\Component\Console\Exception\InvalidArgumentException as CliInvalidArgumentException;
98
use Symfony\Component\Console\Input\InputArgument;
109
use Symfony\Component\Console\Input\InputInterface;
@@ -97,7 +96,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9796
if ($onlyChildren) {
9897
$baseNode = $session->getNode($path, 0);
9998

100-
/** @var NodeInterface $childNode */
10199
foreach ($baseNode->getNodes() as $childNode) {
102100
$childNodePath = $childNode->getPath();
103101
$childNode->remove();

src/PHPCR/Util/Console/Command/NodeTouchCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
/**
1717
* Command to create a PHPCR node of a specified type from
18-
* the command line..
18+
* the command line.
1919
*
2020
* @license http://www.apache.org/licenses Apache License Version 2.0, January 2004
2121
* @license http://opensource.org/licenses/MIT MIT License

0 commit comments

Comments
 (0)