Skip to content

Commit

Permalink
Fixed tests (declare section)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Mar 6, 2024
1 parent 71e799a commit 2d5a503
Show file tree
Hide file tree
Showing 40 changed files with 286 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/tests/checkers/anon_class_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

func TestSimpleAnonClass(t *testing.T) {
linttest.SimpleNegativeTest(t, `<?php
declare(strict_types=1);
function f() {
$a = new class {
/** */
Expand All @@ -21,6 +22,7 @@ function f() {

func TestAnonClassAsInterface(t *testing.T) {
linttest.SimpleNegativeTest(t, `<?php
declare(strict_types=1);
interface IFace {}
function f(IFace $if) {}
Expand All @@ -32,6 +34,7 @@ f(new class implements IFace {});
func TestAnonClassFromDocumentation(t *testing.T) {
test := linttest.NewSuite(t)
test.AddFile(`<?php
declare(strict_types=1);
class Outer {
private $prop = 1;
protected $prop2 = 2;
Expand Down Expand Up @@ -66,6 +69,7 @@ echo (new Outer)->func2()->func3();

func TestAnonClassWithConstructor(t *testing.T) {
linttest.SimpleNegativeTest(t, `<?php
declare(strict_types=1);
function f() {
$a = new class(100, "s") {
/** */
Expand All @@ -84,6 +88,7 @@ function f() {

func TestAnonClassWithExtends(t *testing.T) {
linttest.SimpleNegativeTest(t, `<?php
declare(strict_types=1);
class Boo {
/** */
public function b() {}
Expand All @@ -103,6 +108,7 @@ function f() {

func TestAnonClassWithImplements(t *testing.T) {
linttest.SimpleNegativeTest(t, `<?php
declare(strict_types=1);
interface IBoo {
/** */
public function b() {}
Expand All @@ -121,6 +127,8 @@ function f() {

func TestAnonClassWithSeveralImplements(t *testing.T) {
linttest.SimpleNegativeTest(t, `<?php
declare(strict_types=1);
interface IBoo {
/** */
public function b() {}
Expand Down
3 changes: 3 additions & 0 deletions src/tests/checkers/arrow_functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
func TestArrowFunction(t *testing.T) {
test := linttest.NewSuite(t)
test.AddFile(`<?php
declare(strict_types=1);
class Boo {
/** @return int */
public function b() { }
Expand Down Expand Up @@ -94,6 +95,8 @@ func TestUnusedInArrowFunction(t *testing.T) {
`stubs/phpstorm-stubs/standard/standard_9.php`,
}
test.AddFile(`<?php
declare(strict_types=1);
function f() {
$a1 = [];
$a2 = [];
Expand Down
Loading

0 comments on commit 2d5a503

Please sign in to comment.