Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: phpstan/phpdoc-parser
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f545fc30978190a056832aa7ed995e36a66267f3
Choose a base ref
...
head repository: phpstan/phpdoc-parser
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7d568c87a9df9c5f7e8b5f075fc469aa8cb0a4cd
Choose a head ref

Commits on Apr 18, 2023

  1. Copy the full SHA
    b508006 View commit details
  2. Copy the full SHA
    f9ecd17 View commit details
  3. Copy the full SHA
    ddc8c7a View commit details
  4. Rename tests

    ondrejmirtes committed Apr 18, 2023
    Copy the full SHA
    4255dd3 View commit details

Commits on Apr 19, 2023

  1. Copy the full SHA
    7ff42f5 View commit details
  2. Copy the full SHA
    0138dd9 View commit details
  3. Add missing typehints

    ondrejmirtes committed Apr 19, 2023
    Copy the full SHA
    1ae8d74 View commit details
  4. Increase PHPStan level

    ondrejmirtes committed Apr 19, 2023
    Copy the full SHA
    874bf25 View commit details

Commits on Apr 20, 2023

  1. Copy the full SHA
    00d0fcd View commit details
  2. CloningVisitor

    ondrejmirtes committed Apr 20, 2023
    Copy the full SHA
    10553ab View commit details

Commits on Apr 22, 2023

  1. Copy the full SHA
    900bd69 View commit details
  2. Copy the full SHA
    57f6787 View commit details
  3. Copy the full SHA
    08ccb8d View commit details
  4. Copy the full SHA
    90490bd View commit details

Commits on Apr 24, 2023

  1. Copy the full SHA
    39e4966 View commit details
  2. Copy the full SHA
    ecb7789 View commit details
  3. Copy the full SHA
    3416dc6 View commit details
  4. Copy the full SHA
    cff97e9 View commit details
  5. Copy the full SHA
    b5fede3 View commit details
  6. Copy the full SHA
    6220c55 View commit details

Commits on Apr 25, 2023

  1. Copy the full SHA
    142198e View commit details
  2. Copy the full SHA
    ffaba4f View commit details
  3. Copy the full SHA
    69432fa View commit details
  4. Copy the full SHA
    d985f89 View commit details
  5. Copy the full SHA
    6c04009 View commit details

Commits on May 2, 2023

  1. Open 1.20.x

    ondrejmirtes committed May 2, 2023
    Copy the full SHA
    2ebed2c View commit details
  2. Copy the full SHA
    d60fa73 View commit details
  3. Copy the full SHA
    421d3f3 View commit details
  4. Copy the full SHA
    a7e9698 View commit details
  5. Simplify implementation

    ondrejmirtes committed May 2, 2023
    Copy the full SHA
    7d568c8 View commit details
Showing with 2,737 additions and 171 deletions.
  1. +1 −1 .github/workflows/backward-compatibility.yml
  2. +1 −1 .github/workflows/build.yml
  3. +9 −3 .github/workflows/test-slevomat-coding-standard.yml
  4. +4 −0 Makefile
  5. +16 −16 build-cs/composer.lock
  6. +1 −0 phpcs.xml
  7. +26 −0 phpstan-baseline.neon
  8. +4 −1 phpstan.neon
  9. +34 −0 src/Ast/AbstractNodeVisitor.php
  10. +16 −0 src/Ast/Attribute.php
  11. +1 −1 src/Ast/ConstExpr/QuoteAwareConstExprStringNode.php
  12. +312 −0 src/Ast/NodeTraverser.php
  13. +87 −0 src/Ast/NodeVisitor.php
  14. +20 −0 src/Ast/NodeVisitor/CloningVisitor.php
  15. +2 −1 src/Ast/PhpDoc/InvalidTagValueNode.php
  16. +4 −0 src/Ast/PhpDoc/MethodTagValueNode.php
  17. +1 −0 src/Ast/Type/ArrayShapeNode.php
  18. +3 −0 src/Ast/Type/CallableTypeNode.php
  19. +4 −0 src/Ast/Type/GenericTypeNode.php
  20. +3 −0 src/Ast/Type/IntersectionTypeNode.php
  21. +1 −0 src/Ast/Type/InvalidTypeNode.php
  22. +3 −0 src/Ast/Type/ObjectShapeNode.php
  23. +3 −0 src/Ast/Type/UnionTypeNode.php
  24. +13 −2 src/Lexer/Lexer.php
  25. +127 −17 src/Parser/ConstExprParser.php
  26. +15 −3 src/Parser/ParserException.php
  27. +122 −15 src/Parser/PhpDocParser.php
  28. +3 −3 src/Parser/StringUnescaper.php
  29. +27 −2 src/Parser/TokenIterator.php
  30. +262 −33 src/Parser/TypeParser.php
  31. +411 −0 tests/PHPStan/Ast/NodeTraverserTest.php
  32. +32 −0 tests/PHPStan/Ast/NodeVisitor/CloningVisitorTest.php
  33. +79 −0 tests/PHPStan/Ast/NodeVisitorForTesting.php
  34. +34 −0 tests/PHPStan/Parser/ConstExprParserTest.php
  35. +13 −3 tests/PHPStan/Parser/FuzzyTest.php
  36. +21 −0 tests/PHPStan/Parser/NodeCollectingVisitor.php
  37. +449 −69 tests/PHPStan/Parser/PhpDocParserTest.php
  38. +573 −0 tests/PHPStan/Parser/TypeParserTest.php
2 changes: 1 addition & 1 deletion .github/workflows/backward-compatibility.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ on:
pull_request:
push:
branches:
- "1.9.x"
- "1.20.x"

jobs:
backward-compatibility:
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ on:
pull_request:
push:
branches:
- "1.9.x"
- "1.20.x"

jobs:
lint:
12 changes: 9 additions & 3 deletions .github/workflows/test-slevomat-coding-standard.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ on:
pull_request:
push:
branches:
- "1.9.x"
- "1.20.x"

jobs:
tests:
@@ -32,14 +32,18 @@ jobs:
with:
repository: slevomat/coding-standard
path: slevomat-cs
ref: 8.7.1
ref: 710c256bf3f0f696ec8d4f9d2218321c3eb0f7d2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: "Unset platform"
working-directory: slevomat-cs
run: "composer config --unset platform"

- name: "Install dependencies"
working-directory: slevomat-cs
run: "composer install --no-interaction --no-progress"
@@ -56,12 +60,14 @@ jobs:

- name: "Tests"
working-directory: slevomat-cs
run: "bin/phpunit"
run: "bin/phpunit --no-coverage"

- name: "PHPStan"
if: matrix.php-version == '8.0' || matrix.php-version == '8.1' || matrix.php-version == '8.2'
working-directory: slevomat-cs
run: "bin/phpstan analyse -c build/PHPStan/phpstan.neon"

- name: "PHPStan in tests"
if: matrix.php-version == '8.0' || matrix.php-version == '8.1' || matrix.php-version == '8.2'
working-directory: slevomat-cs
run: "bin/phpstan analyse -c build/PHPStan/phpstan.tests.neon"
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -25,6 +25,10 @@ cs-fix:
phpstan:
php vendor/bin/phpstan

.PHONY: phpstan-generate-baseline
phpstan-generate-baseline:
php vendor/bin/phpstan --generate-baseline

.PHONY: build-abnfgen
build-abnfgen:
./build-abnfgen.sh
32 changes: 16 additions & 16 deletions build-cs/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/>
<exclude name="Consistence.Exceptions.ExceptionDeclaration"/>
<exclude name="Squiz.Commenting.FunctionComment"/>
<exclude name="Squiz.PHP.Heredoc.NotAllowed"/>
26 changes: 26 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
parameters:
ignoreErrors:
-
message: "#^Method PHPStan\\\\PhpDocParser\\\\Ast\\\\ConstExpr\\\\QuoteAwareConstExprStringNode\\:\\:escapeDoubleQuotedString\\(\\) should return string but returns string\\|null\\.$#"
count: 1
path: src/Ast/ConstExpr/QuoteAwareConstExprStringNode.php

-
message: "#^Cannot use array destructuring on array\\<int, array\\<PHPStan\\\\PhpDocParser\\\\Ast\\\\Node\\>\\|int\\|string\\>\\|null\\.$#"
count: 1
path: src/Ast/NodeTraverser.php

-
message: "#^Strict comparison using \\=\\=\\= between 2 and 2 will always evaluate to true\\.$#"
count: 2
path: src/Ast/NodeTraverser.php

-
message: "#^Variable property access on PHPStan\\\\PhpDocParser\\\\Ast\\\\Node\\.$#"
count: 1
path: src/Ast/NodeTraverser.php

-
message: "#^Method PHPStan\\\\PhpDocParser\\\\Parser\\\\StringUnescaper\\:\\:parseEscapeSequences\\(\\) should return string but returns string\\|null\\.$#"
count: 1
path: src/Parser/StringUnescaper.php
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
includes:
- phpstan-baseline.neon

parameters:
paths:
- src
- tests
level: 5
level: 8
ignoreErrors:
- '#^Dynamic call to static method PHPUnit\\Framework\\Assert#'
34 changes: 34 additions & 0 deletions src/Ast/AbstractNodeVisitor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php declare(strict_types = 1);

namespace PHPStan\PhpDocParser\Ast;

/**
* Inspired by https://github.com/nikic/PHP-Parser/tree/36a6dcd04e7b0285e8f0868f44bd4927802f7df1
*
* Copyright (c) 2011, Nikita Popov
* All rights reserved.
*/
abstract class AbstractNodeVisitor implements NodeVisitor
{

public function beforeTraverse(array $nodes): ?array
{
return null;
}

public function enterNode(Node $node)
{
return null;
}

public function leaveNode(Node $node)
{
return null;
}

public function afterTraverse(array $nodes): ?array
{
return null;
}

}
16 changes: 16 additions & 0 deletions src/Ast/Attribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php declare(strict_types = 1);

namespace PHPStan\PhpDocParser\Ast;

final class Attribute
{

public const START_LINE = 'startLine';
public const END_LINE = 'endLine';

public const START_INDEX = 'startIndex';
public const END_INDEX = 'endIndex';

public const ORIGINAL_NODE = 'originalNode';

}
2 changes: 1 addition & 1 deletion src/Ast/ConstExpr/QuoteAwareConstExprStringNode.php
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ public function __toString(): string
return sprintf('"%s"', $this->escapeDoubleQuotedString());
}

private function escapeDoubleQuotedString()
private function escapeDoubleQuotedString(): string
{
$quote = '"';
$escaped = addcslashes($this->value, "\n\r\t\f\v$" . $quote . '\\');
Loading