mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-23 19:39:10 -04:00
ALPHA 3.0.2a
This commit is contained in:
@@ -37,7 +37,7 @@ class FinalClassPassTest extends CodeCleanerTestCase
|
||||
// array('namespace A { final class B {} } namespace C { class D extends \\A\\B {} }'),
|
||||
];
|
||||
|
||||
if (!defined('HHVM_VERSION')) {
|
||||
if (!\defined('HHVM_VERSION')) {
|
||||
// For some reason Closure isn't final in HHVM?
|
||||
$data[] = ['class A extends \\Closure {}'];
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class FunctionReturnInWriteContextPassTest extends CodeCleanerTestCase
|
||||
$this->traverser->traverse($this->parse('isset(strtolower("A"))'));
|
||||
$this->fail();
|
||||
} catch (FatalErrorException $e) {
|
||||
if (version_compare(PHP_VERSION, '5.5', '>=')) {
|
||||
if (\version_compare(PHP_VERSION, '5.5', '>=')) {
|
||||
$this->assertContains(
|
||||
'Cannot use isset() on the result of a function call (you can use "null !== func()" instead)',
|
||||
$e->getMessage()
|
||||
@@ -66,7 +66,7 @@ class FunctionReturnInWriteContextPassTest extends CodeCleanerTestCase
|
||||
*/
|
||||
public function testEmpty()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.5', '>=')) {
|
||||
if (\version_compare(PHP_VERSION, '5.5', '>=')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class LegacyEmptyPassTest extends CodeCleanerTestCase
|
||||
|
||||
public function invalidStatements()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.5', '>=')) {
|
||||
if (\version_compare(PHP_VERSION, '5.5', '>=')) {
|
||||
return [
|
||||
['empty()'],
|
||||
];
|
||||
@@ -58,7 +58,7 @@ class LegacyEmptyPassTest extends CodeCleanerTestCase
|
||||
|
||||
public function validStatements()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.5', '<')) {
|
||||
if (\version_compare(PHP_VERSION, '5.5', '<')) {
|
||||
return [
|
||||
['empty($foo)'],
|
||||
];
|
||||
|
||||
@@ -26,7 +26,7 @@ class ListPassTest extends CodeCleanerTestCase
|
||||
*/
|
||||
public function testProcessInvalidStatement($code, $expectedMessage)
|
||||
{
|
||||
if (method_exists($this, 'setExpectedException')) {
|
||||
if (\method_exists($this, 'setExpectedException')) {
|
||||
$this->setExpectedException('Psy\Exception\ParseErrorException', $expectedMessage);
|
||||
} else {
|
||||
$this->expectExceptionMessage($expectedMessage);
|
||||
@@ -50,20 +50,23 @@ class ListPassTest extends CodeCleanerTestCase
|
||||
['list("a") = array(1)', $errorPhpParserSyntax],
|
||||
];
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.1', '<')) {
|
||||
return array_merge($invalidExpr, [
|
||||
if (\version_compare(PHP_VERSION, '7.1', '<')) {
|
||||
return \array_merge($invalidExpr, [
|
||||
['list("a" => _) = array("a" => 1)', $errorPhpParserSyntax],
|
||||
['[] = []', $errorShortListAssign],
|
||||
['[$a] = [1]', $errorShortListAssign],
|
||||
['list("a" => $a) = array("a" => 1)', $errorAssocListAssign],
|
||||
['[$a[0], $a[1]] = [1, 2]', $errorShortListAssign],
|
||||
['[$a->b, $a->c] = [1, 2]', $errorShortListAssign],
|
||||
]);
|
||||
}
|
||||
|
||||
return array_merge($invalidExpr, [
|
||||
return \array_merge($invalidExpr, [
|
||||
['list("a" => _) = array("a" => 1)', $errorPhpParserSyntax],
|
||||
['["a"] = [1]', $errorNonVariableAssign],
|
||||
['[] = []', $errorEmptyList],
|
||||
['[,] = [1,2]', $errorEmptyList],
|
||||
['[,,] = [1,2,3]', $errorEmptyList],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -84,8 +87,8 @@ class ListPassTest extends CodeCleanerTestCase
|
||||
['list($x, $y) = array(1, 2)'],
|
||||
];
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.1', '>=')) {
|
||||
return array_merge($validExpr, [
|
||||
if (\version_compare(PHP_VERSION, '7.1', '>=')) {
|
||||
return \array_merge($validExpr, [
|
||||
['[$a] = array(1)'],
|
||||
['list($b) = [2]'],
|
||||
['[$x, $y] = array(1, 2)'],
|
||||
@@ -96,6 +99,8 @@ class ListPassTest extends CodeCleanerTestCase
|
||||
['[,$b] = [1,2,3]'],
|
||||
['[$a,,$c] = [1,2,3]'],
|
||||
['[$a,,,] = [1,2,3]'],
|
||||
['[$a[0], $a[1]] = [1, 2]'],
|
||||
['[$a->b, $a->c] = [1, 2]'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class NamespacePassTest extends CodeCleanerTestCase
|
||||
// A new block namespace clears out the current namespace...
|
||||
$this->parseAndTraverse('namespace Gamma { array_merge(); }');
|
||||
|
||||
if (defined('PhpParser\\Node\\Stmt\\Namespace_::KIND_SEMICOLON')) {
|
||||
if (\defined('PhpParser\\Node\\Stmt\\Namespace_::KIND_SEMICOLON')) {
|
||||
$this->assertNull($this->cleaner->getNamespace());
|
||||
} else {
|
||||
// But not for PHP-Parser < v3.1.2 :(
|
||||
|
||||
@@ -20,7 +20,7 @@ class NoReturnValueTest extends ParserTestCase
|
||||
public function testCreate()
|
||||
{
|
||||
$stmt = NoReturnValue::create();
|
||||
if (class_exists('PhpParser\Node\Stmt\Expression')) {
|
||||
if (\class_exists('PhpParser\Node\Stmt\Expression')) {
|
||||
$stmt = new Expression($stmt);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class RequirePassTest extends CodeCleanerTestCase
|
||||
*/
|
||||
public function testResolveEmptyWarnings($file)
|
||||
{
|
||||
if (!E_WARNING & error_reporting()) {
|
||||
if (!E_WARNING & \error_reporting()) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class StrictTypesPassTest extends CodeCleanerTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '7.0', '<')) {
|
||||
if (\version_compare(PHP_VERSION, '7.0', '<')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class UseStatementPassTest extends CodeCleanerTestCase
|
||||
|
||||
public function groupUseStatements()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '7.0', '<')) {
|
||||
if (\version_compare(PHP_VERSION, '7.0', '<')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,7 @@ class ValidClassNamePassTest extends CodeCleanerTestCase
|
||||
['DateTime::$someMethod()'],
|
||||
['Psy\Test\CodeCleaner\Fixtures\ClassWithStatic::doStuff()'],
|
||||
['Psy\Test\CodeCleaner\Fixtures\ClassWithCallStatic::doStuff()'],
|
||||
['Psy\Test\CodeCleaner\Fixtures\TraitWithStatic::doStuff()'],
|
||||
|
||||
// Allow `self` and `static` as class names.
|
||||
['
|
||||
@@ -305,12 +306,12 @@ class ValidClassNamePassTest extends CodeCleanerTestCase
|
||||
];
|
||||
|
||||
// Ugh. There's gotta be a better way to test for this.
|
||||
if (class_exists('PhpParser\ParserFactory')) {
|
||||
if (\class_exists('PhpParser\ParserFactory')) {
|
||||
// PHP 7.0 anonymous classes, only supported by PHP Parser v2.x
|
||||
$valid[] = ['$obj = new class() {}'];
|
||||
}
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.5', '>=')) {
|
||||
if (\version_compare(PHP_VERSION, '5.5', '>=')) {
|
||||
$valid[] = ['interface A {} A::class'];
|
||||
$valid[] = ['interface A {} A::CLASS'];
|
||||
$valid[] = ['class A {} A::class'];
|
||||
|
||||
@@ -47,7 +47,7 @@ class ValidConstructorPassTest extends CodeCleanerTestCase
|
||||
['class A { private static function a() {}}'],
|
||||
];
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.0', '>=')) {
|
||||
if (\version_compare(PHP_VERSION, '7.0', '>=')) {
|
||||
$data[] = ['class A { public function A(): ?array {}}'];
|
||||
$data[] = ['class A { public function a(): ?array {}}'];
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class ValidConstructorPassTest extends CodeCleanerTestCase
|
||||
['namespace B; class A { private static function A() {}}'],
|
||||
];
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.0', '>=')) {
|
||||
if (\version_compare(PHP_VERSION, '7.0', '>=')) {
|
||||
$data[] = ['class A { public static function A() {} public function __construct() {}}'];
|
||||
$data[] = ['class A { private function __construct() {} public static function A(): ?array {}}'];
|
||||
$data[] = ['namespace B; class A { private static function A(): ?array {}}'];
|
||||
|
||||
Reference in New Issue
Block a user