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

Unit test improvements for php-parser 5 #10574

Merged
merged 3 commits into from
Jan 24, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion tests/ClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ class T extends \PHPUnit\Framework\TestCase {
],
'classAliasNoException' => [
'code' => '<?php
class_alias("Bar\F1", "Bar\F2");
namespace {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A namespace declarations must be the first thing in the file. php-parser 5.0 enforces this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is simply invalid PHP code

https://3v4l.org/9HAnR

class_alias("Bar\F1", "Bar\F2");
}

namespace Bar {
class F1 {
Expand Down
16 changes: 8 additions & 8 deletions tests/FileUpdates/TemporaryUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public function foo() : void {

class A {
public function foo() : void {
throw new Error("bad", 5);
throw new Error("bad", []);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

php-parser 5.0 only allows passing an array as the second constructor argument. php-parser 4.0 allows both.

}
}',
],
Expand All @@ -613,7 +613,7 @@ public function foo() : void {

class A {
public function foo() : void {
throw new Error("bad", 5);
throw new Error("bad", []);
}
}',
],
Expand Down Expand Up @@ -657,7 +657,7 @@ public function foo() : void {

class A {
public function foo() : void {
throw new E("bad", 5);
throw new E("bad", []);
}
}',
],
Expand All @@ -667,7 +667,7 @@ public function foo() : void {

class A {
public function foo() : void {
throw new E("bad", 5);
throw new E("bad", []);
}
}',
],
Expand Down Expand Up @@ -707,7 +707,7 @@ public function foo() : void {

class A {
public function foo() : void {
throw new Error("bad", 5);
throw new Error("bad", []);
}
}',
],
Expand All @@ -717,7 +717,7 @@ public function foo() : void {

class A {
public function foo() : void {
throw new Error("bad", 5);
throw new Error("bad", []);
}
}',
],
Expand Down Expand Up @@ -755,7 +755,7 @@ public function foo() : void {

class A {
public function foo() : void {
throw new E("bad", 5);
throw new E("bad", []);
}
}',
],
Expand All @@ -765,7 +765,7 @@ public function foo() : void {

class A {
public function foo() : void {
throw new E("bad", 5);
throw new E("bad", []);
}
}',
],
Expand Down
2 changes: 1 addition & 1 deletion tests/PropertyTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ class Finally_ extends Node\Stmt
* Constructs a finally node.
*
* @param list<Node\Stmt> $stmts Statements
* @param array $attributes Additional attributes
* @param array<string, mixed> $attributes Additional attributes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

php-parser 5.0 has more specific type requirements on attributes.

*/
public function __construct(array $stmts = array(), array $attributes = array()) {
parent::__construct($attributes);
Expand Down