-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new tests, more tests, tests-tests-tests
- Loading branch information
Showing
6 changed files
with
134 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package checkers | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/VKCOM/noverify/src/linttest" | ||
) | ||
|
||
func TestNotNullableString(t *testing.T) { | ||
test := linttest.NewSuite(t) | ||
test.AddFile(`<?php | ||
function nullableString(?string $a = null) { | ||
return 0; | ||
} | ||
`) | ||
|
||
test.RunAndMatch() | ||
} | ||
|
||
func TestNotNullableArray(t *testing.T) { | ||
test := linttest.NewSuite(t) | ||
test.AddFile(`<?php | ||
/** | ||
* @param string[] array | ||
*/ | ||
function nullableArray(array $a = null) { | ||
return 0; | ||
} | ||
`) | ||
|
||
test.Expect = []string{ | ||
"parameter with null default value should be explicitly nullable", | ||
} | ||
test.RunAndMatch() | ||
} | ||
|
||
func TestNullableCallable(t *testing.T) { | ||
test := linttest.NewSuite(t) | ||
test.AddFile(`<?php | ||
function nullableCallable(?callable $a = null) { | ||
return 0; | ||
} | ||
`) | ||
|
||
test.RunAndMatch() | ||
} | ||
|
||
func TestNotNullableCallable(t *testing.T) { | ||
test := linttest.NewSuite(t) | ||
test.AddFile(`<?php | ||
function NotNullableCallable(callable $a = null) { | ||
return 0; | ||
} | ||
`) | ||
|
||
test.Expect = []string{ | ||
"parameter with null default value should be explicitly nullable", | ||
} | ||
test.RunAndMatch() | ||
} | ||
|
||
func TestNotNullableClasses(t *testing.T) { | ||
test := linttest.NewSuite(t) | ||
test.AddFile(`<?php | ||
class MyClass1 { | ||
} | ||
class MyClass2 { | ||
public function myMethod(MyClass1 $a = null) { | ||
return 0; | ||
} | ||
} | ||
`) | ||
|
||
test.Expect = []string{ | ||
"parameter with null default value should be explicitly nullable", | ||
"Missing PHPDoc for", | ||
} | ||
test.RunAndMatch() | ||
} | ||
|
||
func TestNullableClasses(t *testing.T) { | ||
test := linttest.NewSuite(t) | ||
test.AddFile(`<?php | ||
class MyClass1 { | ||
} | ||
class MyClass2 { | ||
public function myMethod(?MyClass1 $a = null) { | ||
return 0; | ||
} | ||
} | ||
`) | ||
|
||
test.Expect = []string{ | ||
"Missing PHPDoc for", | ||
} | ||
test.RunAndMatch() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
function f(string $filed = null) { | ||
return 1; | ||
} | ||
|
||
function notNullableCallable(callable $a = null) { | ||
return 0; | ||
} | ||
|
||
class MyClass1 { | ||
} | ||
|
||
class MyClass2 { | ||
public function myMethod(MyClass1 $a = null) { | ||
return 0; | ||
} | ||
} | ||
|
||
function nullableArray(array $a = null) { | ||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.