diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2019-12-14 11:05:18 -0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2019-12-14 11:05:18 -0300 |
commit | 9d3d3b3e39162a8b5329e7a446b2f359b6e99c9d (patch) | |
tree | eaf5c629483d0b6363efb81e15821b47086f3637 | |
parent | 4c945b89aad24ee3c73ae94c06f2bc858a858956 (diff) | |
download | sql-parser-9d3d3b3e39162a8b5329e7a446b2f359b6e99c9d.zip sql-parser-9d3d3b3e39162a8b5329e7a446b2f359b6e99c9d.tar.gz sql-parser-9d3d3b3e39162a8b5329e7a446b2f359b6e99c9d.tar.bz2 |
Reference classes via a use statement
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
-rw-r--r-- | src/Component.php | 10 | ||||
-rw-r--r-- | src/Core.php | 8 | ||||
-rw-r--r-- | src/Exceptions/LexerException.php | 4 | ||||
-rw-r--r-- | src/Exceptions/LoaderException.php | 4 | ||||
-rw-r--r-- | src/Exceptions/ParserException.php | 3 | ||||
-rw-r--r-- | src/Statements/InsertStatement.php | 2 | ||||
-rw-r--r-- | src/Statements/PurgeStatement.php | 1 | ||||
-rw-r--r-- | src/TokensList.php | 4 | ||||
-rw-r--r-- | src/Translator.php | 6 | ||||
-rw-r--r-- | src/UtfString.php | 13 | ||||
-rw-r--r-- | tests/Components/ComponentTest.php | 5 | ||||
-rw-r--r-- | tests/Lexer/ContextTest.php | 3 | ||||
-rw-r--r-- | tests/Misc/UtfStringTest.php | 5 | ||||
-rw-r--r-- | tests/Utils/CLITest.php | 3 | ||||
-rw-r--r-- | tests/Utils/FormatterTest.php | 3 | ||||
-rw-r--r-- | tools/ContextGenerator.php | 6 | ||||
-rw-r--r-- | tools/TestGenerator.php | 11 |
17 files changed, 57 insertions, 34 deletions
diff --git a/src/Component.php b/src/Component.php index 520735b..c461c78 100644 --- a/src/Component.php +++ b/src/Component.php @@ -11,6 +11,8 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser; +use Exception; + /** * A component (of a statement) is a part of a statement that is common to * multiple query types. @@ -29,7 +31,7 @@ abstract class Component * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing * - * @throws \Exception not implemented yet + * @throws Exception not implemented yet * * @return mixed */ @@ -40,7 +42,7 @@ abstract class Component ) { // This method should be abstract, but it can't be both static and // abstract. - throw new \Exception(Translator::gettext('Not implemented yet.')); + throw new Exception(Translator::gettext('Not implemented yet.')); } /** @@ -52,7 +54,7 @@ abstract class Component * @param mixed $component the component to be built * @param array $options parameters for building * - * @throws \Exception not implemented yet + * @throws Exception not implemented yet * * @return string */ @@ -60,7 +62,7 @@ abstract class Component { // This method should be abstract, but it can't be both static and // abstract. - throw new \Exception(Translator::gettext('Not implemented yet.')); + throw new Exception(Translator::gettext('Not implemented yet.')); } /** diff --git a/src/Core.php b/src/Core.php index 1965a2f..8783ea8 100644 --- a/src/Core.php +++ b/src/Core.php @@ -6,6 +6,8 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser; +use Exception; + class Core { /** @@ -24,7 +26,7 @@ class Core * error might be false positive or a partial result (even a bad one) * might be needed. * - * @var \Exception[] + * @var Exception[] * * @see Core::error() */ @@ -33,9 +35,9 @@ class Core /** * Creates a new error log. * - * @param \Exception $error the error exception + * @param Exception $error the error exception * - * @throws \Exception throws the exception, if strict mode is enabled + * @throws Exception throws the exception, if strict mode is enabled */ public function error($error) { diff --git a/src/Exceptions/LexerException.php b/src/Exceptions/LexerException.php index 7dd85a4..857d09b 100644 --- a/src/Exceptions/LexerException.php +++ b/src/Exceptions/LexerException.php @@ -6,6 +6,8 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Exceptions; +use Exception; + /** * Exception thrown by the lexer. * @@ -13,7 +15,7 @@ namespace PhpMyAdmin\SqlParser\Exceptions; * * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ -class LexerException extends \Exception +class LexerException extends Exception { /** * The character that produced this error. diff --git a/src/Exceptions/LoaderException.php b/src/Exceptions/LoaderException.php index d809876..41d04ff 100644 --- a/src/Exceptions/LoaderException.php +++ b/src/Exceptions/LoaderException.php @@ -6,6 +6,8 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Exceptions; +use Exception; + /** * Exception thrown by the lexer. * @@ -13,7 +15,7 @@ namespace PhpMyAdmin\SqlParser\Exceptions; * * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ -class LoaderException extends \Exception +class LoaderException extends Exception { /** * The failed load name. diff --git a/src/Exceptions/ParserException.php b/src/Exceptions/ParserException.php index 575eeb1..4cf6977 100644 --- a/src/Exceptions/ParserException.php +++ b/src/Exceptions/ParserException.php @@ -6,6 +6,7 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Exceptions; +use Exception; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +16,7 @@ use PhpMyAdmin\SqlParser\Token; * * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ -class ParserException extends \Exception +class ParserException extends Exception { /** * The token that produced this error. diff --git a/src/Statements/InsertStatement.php b/src/Statements/InsertStatement.php index 265929d..383b025 100644 --- a/src/Statements/InsertStatement.php +++ b/src/Statements/InsertStatement.php @@ -6,8 +6,8 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; -use PhpMyAdmin\SqlParser\Components\ArrayObj; use PhpMyAdmin\SqlParser\Components\Array2d; +use PhpMyAdmin\SqlParser\Components\ArrayObj; use PhpMyAdmin\SqlParser\Components\IntoKeyword; use PhpMyAdmin\SqlParser\Components\OptionsArray; use PhpMyAdmin\SqlParser\Components\SetOperation; diff --git a/src/Statements/PurgeStatement.php b/src/Statements/PurgeStatement.php index eee6f4a..10d726e 100644 --- a/src/Statements/PurgeStatement.php +++ b/src/Statements/PurgeStatement.php @@ -7,7 +7,6 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; use PhpMyAdmin\SqlParser\Components\Expression; -use PhpMyAdmin\SqlParser\Components\OptionsArray; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Statement; use PhpMyAdmin\SqlParser\Token; diff --git a/src/TokensList.php b/src/TokensList.php index 507d68b..d56fb98 100644 --- a/src/TokensList.php +++ b/src/TokensList.php @@ -6,6 +6,8 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser; +use ArrayAccess; + /** * A structure representing a list of tokens. * @@ -13,7 +15,7 @@ namespace PhpMyAdmin\SqlParser; * * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ -class TokensList implements \ArrayAccess +class TokensList implements ArrayAccess { /** * The array of tokens. diff --git a/src/Translator.php b/src/Translator.php index a169632..2c28370 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -6,12 +6,14 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser; +use PhpMyAdmin\MoTranslator\Loader; + class Translator { /** * The MoTranslator loader object. * - * @var \PhpMyAdmin\MoTranslator\Loader + * @var Loader */ private static $loader; @@ -29,7 +31,7 @@ class Translator { if (is_null(self::$loader)) { // Create loader object - self::$loader = new \PhpMyAdmin\MoTranslator\Loader(); + self::$loader = new Loader(); // Set locale self::$loader->setlocale( diff --git a/src/UtfString.php b/src/UtfString.php index 9e6e55b..1a88a6b 100644 --- a/src/UtfString.php +++ b/src/UtfString.php @@ -13,6 +13,9 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser; +use ArrayAccess; +use Exception; + /** * Implements array-like access for UTF-8 strings. * @@ -22,7 +25,7 @@ namespace PhpMyAdmin\SqlParser; * * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ -class UtfString implements \ArrayAccess +class UtfString implements ArrayAccess { /** * The raw, multi-byte string. @@ -141,11 +144,11 @@ class UtfString implements \ArrayAccess * @param int $offset the offset to be set * @param string $value the value to be set * - * @throws \Exception not implemented + * @throws Exception not implemented */ public function offsetSet($offset, $value) { - throw new \Exception('Not implemented.'); + throw new Exception('Not implemented.'); } /** @@ -153,11 +156,11 @@ class UtfString implements \ArrayAccess * * @param int $offset the value to be unset * - * @throws \Exception not implemented + * @throws Exception not implemented */ public function offsetUnset($offset) { - throw new \Exception('Not implemented.'); + throw new Exception('Not implemented.'); } /** diff --git a/tests/Components/ComponentTest.php b/tests/Components/ComponentTest.php index ce7c68f..1044289 100644 --- a/tests/Components/ComponentTest.php +++ b/tests/Components/ComponentTest.php @@ -7,6 +7,7 @@ use PhpMyAdmin\SqlParser\Component; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\TokensList; +use Throwable; class ComponentTest extends TestCase { @@ -17,14 +18,14 @@ class ComponentTest extends TestCase public function testParse() { $this->expectExceptionMessage('Not implemented yet.'); - $this->expectException(\Exception::class); + $this->expectException(Throwable::class); Component::parse(new Parser(), new TokensList()); } public function testBuild() { $this->expectExceptionMessage('Not implemented yet.'); - $this->expectException(\Exception::class); + $this->expectException(Throwable::class); Component::build(null); } } diff --git a/tests/Lexer/ContextTest.php b/tests/Lexer/ContextTest.php index 83207c3..d713059 100644 --- a/tests/Lexer/ContextTest.php +++ b/tests/Lexer/ContextTest.php @@ -5,6 +5,7 @@ namespace PhpMyAdmin\SqlParser\Tests\Lexer; use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Tests\TestCase; +use Throwable; class ContextTest extends TestCase { @@ -106,7 +107,7 @@ class ContextTest extends TestCase public function testLoadError() { $this->expectExceptionMessage('Specified context ("\PhpMyAdmin\SqlParser\Contexts\ContextFoo") does not exist.'); - $this->expectException(\Exception::class); + $this->expectException(Throwable::class); Context::load('Foo'); } diff --git a/tests/Misc/UtfStringTest.php b/tests/Misc/UtfStringTest.php index c83339a..d351e77 100644 --- a/tests/Misc/UtfStringTest.php +++ b/tests/Misc/UtfStringTest.php @@ -5,6 +5,7 @@ namespace PhpMyAdmin\SqlParser\Tests\Misc; use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\UtfString; +use Throwable; class UtfStringTest extends TestCase { @@ -40,7 +41,7 @@ class UtfStringTest extends TestCase public function testSet() { $this->expectExceptionMessage('Not implemented.'); - $this->expectException(\Exception::class); + $this->expectException(Throwable::class); $str = new UtfString(''); $str[0] = 'a'; } @@ -48,7 +49,7 @@ class UtfStringTest extends TestCase public function testUnset() { $this->expectExceptionMessage('Not implemented.'); - $this->expectException(\Exception::class); + $this->expectException(Throwable::class); $str = new UtfString(''); unset($str[0]); } diff --git a/tests/Utils/CLITest.php b/tests/Utils/CLITest.php index ec69ad9..6d0ea4c 100644 --- a/tests/Utils/CLITest.php +++ b/tests/Utils/CLITest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Tests\Utils; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PhpMyAdmin\SqlParser\Utils\CLI; class CLITest extends TestCase { @@ -22,7 +23,7 @@ class CLITest extends TestCase */ public function testGetopt() { - $cli = new \PhpMyAdmin\SqlParser\Utils\CLI(); + $cli = new CLI(); $this->assertEquals( $cli->getopt('', []), [] diff --git a/tests/Utils/FormatterTest.php b/tests/Utils/FormatterTest.php index 08b7377..0c09215 100644 --- a/tests/Utils/FormatterTest.php +++ b/tests/Utils/FormatterTest.php @@ -5,6 +5,7 @@ namespace PhpMyAdmin\SqlParser\Tests\Utils; use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Utils\Formatter; +use ReflectionMethod; class FormatterTest extends TestCase { @@ -51,7 +52,7 @@ class FormatterTest extends TestCase 'formats' => $overriding, ]; - $reflectionMethod = new \ReflectionMethod($formatter, 'getMergedOptions'); + $reflectionMethod = new ReflectionMethod($formatter, 'getMergedOptions'); $reflectionMethod->setAccessible(true); $this->assertEquals($expectedOptions, $reflectionMethod->invoke($formatter, $overridingOptions)); } diff --git a/tools/ContextGenerator.php b/tools/ContextGenerator.php index ac24156..7645564 100644 --- a/tools/ContextGenerator.php +++ b/tools/ContextGenerator.php @@ -3,6 +3,8 @@ declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Tools; +use Exception; + require_once __DIR__ . '/../vendor/autoload.php'; /** @@ -391,9 +393,9 @@ if (count($argv) >= 3) { // Checking if all directories are valid. if (! is_dir($input)) { - throw new \Exception('The input directory does not exist.'); + throw new Exception('The input directory does not exist.'); } elseif (! is_dir($output)) { - throw new \Exception('The output directory does not exist.'); + throw new Exception('The output directory does not exist.'); } // Finally, building the tests. diff --git a/tools/TestGenerator.php b/tools/TestGenerator.php index d52e708..abeeb3e 100644 --- a/tools/TestGenerator.php +++ b/tools/TestGenerator.php @@ -5,6 +5,7 @@ namespace PhpMyAdmin\SqlParser\Tools; require_once '../vendor/autoload.php'; +use Exception; use PhpMyAdmin\SqlParser\Lexer; use PhpMyAdmin\SqlParser\Parser; @@ -111,7 +112,7 @@ class TestGenerator { // Support query types: `lexer` / `parser`. if (! in_array($type, ['lexer', 'parser'])) { - throw new \Exception('Unknown test type (expected `lexer` or `parser`).'); + throw new Exception('Unknown test type (expected `lexer` or `parser`).'); } /** @@ -123,7 +124,7 @@ class TestGenerator // There is no point in generating a test without a query. if (empty($query)) { - throw new \Exception('No input query specified.'); + throw new Exception('No input query specified.'); } $test = static::generate($query, $type); @@ -214,11 +215,11 @@ if (count($argv) >= 3) { // Checking if all directories are valid. if (! is_dir($input)) { - throw new \Exception('The input directory does not exist.'); + throw new Exception('The input directory does not exist.'); } elseif (! is_dir($output)) { - throw new \Exception('The output directory does not exist.'); + throw new Exception('The output directory does not exist.'); } elseif (($debug !== null) && (! is_dir($debug))) { - throw new \Exception('The debug directory does not exist.'); + throw new Exception('The debug directory does not exist.'); } // Finally, building the tests. |