Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more phpdoc cleanup #219

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/PHPCR/Util/CND/Parser/AbstractParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
*/
abstract class AbstractParser
{
/**
* The token queue.
*/
protected TokenQueue $tokenQueue;

/**
Expand Down Expand Up @@ -105,7 +102,7 @@ protected function expectToken(int $type, string $data = null): Token
* @param int $type The expected token type
* @param string|null $data The expected token data or null
*/
protected function checkAndExpectToken(int $type, string $data = null): bool|Token
protected function checkAndExpectToken(int $type, string $data = null): false|Token
{
if ($this->checkToken($type, $data)) {
$token = $this->tokenQueue->peek();
Expand Down
43 changes: 20 additions & 23 deletions src/PHPCR/Util/CND/Parser/CndParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ final class CndParser extends AbstractParser
/**
* @var string[]
*/
protected array $namespaces = [];
private array $namespaces = [];

/**
* @var string[]
*/
protected array $nodeTypes = [];
private array $nodeTypes = [];

public function __construct(NodeTypeManagerInterface $ntm)
{
Expand Down Expand Up @@ -142,7 +142,7 @@ private function parse(ReaderInterface $reader): array
* Prefix ::= String
* Uri ::= String
*/
protected function parseNamespaceMapping(): void
private function parseNamespaceMapping(): void
{
$this->expectToken(Token::TK_SYMBOL, '<');
$prefix = $this->parseCndString();
Expand All @@ -162,7 +162,7 @@ protected function parseNamespaceMapping(): void
* [NodeTypeAttribute {NodeTypeAttribute}]
* {PropertyDef | ChildNodeDef}
*/
protected function parseNodeType(): void
private function parseNodeType(): void
{
$nodeType = $this->ntm->createNodeTypeTemplate();
$this->parseNodeTypeName($nodeType);
Expand All @@ -183,7 +183,7 @@ protected function parseNodeType(): void
*
* NodeTypeName ::= '[' String ']'
*/
protected function parseNodeTypeName(NodeTypeTemplateInterface $nodeType): void
private function parseNodeTypeName(NodeTypeTemplateInterface $nodeType): void
{
$this->expectToken(Token::TK_SYMBOL, '[');
$name = $this->parseCndString();
Expand All @@ -200,7 +200,7 @@ protected function parseNodeTypeName(NodeTypeTemplateInterface $nodeType): void
*
* Supertypes ::= '>' (StringList | '?')
*/
protected function parseSupertypes(NodeTypeTemplateInterface $nodeType): void
private function parseSupertypes(NodeTypeTemplateInterface $nodeType): void
{
$this->expectToken(Token::TK_SYMBOL, '>');

Expand Down Expand Up @@ -243,7 +243,7 @@ protected function parseSupertypes(NodeTypeTemplateInterface $nodeType): void
* Query ::= ('noquery' | 'nq') | ('query' | 'q' )
* PrimaryItem ::= ('primaryitem'| '!')(String | '?')
*/
protected function parseNodeTypeAttributes(NodeTypeTemplateInterface $nodeType): void
private function parseNodeTypeAttributes(NodeTypeTemplateInterface $nodeType): void
{
while (true) {
if ($this->checkTokenIn(Token::TK_IDENTIFIER, $this->ORDERABLE)) {
Expand Down Expand Up @@ -284,7 +284,7 @@ protected function parseNodeTypeAttributes(NodeTypeTemplateInterface $nodeType):
*
* {PropertyDef | ChildNodeDef}
*/
protected function parseChildrenAndAttributes(NodeTypeTemplateInterface $nodeType): void
private function parseChildrenAndAttributes(NodeTypeTemplateInterface $nodeType): void
{
while (true) {
if ($this->checkToken(Token::TK_SYMBOL, '-')) {
Expand All @@ -310,7 +310,7 @@ protected function parseChildrenAndAttributes(NodeTypeTemplateInterface $nodeTyp
* [ValueConstraints]
* PropertyName ::= '-' String
*/
protected function parsePropDef(NodeTypeTemplateInterface $nodeType): void
private function parsePropDef(NodeTypeTemplateInterface $nodeType): void
{
$this->expectToken(Token::TK_SYMBOL, '-');

Expand Down Expand Up @@ -364,7 +364,7 @@ protected function parsePropDef(NodeTypeTemplateInterface $nodeType): void
* 'DECIMAL' | 'URI' | 'UNDEFINED' | '*' |
* '?') ')'
*/
protected function parsePropertyType(PropertyDefinitionTemplateInterface $property): void
private function parsePropertyType(PropertyDefinitionTemplateInterface $property): void
{
$types = ['STRING', 'BINARY', 'LONG', 'DOUBLE', 'BOOLEAN', 'DATE', 'NAME', 'PATH',
'REFERENCE', 'WEAKREFERENCE', 'DECIMAL', 'URI', 'UNDEFINED', '*', '?', ];
Expand All @@ -388,7 +388,7 @@ protected function parsePropertyType(PropertyDefinitionTemplateInterface $proper
*
* DefaultValues ::= '=' (StringList | '?')
*/
protected function parseDefaultValue(PropertyDefinitionTemplateInterface $property): void
private function parseDefaultValue(PropertyDefinitionTemplateInterface $property): void
{
if ($this->checkAndExpectToken(Token::TK_SYMBOL, '?')) {
$list = ['?'];
Expand All @@ -406,7 +406,7 @@ protected function parseDefaultValue(PropertyDefinitionTemplateInterface $proper
*
* ValueConstraints ::= '<' (StringList | '?')
*/
protected function parseValueConstraints(PropertyDefinitionTemplateInterface $property): void
private function parseValueConstraints(PropertyDefinitionTemplateInterface $property): void
{
$this->expectToken(Token::TK_SYMBOL, '<');

Expand Down Expand Up @@ -473,7 +473,7 @@ protected function parseValueConstraints(PropertyDefinitionTemplateInterface $pr
* NoFullText ::= ('nofulltext' | 'nof') ['?']
* NoQueryOrder ::= ('noqueryorder' | 'nqord') ['?']
*/
protected function parsePropertyAttributes(NodeTypeTemplateInterface $parentType, PropertyDefinitionTemplateInterface $property): void
private function parsePropertyAttributes(NodeTypeTemplateInterface $parentType, PropertyDefinitionTemplateInterface $property): void
{
$opvSeen = false;
while (true) {
Expand Down Expand Up @@ -527,7 +527,7 @@ protected function parsePropertyAttributes(NodeTypeTemplateInterface $parentType
* RequiredTypes ::= '(' (StringList | '?') ')'
* DefaultType ::= '=' (String | '?')
*/
protected function parseChildNodeDef(NodeTypeTemplateInterface $nodeType): void
private function parseChildNodeDef(NodeTypeTemplateInterface $nodeType): void
{
$this->expectToken(Token::TK_SYMBOL, '+');
$childType = $this->ntm->createNodeDefinitionTemplate();
Expand Down Expand Up @@ -593,7 +593,7 @@ protected function parseChildNodeDef(NodeTypeTemplateInterface $nodeType): void
* 'IGNORE' | 'ABORT' | ('OPV' '?')
* Sns ::= ('sns' | '*') ['?']
*/
protected function parseChildNodeAttributes(
private function parseChildNodeAttributes(
NodeTypeTemplateInterface $parentType,
NodeDefinitionTemplateInterface $childType
): void {
Expand Down Expand Up @@ -627,7 +627,7 @@ protected function parseChildNodeAttributes(
*
* @return string[]
*/
protected function parseCndStringList(): array
private function parseCndStringList(): array
{
$strings = [];

Expand Down Expand Up @@ -658,7 +658,7 @@ protected function parseCndStringList(): array
*
* TODO: check \n, \r, \t are valid in CND strings!
*/
protected function parseCndString(): string
private function parseCndString(): string
{
$string = '';
$lastType = null;
Expand Down Expand Up @@ -714,9 +714,9 @@ protected function parseCndString(): string
* (('''Operator {','Operator}''') | '?')
* Operator ::= '=' | '<>' | '<' | '<=' | '>' | '>=' | 'LIKE'
*
* @return array
* @return array<bool|string>
*/
protected function parseQueryOpsAttribute()
private function parseQueryOpsAttribute(): array
{
if ($this->checkAndExpectToken(Token::TK_SYMBOL, '?')) {
// this denotes a variant, whatever that is
Expand All @@ -732,10 +732,7 @@ protected function parseQueryOpsAttribute()
return $ops;
}

/**
* Parse a query operator.
*/
protected function parseQueryOperator(): bool|string
private function parseQueryOperator(): bool|string
{
$token = $this->tokenQueue->peek();
$data = $token->getData();
Expand Down
25 changes: 2 additions & 23 deletions src/PHPCR/Util/CND/Scanner/GenericScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ protected function consumeNewLine(ReaderInterface $reader): bool
return false;
}

/**
* Detect and consume strings.
*
* @throws ScannerException
*/
protected function consumeString(ReaderInterface $reader): bool
{
$curDelimiter = $reader->currentChar();
Expand All @@ -121,9 +116,6 @@ protected function consumeString(ReaderInterface $reader): bool
return false;
}

/**
* Detect and consume comments.
*/
protected function consumeComments(ReaderInterface $reader): bool
{
if ($this->consumeBlockComments($reader)) {
Expand All @@ -133,11 +125,6 @@ protected function consumeComments(ReaderInterface $reader): bool
return $this->consumeLineComments($reader);
}

/**
* Detect and consume block comments.
*
* @throws ScannerException
*/
protected function consumeBlockComments(ReaderInterface $reader): bool
{
$nextChar = $reader->currentChar();
Expand Down Expand Up @@ -184,15 +171,13 @@ protected function consumeBlockComments(ReaderInterface $reader): bool
return false;
}

/**
* Detect and consume line comments.
*/
protected function consumeLineComments(ReaderInterface $reader): bool
{
$nextChar = $reader->currentChar();
foreach ($this->context->getLineCommentDelimiters() as $delimiter) {
if ($delimiter && $nextChar === $delimiter[0]) {
for ($i = 1; $i <= strlen($delimiter); ++$i) {
$delimiterLength = strlen($delimiter);
for ($i = 1; $i <= $delimiterLength; ++$i) {
$reader->forward();
}

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

/**
* Detect and consume identifiers.
*/
protected function consumeIdentifiers(ReaderInterface $reader): bool
{
$nextChar = $reader->currentChar();
Expand All @@ -239,9 +221,6 @@ protected function consumeIdentifiers(ReaderInterface $reader): bool
return false;
}

/**
* Detect and consume symbols.
*/
protected function consumeSymbols(ReaderInterface $reader): bool
{
$found = false;
Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Util/CND/Scanner/GenericToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public static function getTypeName(int $type): string

public function __toString()
{
return sprintf("TOKEN(%s, '%s', %s, %s)", self::getTypeName($this->getType()), trim($this->data), $this->line, $this->row);
return sprintf("TOKEN(%s, '%s', %s, %s)", self::getTypeName($this->getType()), trim($this->getData()), $this->getLine(), $this->getRow());
}
}
38 changes: 9 additions & 29 deletions src/PHPCR/Util/CND/Scanner/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,15 @@
*/
class Token
{
/**
* The type of token.
*/
public int $type;

/**
* The token raw data.
*/
public string $data;

/**
* The line where the token appears.
*/
protected int $line;

/**
* The column where the token appears.
*/
protected int $row;

/**
* Constructor.
*/
public function __construct(int $type = 0, string $data = '', int $line = 0, int $row = 0)
{
$this->type = $type;
$this->data = $data;
$this->line = $line;
$this->row = $row;
public function __construct(
private int $type = 0,
/**
* The token raw data.
*/
private string $data = '',
private int $line = 0,
private int $row = 0
) {
}

public function getData(): string
Expand Down
14 changes: 7 additions & 7 deletions src/PHPCR/Util/CND/Writer/CndWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
*/
class CndWriter
{
private NamespaceRegistryInterface $ns;

/** @var array<string, string> hashmap of prefix => namespace uri */
/**
* @var array<string, string> hashmap of prefix => namespace uri
*/
private array $namespaces = [];

public function __construct(NamespaceRegistryInterface $ns)
{
$this->ns = $ns;
public function __construct(
private NamespaceRegistryInterface $ns
) {
}

/**
Expand Down Expand Up @@ -232,7 +232,7 @@ private function writeChildren(?array $children): string
if ($child->isProtected()) {
$attributes .= 'protected ';
}
if (OnParentVersionAction::COPY != $child->getOnParentVersion()) {
if (OnParentVersionAction::COPY !== $child->getOnParentVersion()) {
$attributes .= OnParentVersionAction::nameFromValue($child->getOnParentVersion()).' ';
}
if ($child->allowsSameNameSiblings()) {
Expand Down
2 changes: 0 additions & 2 deletions src/PHPCR/Util/Console/Command/NodeRemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace PHPCR\Util\Console\Command;

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

/** @var NodeInterface $childNode */
foreach ($baseNode->getNodes() as $childNode) {
$childNodePath = $childNode->getPath();
$childNode->remove();
Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Util/Console/Command/NodeTouchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/**
* Command to create a PHPCR node of a specified type from
* the command line..
* the command line.
*
* @license http://www.apache.org/licenses Apache License Version 2.0, January 2004
* @license http://opensource.org/licenses/MIT MIT License
Expand Down
Loading