Skip to content

Commit c64b46b

Browse files
committed
TBF
1 parent c1985ee commit c64b46b

File tree

10 files changed

+34
-37
lines changed

10 files changed

+34
-37
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66

77
jobs:
88
tests:
9-
runs-on: ubuntu-22.04
9+
runs-on: ubuntu-24.04
1010
strategy:
1111
matrix:
12-
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
12+
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
1313
name: PHP ${{ matrix.php }}
1414
steps:
15-
- uses: actions/checkout@v3
16-
# required for "git tag" presence for MonorepoBuilder split and ChangelogLinker git tags resolver; default is 1
17-
- run: git fetch --depth=100000 origin
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 5
1818
# see https://github.com/shivammathur/setup-php
1919
- uses: shivammathur/setup-php@v2
2020
with:
@@ -25,10 +25,11 @@ jobs:
2525
- run: composer phpunit
2626

2727
tests_lowest_dependencies:
28-
runs-on: ubuntu-22.04
28+
runs-on: ubuntu-24.04
2929
steps:
30-
- uses: actions/checkout@v3
31-
- run: git fetch --depth=100000 origin
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 5
3233
# see https://github.com/shivammathur/setup-php
3334
- uses: shivammathur/setup-php@v2
3435
with:

lib/MC/Google/Visualization.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
use MC\Parser\Token;
1515
use PDO;
1616
use PDOException;
17+
use Tests\VisualizationTest;
1718

1819
/**
1920
* Provide a working implementation of the Google Visualization Query data source that works with a database
2021
* (or any other custom backend). The documentation for the query language itself and how to use it with Google
2122
* Visualizations can be found here: http://code.google.com/apis/visualization/documentation/querylanguage.html.
2223
*
23-
* @see \Tests\VisualizationTest
24+
* @see VisualizationTest
2425
*
2526
* @phpstan-type FieldSpec array{
2627
* type: string,
@@ -106,10 +107,8 @@ class Visualization
106107
* Create a new instance. This must be done before the library can be used. Pass in a PDO connection and
107108
* dialect if MC_Google_Visualization will handle the entire request cycle.
108109
*
109-
* @param null|PDO $db the database connection to use
110-
* @param string $dialect the SQL dialect to use - one of "mysql", "postgres", or "sqlite"
111-
*
112-
* @phpstan-param 'mysql'|'postgres'|'sqlite' $dialect
110+
* @param null|PDO $db the database connection to use
111+
* @param 'mysql'|'postgres'|'sqlite' $dialect the SQL dialect to use
113112
*
114113
* @throws Visualization_Error
115114
*/
@@ -140,9 +139,7 @@ public function setDB(?PDO $db = null): void
140139
/**
141140
* Set the dialect to use when generating SQL statements.
142141
*
143-
* @param string $dialect one of "mysql", "postgres", or "sqlite"
144-
*
145-
* @phpstan-param 'mysql'|'postgres'|'sqlite' $dialect
142+
* @param 'mysql'|'postgres'|'sqlite' $dialect the SQL dialect to use
146143
*
147144
* @throws Visualization_Error
148145
*/
@@ -158,11 +155,8 @@ public function setSqlDialect(string $dialect): void
158155
/**
159156
* Change the default format string to use for a particular data type.
160157
*
161-
* @param string $type the data type to change - one of "date", "datetime", "time", "boolean", or "number"
162-
*
163-
* @phpstan-param 'date'|'datetime'|'time'|'boolean'|'number' $type
164-
*
165-
* @param string $format the format string to use for the data type
158+
* @param string $format the format string to use for the data type
159+
* @param 'boolean'|'date'|'datetime'|'number'|'time' $type the data type to change
166160
*
167161
* @throws Visualization_Error
168162
*/
@@ -737,7 +731,7 @@ public function getGrammar(): Def
737731
*
738732
* @throws ParseError
739733
* @throws Visualization_QueryError
740-
* @throws Parser\DefError
734+
* @throws DefError
741735
*/
742736
public function parseQuery(string $str): array
743737
{
@@ -887,7 +881,7 @@ public function parseQuery(string $str): array
887881
*
888882
* @return string the string to output that will cause the visualization client to detect an error
889883
*/
890-
protected function handleError(int $reqid, string $detailMsg, string $handler = 'google.visualization.Query.setResponse', string $code = 'error', string $summaryMsg = null): string
884+
protected function handleError(int $reqid, string $detailMsg, string $handler = 'google.visualization.Query.setResponse', string $code = 'error', ?string $summaryMsg = null): string
891885
{
892886
if (null === $summaryMsg) {
893887
$summaryMsg = $detailMsg;
@@ -1292,7 +1286,7 @@ protected function getFieldQuote(): string
12921286
*
12931287
* @return string the SQL string for this field, with an op
12941288
*/
1295-
protected function getFieldSQL(string $name, array $spec, bool $alias = false, string $func = null, array $pivot = null, array $pivotFields = null): string
1289+
protected function getFieldSQL(string $name, array $spec, bool $alias = false, ?string $func = null, ?array $pivot = null, ?array $pivotFields = null): string
12961290
{
12971291
$sql = $spec['field'];
12981292
$q = $this->getFieldQuote();
@@ -1360,7 +1354,7 @@ protected function addDependantCallbackFields(array $fieldSpec, array $entity, a
13601354
* @param Token $token the token or token group to recursively parse
13611355
* @param null|array $fields the collector array reference to receive the flattened select field values
13621356
*/
1363-
protected function parseFieldTokens(Token $token, array &$fields = null): void
1357+
protected function parseFieldTokens(Token $token, ?array &$fields = null): void
13641358
{
13651359
if ('*' === $token->value) {
13661360
return;
@@ -1392,7 +1386,7 @@ protected function parseFieldTokens(Token $token, array &$fields = null): void
13921386
* @param Token $token the token or token group to parse
13931387
* @param null|array<array{type: string, value: string}> $where the collector array of tokens that make up the where clause
13941388
*/
1395-
protected function parseWhereTokens(Token $token, array &$where = null): void
1389+
protected function parseWhereTokens(Token $token, ?array &$where = null): void
13961390
{
13971391
if (!is_array($where)) {
13981392
$where = [];

lib/MC/Parser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
use MC\Parser\Def\Set;
1515
use MC\Parser\Def\Word;
1616
use MC\Parser\DefError;
17+
use Tests\ParserTest;
1718

1819
/**
1920
* Parser-generator class with an easy PHP-based API, similar to the pyparsing module in philosophy.
2021
*
21-
* @see \Tests\ParserTest
22+
* @see ParserTest
2223
*/
2324
class Parser
2425
{
@@ -48,7 +49,7 @@ public function oneOf(Def ...$args): OneOf
4849
/**
4950
* Return a Word that matches a set of possible characters not separated by whitespace.
5051
*/
51-
public function word(string $firstChars, string $restChars = null): Word
52+
public function word(string $firstChars, ?string $restChars = null): Word
5253
{
5354
return new Word($firstChars, $restChars);
5455
}

lib/MC/Parser/Def.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function parsePart(string $str, int $loc): array
4747
[$loc, $tok] = $this->_parse($str, $loc);
4848

4949
$char = @$str[$loc++];
50+
// @phpstan-ignore-next-line
5051
while (('' !== $char) && Parser::isWhitespace($char)) {
5152
$char = @$str[$loc++];
5253
}

lib/MC/Parser/Def/Regex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Regex extends Def
2929
/** @var int */
3030
public $retgroup = 0;
3131

32-
public function __construct(string $regex = null, string $flags = null, string $errstr = null)
32+
public function __construct(?string $regex = null, ?string $flags = null, ?string $errstr = null)
3333
{
3434
if (null !== $regex) {
3535
$this->regex = $regex;

lib/MC/Parser/Def/Word.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Word extends Regex
1313
* @param string $firstChars the characters allowed as the first character in the word
1414
* @param null|string $restChars the characters allowed as the rest of the word - defaults to same as $first_chars
1515
*/
16-
public function __construct(string $firstChars, string $restChars = null)
16+
public function __construct(string $firstChars, ?string $restChars = null)
1717
{
1818
parent::__construct();
1919

lib/MC/Parser/DefError.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44

55
namespace MC\Parser;
66

7-
class DefError extends Error
8-
{
9-
}
7+
class DefError extends Error {}

lib/MC/Parser/Error.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66

77
use Exception;
88

9-
class Error extends Exception
10-
{
11-
}
9+
class Error extends Exception {}

tests/ExampleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public function testQueryJoins(): void
141141

142142
$output = $vis->handleRequest(false, $parameters);
143143

144+
// hack, different PHP version have different float rounding
145+
$output = preg_replace('/69\.22149730656[0-9]+/', '69.22149730656', $output);
146+
assert(is_string($output));
147+
144148
// file_put_contents(__DIR__.'/result3.js', $output);
145149
self::assertStringEqualsFile(__DIR__.'/result3.js', $output);
146150
}

tests/result3.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)