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

Added DNF type support #505

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

krzysztof-ciszewski
Copy link

TODO:

  • tests
  • domain exceptions

@scrutinizer-notifier
Copy link

A new inspection was created.

@krzysztof-ciszewski krzysztof-ciszewski marked this pull request as draft May 19, 2024 14:59
$pointcuts = array_slice($args, 1);
}

if (count(array_filter($pointcuts, static fn ($pointcut) => $pointcut instanceof Pointcut)) !== count($pointcuts)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before opening parenthesis of function call prohibited

@@ -0,0 +1,14 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

readonly class Node
{
public function __construct(
public NodeType $type,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 4 spaces, found 8

{
public function __construct(
public NodeType $type,
public ?string $identifier = null,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 4 spaces, found 8

public function __construct(
public NodeType $type,
public ?string $identifier = null,
public ?Node $left = null,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 4 spaces, found 8

public NodeType $type,
public ?string $identifier = null,
public ?Node $left = null,
public ?Node $right = null,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 4 spaces, found 8

@@ -0,0 +1,10 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

enum NodeType
{
case IDENTIFIER;
case AND;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND

{
case IDENTIFIER;
case AND;
case OR;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR

@@ -0,0 +1,13 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

case IDENTIFIER;
case LPAREN;
case RPAREN;
case AND;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND

case LPAREN;
case RPAREN;
case AND;
case OR;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR

@@ -0,0 +1,74 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

@@ -0,0 +1,74 @@
<?php

namespace Go\Aop\Pointcut\DNF\Parser;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be one blank line after the namespace declaration

* @param \ArrayIterator<\PhpToken> $tokens
*/
public function __construct(
private readonly \ArrayIterator $tokens

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 4 spaces, found 8


private function getToken(string $val): Token
{
return match ($val) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before opening parenthesis of function call prohibited

chr(26) => Token::EOF,
'(' => Token::LPAREN,
')' => Token::RPAREN,
'|' => Token::OR,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR

'(' => Token::LPAREN,
')' => Token::RPAREN,
'|' => Token::OR,
'&' => Token::AND,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND

')' => Token::RPAREN,
'|' => Token::OR,
'&' => Token::AND,
default => Token::IDENTIFIER

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 12

@@ -0,0 +1,21 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

* @return array{0: Token, 1: string|null}
*/
public function peek(int $i): array;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 newline at end of file; 0 found

@@ -0,0 +1,113 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

TokenCollection $tokens,
int $bindingPower,
bool $insideParenthesis = false
): ?Node {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found 0 spaces

): ?Node {
[$token, $val] = $tokens->next();
switch ($token) {
case Token::LPAREN:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CASE statements must be defined using a colon

while (true) {
[$token] = $tokens->peek(0);

if ($token === Token::OR && $insideParenthesis) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR

}

switch ($token) {
case Token::OR:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR


switch ($token) {
case Token::OR:
case Token::AND:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND


private function operatorNode(Token $type, Node $left, ?Node $right): Node
{
return match ($type) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before opening parenthesis of function call prohibited

private function operatorNode(Token $type, Node $left, ?Node $right): Node
{
return match ($type) {
Token::OR => new Node(NodeType::OR, left: $left, right: $right),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR

{
return match ($type) {
Token::OR => new Node(NodeType::OR, left: $left, right: $right),
Token::AND => new Node(NodeType::AND, left: $left, right: $right),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND

return match ($type) {
Token::OR => new Node(NodeType::OR, left: $left, right: $right),
Token::AND => new Node(NodeType::AND, left: $left, right: $right),
default => throw new Exception('invalid op')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 12

*/
private function getBindingPower(Token $type): array
{
return match ($type) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before opening parenthesis of function call prohibited

private function getBindingPower(Token $type): array
{
return match ($type) {
Token::OR => [1, 2],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR

{
return match ($type) {
Token::OR => [1, 2],
Token::AND => [3, 4],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND

return match ($type) {
Token::OR => [1, 2],
Token::AND => [3, 4],
default => throw new Exception('Invalid operator')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 12

};
}

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Expected 1 newline at end of file; 0 found
  • The closing brace for the class must go on the next line after the body

@@ -0,0 +1,8 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

interface TokenizerParserInterface
{
public function parse(string $input);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 newline at end of file; 0 found

@@ -0,0 +1,44 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

|| $val->implementsInterface($tree->identifier);
}

if ($tree?->type === NodeType::AND) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND

return match ($type) {
Token::OR => new Node(NodeType::OR, left: $left, right: $right),
Token::AND => new Node(NodeType::AND, left: $left, right: $right),
default => throw new Exception('invalid op')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 12

*/
private function getBindingPower(Token $type): array
{
return match ($type) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before opening parenthesis of function call prohibited

private function getBindingPower(Token $type): array
{
return match ($type) {
Token::OR => [1, 2],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR

{
return match ($type) {
Token::OR => [1, 2],
Token::AND => [3, 4],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND

return match ($type) {
Token::OR => [1, 2],
Token::AND => [3, 4],
default => throw new Exception('Invalid operator')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 12

};
}

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Expected 1 newline at end of file; 0 found
  • The closing brace for the class must go on the next line after the body

@@ -0,0 +1,8 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

interface TokenizerParserInterface
{
public function parse(string $input);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 newline at end of file; 0 found

@@ -0,0 +1,44 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

|| $val->implementsInterface($tree->identifier);
}

if ($tree?->type === NodeType::AND) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected and but found AND

return $this->verifyTree($tree->left, $val) && $this->verifyTree($tree->right, $val);
}

if ($tree->type === NodeType::OR) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP keywords must be lowercase; expected or but found OR


return $parentClasses;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 newline at end of file; 0 found

@@ -0,0 +1,11 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End of line character is invalid; expected \n but found \r\n

interface SemanticAnalyzerInterface
{
public function verifyTree(Node $tree, \ReflectionClass|ReflectionFileNamespace $val);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 1 newline at end of file; 0 found

->call(fn($parentClassName) => new ClassInheritancePointcut($parentClassName))
->call(static function (...$args) {
return array_map(
static fn (string $class) => new ClassInheritancePointcut($class),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Line indented incorrectly; expected 16 spaces, found 20
  • Space before opening parenthesis of function call prohibited

@@ -301,6 +305,12 @@ function () {
->call($stringConverter)
->is('namespacePattern', 'nsSeparator', '**')
->call($stringConverter)
->is('namespacePattern', '&', 'namespacePattern')
->call($stringConverter)
->is('(' , 'namespacePattern', '&', 'namespacePattern', ')')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space found before comma in function call

@krzysztof-ciszewski
Copy link
Author

@lisachenko I would suggest disabling nitpick, seems pretty outdated, most of these comments are wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants