From 72ec8fdbe8c3b9a35f3dfca1c3d60d1ec8f1790a Mon Sep 17 00:00:00 2001 From: Damien Debin Date: Fri, 7 Jan 2022 14:10:59 +0100 Subject: [PATCH] Adds compatibility with PHP 8.0. Drop compatibility with PHP 7.0. --- .gitattributes | 10 +++---- .github/workflows/main.yml | 12 ++++---- .gitignore | 5 ++-- .php-cs-fixer.php | 36 +++++++++++++++++++++++ .php_cs | 34 --------------------- composer.json | 16 ++++++---- examples/callback_fields.php | 6 ++-- examples/complete.php | 2 +- examples/joins.php | 2 +- examples/simple.php | 2 +- lib/MC/Google/Visualization.php | 52 ++++++++++++++++++--------------- lib/MC/Parser.php | 6 ++-- lib/MC/Parser/Def.php | 6 ++-- lib/MC/Parser/Def/Literal.php | 2 -- lib/MC/Parser/Def/NOrMore.php | 5 ++-- lib/MC/Parser/Def/OneOf.php | 9 +----- lib/MC/Parser/Def/Recursive.php | 2 -- lib/MC/Parser/Def/Regex.php | 4 +-- lib/MC/Parser/Def/Set.php | 4 +-- lib/MC/Parser/Token.php | 11 ++----- lib/MC/Parser/Token/Group.php | 8 +---- phpstan.neon | 2 -- phpunit.xml | 14 ++++----- tests/ExampleTest.php | 8 ++--- tests/ParserTest.php | 28 +++++++++--------- tests/VisualizationTest.php | 32 ++++++++++---------- 26 files changed, 148 insertions(+), 170 deletions(-) create mode 100644 .php-cs-fixer.php delete mode 100644 .php_cs diff --git a/.gitattributes b/.gitattributes index 5f60206..80b033e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,10 @@ # Ignore all test and documentation with “export-ignore”. /.gitattributes export-ignore /.gitignore export-ignore -/.php_cs export-ignore -/phpstan.neon export-ignore -/phpunit.xml export-ignore -/README.md export-ignore +/.php-cs-fixer.php export-ignore /.github export-ignore +/README.md export-ignore +/phpunit.xml export-ignore +/phpstan.neon export-ignore +/tests export-ignore /examples export-ignore -/tests export-ignore \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 257a784..e50a6e8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,17 +8,17 @@ on: jobs: tests: - runs-on: ubuntu-16.04 + runs-on: ubuntu-latest strategy: matrix: - php: ['7.0', '7.1', '7.2', '7.3', '7.4'] + php: ['7.1', '7.2', '7.3', '7.4', '8.0'] name: PHP ${{ matrix.php }} tests steps: - uses: actions/checkout@v2 # required for "git tag" presence for MonorepoBuilder split and ChangelogLinker git tags resolver; default is 1 - run: git fetch --depth=100000 origin # see https://github.com/shivammathur/setup-php - - uses: shivammathur/setup-php@v1 + - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: none @@ -27,14 +27,14 @@ jobs: - run: composer phpunit tests_lowest_dependencies: - runs-on: ubuntu-16.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - run: git fetch --depth=100000 origin # see https://github.com/shivammathur/setup-php - - uses: shivammathur/setup-php@v1 + - uses: shivammathur/setup-php@v2 with: - php-version: 7.0 + php-version: 7.1 coverage: none - run: composer update --no-progress --prefer-lowest - run: composer phpstan diff --git a/.gitignore b/.gitignore index 3d120a9..26fe71e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor/ -.php_cs.cache +/.*.cache /tests-report-html/ -/composer.lock \ No newline at end of file +/composer.lock +/coverage.xml \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..f585f00 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,36 @@ +exclude('vendor') + ->in(__DIR__) +; + + +$finder = PhpCsFixer\Finder::create() + ->exclude('vendor') + ->in(__DIR__); + +$config = new PhpCsFixer\Config(); +return $config->setRules([ + '@PhpCsFixer' => true, + '@PhpCsFixer:risky' => true, + 'array_syntax' => ['syntax' => 'short'], + 'php_unit_test_class_requires_covers' => false, + 'backtick_to_shell_exec' => true, + 'blank_line_before_statement' => [ + 'statements' => ['declare', 'return', 'case'], + ], + 'comment_to_phpdoc' => false, + 'declare_equal_normalize' => ['space' => 'single'], + 'global_namespace_import' => true, + 'linebreak_after_opening_tag' => true, + 'native_function_invocation' => false, + 'no_unset_on_property' => false, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'phpdoc_to_comment' => false, + 'self_static_accessor' => true, +]) + ->setFinder($finder); diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 210ef95..0000000 --- a/.php_cs +++ /dev/null @@ -1,34 +0,0 @@ -name('.php_cs') - ->exclude('vendor') - ->in(__DIR__) -; - -return Config::create() - ->setRules([ - '@PhpCsFixer' => true, - '@PhpCsFixer:risky' => true, - '@PHP70Migration:risky' => true, - '@PHPUnit75Migration:risky' => true, - 'backtick_to_shell_exec' => true, - 'blank_line_before_statement' => [ - 'statements' => ['declare', 'return', 'case'], - ], - 'comment_to_phpdoc' => false, - 'declare_equal_normalize' => ['space' => 'single'], - 'final_static_access' => true, - 'global_namespace_import' => true, - 'linebreak_after_opening_tag' => true, - 'native_function_invocation' => false, - 'no_unset_on_property' => false, - 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], - 'phpdoc_to_comment' => false, - 'self_static_accessor' => true, - ]) - ->setFinder($finder) - ; \ No newline at end of file diff --git a/composer.json b/composer.json index 0ce6af2..38717bf 100644 --- a/composer.json +++ b/composer.json @@ -22,15 +22,19 @@ } ], "require": { - "php": "^7.0", + "php": "^7.1 || 8.0.*", "ext-json": "*", "ext-pdo": "*" }, "require-dev": { - "phpstan/phpstan": "^0.9 || ^0.10 || ^0.11 || ^0.12", - "phpstan/phpstan-phpunit": "^0.9 || ^0.10 || ^0.11 || ^0.12", - "phpstan/phpstan-strict-rules": "^0.9 || ^0.10 || ^0.11 || ^0.12", - "phpunit/phpunit": "^6.0 || ^7.0" + "friendsofphp/php-cs-fixer": "^3.0", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "config": { + "sort-packages": true }, "autoload": { "psr-4": { @@ -44,6 +48,8 @@ }, "scripts": { "phpstan": "phpstan analyse -l max lib tests", + "php-cs-fixer": "php-cs-fixer fix --allow-risky=yes", + "php-cs-fixer-dry-run": "php-cs-fixer fix --dry-run --allow-risky=yes", "phpunit": "phpunit" } } diff --git a/examples/callback_fields.php b/examples/callback_fields.php index 1c2d287..a1a2d1b 100644 --- a/examples/callback_fields.php +++ b/examples/callback_fields.php @@ -10,10 +10,8 @@ /** * @param mixed $row - * - * @return null|string */ -function most_common($row) +function most_common($row): ?string { $forms = ['pill', 'iud', 'condom', 'sterile_total', 'other_modern', 'traditional']; $maxForm = -1; @@ -53,7 +51,7 @@ function most_common($row) ]); $vis->handleRequest(); - die(); + exit(); } ?> diff --git a/examples/complete.php b/examples/complete.php index 7542b1f..ed12d92 100644 --- a/examples/complete.php +++ b/examples/complete.php @@ -34,7 +34,7 @@ $vis->setDefaultEntity('timeline'); $vis->handleRequest(); - die(); + exit(); } ?> diff --git a/examples/joins.php b/examples/joins.php index a06c5e9..3d685c9 100644 --- a/examples/joins.php +++ b/examples/joins.php @@ -31,7 +31,7 @@ ]); $vis->handleRequest(); - die(); + exit(); } ?> diff --git a/examples/simple.php b/examples/simple.php index f34fc93..b3f7d70 100644 --- a/examples/simple.php +++ b/examples/simple.php @@ -21,7 +21,7 @@ ]); $vis->handleRequest(); - die(); + exit(); } ?> diff --git a/lib/MC/Google/Visualization.php b/lib/MC/Google/Visualization.php index 99a887e..820508f 100644 --- a/lib/MC/Google/Visualization.php +++ b/lib/MC/Google/Visualization.php @@ -99,7 +99,7 @@ public function __construct(PDO $db = null, string $dialect = 'mysql') * * @param null|PDO $db the database connection to use - or null if you want to handle your own queries */ - public function setDB(PDO $db = null) + public function setDB(PDO $db = null): void { if (null !== $db) { $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -115,7 +115,7 @@ public function setDB(PDO $db = null) * * @throws Visualization_Error */ - public function setSqlDialect(string $dialect) + public function setSqlDialect(string $dialect): void { if ('mysql' !== $dialect && 'postgres' !== $dialect && 'sqlite' !== $dialect) { throw new Visualization_Error('SQL dialects must be one of "mysql", "postgres", or "sqlite" - not "'.$dialect.'"'); @@ -132,7 +132,7 @@ public function setSqlDialect(string $dialect) * * @throws Visualization_Error */ - public function setDefaultFormat(string $type, string $format) + public function setDefaultFormat(string $type, string $format): void { if (!isset($this->defaultFormat[$type])) { throw new Visualization_Error('Unknown or unformattable type: "'.$type.'"'); @@ -167,7 +167,7 @@ public function handleRequest(bool $echo = true, array $queryParams = null): str ]; $paramlist = explode(';', $queryParams['tqx']); foreach ($paramlist as $paramstr) { - list($name, $val) = explode(':', $paramstr); + [$name, $val] = explode(':', $paramstr); $params[$name] = $val; } @@ -412,7 +412,7 @@ public function generateMetadata(array $query): array * * @throws Visualization_Error */ - public function addEntity(string $name, array $spec = []) + public function addEntity(string $name, array $spec = []): void { $entity = ['table' => $spec['table'] ?? $name, 'fields' => [], 'joins' => []]; $this->entities[$name] = $entity; @@ -441,7 +441,7 @@ public function addEntity(string $name, array $spec = []) * * @throws Visualization_Error */ - public function setDefaultEntity(string $default = null) + public function setDefaultEntity(string $default = null): void { if (null !== $default && !isset($this->entities[$default])) { throw new Visualization_Error('No entity exists with name "'.$default.'"'); @@ -528,7 +528,7 @@ public function getRowValues(array $row, array $meta): string case 'boolean': $val = (bool) $val; - list($formatFalse, $formatTrue) = explode(':', $format, 2); + [$formatFalse, $formatTrue] = explode(':', $format, 2); $formatted = $val ? $formatTrue : $formatFalse; $val = json_encode($val); break; @@ -536,18 +536,19 @@ public function getRowValues(array $row, array $meta): string case 'date': if (!is_numeric($val) || (is_string($val) && (6 !== strlen($val)))) { $time = strtotime($val); - list($year, $month, $day) = explode('-', date('Y-m-d', $time)); + [$year, $month, $day] = explode('-', date('Y-m-d', $time)); $formatted = date($format, $time); - } else { - assert(is_string($val)); + } elseif (is_string($val)) { $year = substr($val, 0, 4); $week = substr($val, -2); $time = strtotime($year.'0104 +'.$week.' weeks'); assert(false !== $time); $monday = strtotime('-'.((int) date('w', $time) - 1).' days', $time); assert(false !== $monday); - list($year, $month, $day) = explode('-', date('Y-m-d', $monday)); + [$year, $month, $day] = explode('-', date('Y-m-d', $monday)); $formatted = date($format, $monday); + } else { + throw new Visualization_Error('Incompatible value with field type "'.$type.'"'); } $val = 'new Date('.(int) $year.','.((int) $month - 1).','.(int) $day.')'; break; @@ -555,7 +556,7 @@ public function getRowValues(array $row, array $meta): string case 'datetime': case 'timestamp': $time = strtotime($val); - list($year, $month, $day, $hour, $minute, $second) = explode('-', date('Y-m-d-H-i-s', $time)); + [$year, $month, $day, $hour, $minute, $second] = explode('-', date('Y-m-d-H-i-s', $time)); // MALC - Force us to consider the date as UTC... $val = 'new Date(Date.UTC('.(int) $year.','.((int) $month - 1).','.(int) $day.','.(int) $hour.','.(int) $minute.','.(int) $second.'))'; $formatted = date($format, $time); @@ -563,21 +564,24 @@ public function getRowValues(array $row, array $meta): string case 'time': $time = strtotime($val); - list($hour, $minute, $second) = explode('-', date('H-i-s', $time)); + [$hour, $minute, $second] = explode('-', date('H-i-s', $time)); $val = '['.(int) $hour.','.(int) $minute.','.(int) $second.',0]'; $formatted = date($format, $time); break; case 'binary': - $formatted = '0x'.current(unpack('H*', $val)); - $val = '0x'.current(unpack('H*', $val)); - $val = json_encode($val); + $bin = unpack('H*', $val); + if (false === $bin) { + throw new Visualization_Error('Incompatible value with field type "'.$type.'"'); + } + $formatted = '0x'.current($bin); + $val = json_encode($formatted); break; default: throw new Visualization_Error('Unknown field type "'.$type.'"'); } - if (isset($callbackResponse['formatted'])) { + if (is_array($callbackResponse) && isset($callbackResponse['formatted'])) { $formatted = $callbackResponse['formatted']; } @@ -855,7 +859,7 @@ protected function handleError(int $reqid, string $detailMsg, string $handler = * * @throws Visualization_Error */ - protected function addEntityField(string $entity, string $field, array $spec) + protected function addEntityField(string $entity, string $field, array $spec): void { if (!isset($spec['callback']) && (isset($spec['fields']) || isset($spec['extra']))) { throw new Visualization_Error('"fields" and "extra" parameters only apply to callback fields'); @@ -881,7 +885,7 @@ protected function addEntityField(string $entity, string $field, array $spec) * * @throws Visualization_Error */ - protected function addEntityJoin(string $entity, string $join, string $sql) + protected function addEntityJoin(string $entity, string $join, string $sql): void { if (!isset($this->entities[$entity])) { throw new Visualization_Error('No entity table defined with name "'.$entity.'"'); @@ -898,7 +902,7 @@ protected function addEntityJoin(string $entity, string $join, string $sql) * * @throws Visualization_Error */ - protected function setEntityWhere(string $entity, string $where) + protected function setEntityWhere(string $entity, string $where): void { if (!isset($this->entities[$entity])) { throw new Visualization_Error('No entity table defined with name "'.$entity.'"'); @@ -1202,7 +1206,7 @@ protected function convertTime(string $value): string * * @return string the limit clause converted to be used inline in a SQL query */ - protected function convertLimit($limit, $offset): string + protected function convertLimit(?int $limit, ?int $offset): string { $sql = ''; if (null !== $limit) { @@ -1279,7 +1283,7 @@ protected function getFieldSQL(string $name, array $spec, bool $alias = false, s * * @throws Visualization_Error */ - protected function addDependantCallbackFields(array $field, array $entity, array &$meta) + protected function addDependantCallbackFields(array $field, array $entity, array &$meta): void { foreach ($field['fields'] as $dependant) { if (!isset($entity['fields'][$dependant])) { @@ -1305,7 +1309,7 @@ protected function addDependantCallbackFields(array $field, array $entity, array * @param Token $token the token or token group to recursively parse * @param null|array $fields the collector array reference to receive the flattened select field values */ - protected function parseFieldTokens(Token $token, array &$fields = null) + protected function parseFieldTokens(Token $token, array &$fields = null): void { if ('*' === $token->value) { return; @@ -1336,7 +1340,7 @@ protected function parseFieldTokens(Token $token, array &$fields = null) * @param Token $token the token or token group to parse * @param null|array $where the collector array of tokens that make up the where clause */ - protected function parseWhereTokens(Token $token, array &$where = null) + protected function parseWhereTokens(Token $token, array &$where = null): void { if (!is_array($where)) { $where = []; diff --git a/lib/MC/Parser.php b/lib/MC/Parser.php index 06065dd..0282d93 100644 --- a/lib/MC/Parser.php +++ b/lib/MC/Parser.php @@ -156,7 +156,7 @@ public function keyword(string $str, bool $caseless = false, bool $fullword = tr */ public function delimitedList(Def $expr, string $delim = ','): Set { - return $this->set($expr, $this->zeroOrMore($this->set($this->literal($delim, false, false)->suppress(), $expr))); + return $this->set($expr, $this->zeroOrMore($this->set($this->literal($delim)->suppress(), $expr))); } /** @@ -223,10 +223,8 @@ public function nums(): string /** * Simple test for whether a character is a whitespace character. - * - * @param mixed $test */ - public static function isWhitespace($test): bool + public static function isWhitespace(string $test): bool { return false !== strpos(self::$whitespace, $test); } diff --git a/lib/MC/Parser/Def.php b/lib/MC/Parser/Def.php index 25f3273..c7dfa45 100644 --- a/lib/MC/Parser/Def.php +++ b/lib/MC/Parser/Def.php @@ -27,7 +27,7 @@ public function parse(string $str): Token { $str = ltrim($str); - list($loc, $tok) = $this->parsePart($str, 0); + [$loc, $tok] = $this->parsePart($str, 0); if ($loc !== strlen($str)) { throw new ParseError('An error occurred: "'.substr($str, $loc).'"', $str, $loc); } @@ -44,7 +44,7 @@ public function parse(string $str): Token */ public function parsePart(string $str, int $loc): array { - list($loc, $tok) = $this->_parse($str, $loc); + [$loc, $tok] = $this->_parse($str, $loc); $char = @$str[$loc++]; while (('' !== $char) && Parser::isWhitespace($char)) { @@ -107,7 +107,7 @@ public function suppress(): self * * @return null|Token the new token, or null if the token should be suppressed */ - public function token($value) + public function token($value): ?Token { if ($this->suppress) { return null; diff --git a/lib/MC/Parser/Def/Literal.php b/lib/MC/Parser/Def/Literal.php index bd75874..36b85e4 100644 --- a/lib/MC/Parser/Def/Literal.php +++ b/lib/MC/Parser/Def/Literal.php @@ -35,8 +35,6 @@ public function __construct(string $str, bool $caseless = false, bool $fullword /** * @throws ParseError - * - * @return mixed[] */ public function _parse(string $str, int $loc): array { diff --git a/lib/MC/Parser/Def/NOrMore.php b/lib/MC/Parser/Def/NOrMore.php index 3936c26..ab0681b 100644 --- a/lib/MC/Parser/Def/NOrMore.php +++ b/lib/MC/Parser/Def/NOrMore.php @@ -23,16 +23,15 @@ public function __construct(Def $expr, int $min) /** * @throws ParseError - * - * @return mixed[] */ public function _parse(string $str, int $loc): array { $toks = $this->tokenGroup(); try { + /** @phpstan-ignore-next-line */ while (true) { - list($loc, $tok) = $this->expr->parsePart($str, $loc); + [$loc, $tok] = $this->expr->parsePart($str, $loc); $toks->append($tok); } } catch (ParseError $parseError) { diff --git a/lib/MC/Parser/Def/OneOf.php b/lib/MC/Parser/Def/OneOf.php index 306c979..20dff16 100644 --- a/lib/MC/Parser/Def/OneOf.php +++ b/lib/MC/Parser/Def/OneOf.php @@ -15,11 +15,6 @@ class OneOf extends Def /** @var Def[] */ public $exprs = []; - /** - * OneOf constructor. - * - * @param mixed[] $exprs - */ public function __construct(array $exprs = []) { $this->exprs = $exprs; @@ -30,8 +25,6 @@ public function __construct(array $exprs = []) * @param int $loc the index to start parsing * * @throws ParseError - * - * @return mixed[] */ public function _parse(string $str, int $loc): array { @@ -39,7 +32,7 @@ public function _parse(string $str, int $loc): array $res = null; foreach ($this->exprs as $expr) { try { - list($loc2, $toks) = $expr->parsePart($str, $loc); + [$loc2, $toks] = $expr->parsePart($str, $loc); if ($loc2 > $maxMatch) { $maxMatch = $loc2; $res = $toks; diff --git a/lib/MC/Parser/Def/Recursive.php b/lib/MC/Parser/Def/Recursive.php index 74d2b56..96b6f47 100644 --- a/lib/MC/Parser/Def/Recursive.php +++ b/lib/MC/Parser/Def/Recursive.php @@ -16,8 +16,6 @@ class Recursive extends Def /** * @throws DefError * @throws ParseError - * - * @return mixed[] */ public function _parse(string $str, int $loc): array { diff --git a/lib/MC/Parser/Def/Regex.php b/lib/MC/Parser/Def/Regex.php index e8484d6..8d3ec34 100644 --- a/lib/MC/Parser/Def/Regex.php +++ b/lib/MC/Parser/Def/Regex.php @@ -13,7 +13,7 @@ class Regex extends Def { /** @var string */ - const DELIMITER = '/'; + public const DELIMITER = '/'; // Subclasses of this can just modify the $regex, $flags, and $errstr properties. @@ -44,8 +44,6 @@ public function __construct(string $regex = null, string $flags = null, string $ /** * @throws ParseError - * - * @return mixed[] */ public function _parse(string $str, int $loc): array { diff --git a/lib/MC/Parser/Def/Set.php b/lib/MC/Parser/Def/Set.php index 49c8bd8..9d8c840 100644 --- a/lib/MC/Parser/Def/Set.php +++ b/lib/MC/Parser/Def/Set.php @@ -25,14 +25,12 @@ public function __construct(array $exprs = []) /** * @param string $str the string to parse * @param int $loc the index to start parsing - * - * @return mixed[] */ public function _parse(string $str, int $loc): array { $res = $this->tokenGroup(); foreach ($this->exprs as $expr) { - list($loc, $toks) = $expr->parsePart($str, $loc); + [$loc, $toks] = $expr->parsePart($str, $loc); if ((null !== $toks) && (!is_array($toks) || (count($toks) > 0))) { $res->append($toks); } diff --git a/lib/MC/Parser/Token.php b/lib/MC/Parser/Token.php index 255b7db..a199a96 100644 --- a/lib/MC/Parser/Token.php +++ b/lib/MC/Parser/Token.php @@ -18,26 +18,19 @@ class Token /** * Token constructor. * - * @param mixed $value - * @param null|string $name + * @param mixed $value */ - public function __construct($value, $name) + public function __construct($value, ?string $name) { $this->value = $value; $this->name = $name; } - /** - * @return mixed[] - */ public function getValues(): array { return [$this->value]; } - /** - * @return mixed[] - */ public function getNameValues(): array { return [[$this->name, $this->value]]; diff --git a/lib/MC/Parser/Token/Group.php b/lib/MC/Parser/Token/Group.php index 2f93656..2aa0fb3 100644 --- a/lib/MC/Parser/Token/Group.php +++ b/lib/MC/Parser/Token/Group.php @@ -27,7 +27,7 @@ public function __construct($name) * * @param null|Token|Token[] $toks one or more token instances */ - public function append($toks) + public function append($toks): void { if (null === $toks) { return; @@ -43,9 +43,6 @@ public function count(): int return count($this->subtoks); } - /** - * @return mixed[] - */ public function getValues(): array { $values = []; @@ -56,9 +53,6 @@ public function getValues(): array return $values; } - /** - * @return mixed[] - */ public function getNameValues(): array { $values = []; diff --git a/phpstan.neon b/phpstan.neon index 1c0d854..101e9e9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,5 +4,3 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon parameters: checkMissingIterableValueType: false - ignoreErrors: - - '#has no return typehint#' \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml index 59a1f8d..46a496c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,16 +1,16 @@ + + + lib + + tests - - - lib - - - \ No newline at end of file + diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php index c4f8307..bcf1257 100644 --- a/tests/ExampleTest.php +++ b/tests/ExampleTest.php @@ -14,7 +14,7 @@ */ final class ExampleTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -26,7 +26,7 @@ protected function setUp() /** * @throws Visualization_Error */ - public function testQueryComplete() + public function testQueryComplete(): void { $db = new PDO('sqlite:'.__DIR__.'/../examples/example.db'); $vis = new Visualization($db); @@ -64,7 +64,7 @@ public function testQueryComplete() /** * @throws Visualization_Error */ - public function testQuerySimple() + public function testQuerySimple(): void { $db = new PDO('sqlite:'.__DIR__.'/../examples/example.db'); $vis = new Visualization($db); @@ -89,7 +89,7 @@ public function testQuerySimple() /** * @throws Visualization_Error */ - public function testQueryJoins() + public function testQueryJoins(): void { $db = new PDO('sqlite:'.__DIR__.'/../examples/example.db'); $vis = new Visualization($db); diff --git a/tests/ParserTest.php b/tests/ParserTest.php index f531600..d6616c7 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -15,7 +15,7 @@ */ final class ParserTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -27,7 +27,7 @@ protected function setUp() /** * @throws ParseError */ - public function testLiteral() + public function testLiteral(): void { $p = new Parser(); $select = $p->keyword('select', true); @@ -40,7 +40,7 @@ public function testLiteral() self::assertSame(['select', 'from'], $selectfrom->parse('select from ')->getValues()); } - public function testName() + public function testName(): void { $p = new Parser(); $select = $p->keyword('select'); @@ -50,7 +50,7 @@ public function testName() self::assertSame('SELECT', $select->getName()); } - public function testToken() + public function testToken(): void { $p = new Parser(); $select = $p->keyword('select'); @@ -61,7 +61,7 @@ public function testToken() self::assertSame([], $token->getChildren()); } - public function testTokenGroup() + public function testTokenGroup(): void { $p = new Parser(); $select = $p->keyword('select'); @@ -77,7 +77,7 @@ public function testTokenGroup() /** * @throws ParseError */ - public function testOneOf() + public function testOneOf(): void { $p = new Parser(); $select = $p->keyword('select'); @@ -90,7 +90,7 @@ public function testOneOf() /** * @throws ParseError */ - public function testOptional() + public function testOptional(): void { $p = new Parser(); $select = $p->keyword('select'); @@ -105,7 +105,7 @@ public function testOptional() /** * @throws ParseError */ - public function testWord() + public function testWord(): void { $p = new Parser(); $select = $p->keyword('select'); @@ -117,7 +117,7 @@ public function testWord() /** * @throws ParseError */ - public function testDelimitedList() + public function testDelimitedList(): void { $p = new Parser(); $select = $p->keyword('select'); @@ -129,7 +129,7 @@ public function testDelimitedList() /** * @throws ParseError */ - public function testRecursive() + public function testRecursive(): void { $p = new Parser(); $expr = $p->recursive(); @@ -142,7 +142,7 @@ public function testRecursive() * @throws DefError * @throws ParseError */ - public function testDelimitedSet() + public function testDelimitedSet(): void { $p = new Parser(); $limit = $p->set($p->keyword('limit'), $p->delimitedList($p->set($p->word($p->alphanums()), $p->quotedString()))); @@ -153,7 +153,7 @@ public function testDelimitedSet() * @throws DefError * @throws ParseError */ - public function testVisParser() + public function testVisParser(): void { $p = new Parser(); $ident = $p->oneOf( @@ -227,7 +227,7 @@ public function testVisParser() /** * @throws DefError */ - public function testQuotedStringEx1() + public function testQuotedStringEx1(): void { $p = new Parser(); $this->expectException(DefError::class); @@ -237,7 +237,7 @@ public function testQuotedStringEx1() /** * @throws DefError */ - public function testQuotedStringEx2() + public function testQuotedStringEx2(): void { $p = new Parser(); $this->expectException(DefError::class); diff --git a/tests/VisualizationTest.php b/tests/VisualizationTest.php index a507c4d..a168214 100644 --- a/tests/VisualizationTest.php +++ b/tests/VisualizationTest.php @@ -17,7 +17,7 @@ */ final class VisualizationTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -31,7 +31,7 @@ protected function setUp() * @throws ParseError * @throws DefError */ - public function testGenSQL() + public function testGenSQL(): void { $vis = new Visualization(); $vis->addEntity('entity', [ @@ -76,7 +76,7 @@ public function testGenSQL() * @throws DefError * @throws ParseError */ - public function testFunctions() + public function testFunctions(): void { $vis = new Visualization(); $vis->addEntity('campaigns', [ @@ -96,7 +96,7 @@ public function testFunctions() * @throws ParseError * @throws DefError */ - public function testSerializeFunction() + public function testSerializeFunction(): void { $vis = new Visualization(); $vis->addEntity('campaigns', [ @@ -118,7 +118,7 @@ public function testSerializeFunction() * @throws DefError * @throws ParseError */ - public function testWhere() + public function testWhere(): void { $vis = new Visualization(); $vis->addEntity('campaigns', [ @@ -138,7 +138,7 @@ public function testWhere() * @throws ParseError * @throws DefError */ - public function testCallback() + public function testCallback(): void { $vis = new Visualization(); $vis->addEntity('campaigns', [ @@ -165,7 +165,7 @@ public function testCallback() * @throws Visualization_Error * @throws Visualization_QueryError */ - public function testOrderBy() + public function testOrderBy(): void { $vis = new Visualization(); $vis->addEntity('campaigns', [ @@ -183,7 +183,7 @@ public function testOrderBy() * @throws ParseError * @throws DefError */ - public function testFormat() + public function testFormat(): void { $vis = new Visualization(); $vis->addEntity('campaigns', [ @@ -206,7 +206,7 @@ public function testFormat() * @throws Visualization_Error * @throws Visualization_QueryError */ - public function testGroupBy() + public function testGroupBy(): void { $vis = new Visualization(); $vis->addEntity('campaigns', [ @@ -224,7 +224,7 @@ public function testGroupBy() * @throws ParseError * @throws DefError */ - public function testPivot() + public function testPivot(): void { if (!in_array('sqlite', PDO::getAvailableDrivers(), true)) { self::markTestSkipped('Pivot tests require the SQLite PDO drivers to be installed'); @@ -258,7 +258,7 @@ public function testPivot() * @throws ParseError * @throws DefError */ - public function testLabelAfterWhereAndGroupBy() + public function testLabelAfterWhereAndGroupBy(): void { $vis = new Visualization(); $vis->addEntity('orders', [ @@ -274,7 +274,7 @@ public function testLabelAfterWhereAndGroupBy() * @throws Visualization_Error * @throws Visualization_QueryError */ - public function testDateLiterals() + public function testDateLiterals(): void { $vis = new Visualization(); $vis->addEntity('orders', [ @@ -289,7 +289,7 @@ public function testDateLiterals() * @throws ParseError * @throws DefError */ - public function testNoFormat() + public function testNoFormat(): void { $vis = new Visualization(); $vis->addEntity('orders', [ @@ -308,7 +308,7 @@ public function testNoFormat() * @throws ParseError * @throws DefError */ - public function testNoValues() + public function testNoValues(): void { $vis = new Visualization(); $vis->addEntity('orders', [ @@ -327,7 +327,7 @@ public function testNoValues() * @throws ParseError * @throws DefError */ - public function testCountNonNumber() + public function testCountNonNumber(): void { $vis = new Visualization(); $vis->addEntity('orders', [ @@ -347,7 +347,7 @@ public function testCountNonNumber() * @throws Visualization_Error * @throws Visualization_QueryError */ - public function testIsNull() + public function testIsNull(): void { $vis = new Visualization(); $vis->addEntity('orders', [