Skip to content

Commit 9560adf

Browse files
committed
Bump minimum PHP to 7.4
1 parent 658c1c2 commit 9560adf

20 files changed

+65
-93
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-24.04
1010
strategy:
1111
matrix:
12-
php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
12+
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
1313
name: PHP ${{ matrix.php }}
1414
steps:
1515
- uses: actions/checkout@v6
@@ -21,6 +21,7 @@ jobs:
2121
tools: composer:2
2222
coverage: none
2323
- run: composer install --no-progress
24+
- run: composer php-cs-fixer-dry-run
2425
- run: composer phpstan
2526
- run: composer phpunit
2627

@@ -32,9 +33,10 @@ jobs:
3233
fetch-depth: 5
3334
- uses: shivammathur/setup-php@v2
3435
with:
35-
php-version: '7.3'
36+
php-version: '7.4'
3637
tools: composer:2
3738
coverage: none
3839
- run: composer update --no-progress --prefer-lowest
40+
- run: composer php-cs-fixer-dry-run
3941
- run: composer phpstan
4042
- run: composer phpunit

.php-cs-fixer.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,34 @@
22

33
use PhpCsFixer\Config;
44
use PhpCsFixer\Finder;
5+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
56

67
$finder = Finder::create()
78
->exclude('vendor')
89
->in(__DIR__)
910
;
1011

1112
$config = new Config();
12-
return $config->setRules([
13+
return $config
14+
->setParallelConfig(ParallelConfigFactory::detect())
15+
->setRules([
1316
'@PSR12' => true,
1417
'@PSR12:risky' => true,
1518
'@PhpCsFixer' => true,
1619
'@PhpCsFixer:risky' => true,
1720
'@PHP71Migration' => true,
1821
'@PHP71Migration:risky' => true,
1922
'@PHP73Migration' => true,
23+
'@PHP74Migration' => true,
24+
'@PHP74Migration:risky' => true,
2025
'@PHPUnit75Migration:risky' => true,
2126
'@PHPUnit7x5Migration:risky' => true,
2227
'@PHPUnit84Migration:risky' => true,
2328
'@PHPUnit8x4Migration:risky' => true,
2429
'@PHPUnit91Migration:risky' => true,
2530
'@PHPUnit9x1Migration:risky' => true,
31+
'@PHPUnit100Migration:risky' => true,
32+
'@PHPUnit10x0Migration:risky' => true,
2633
'array_syntax' => ['syntax' => 'short'],
2734
'php_unit_test_class_requires_covers' => false,
2835
'backtick_to_shell_exec' => true,

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^7.3 || ^8.0",
25+
"php": "^7.4 || ^8.0",
2626
"ext-json": "*",
2727
"ext-pdo": "*"
2828
},
2929
"require-dev": {
30-
"friendsofphp/php-cs-fixer": "^3.0",
30+
"friendsofphp/php-cs-fixer": "^3.92",
3131
"phpstan/phpstan": "^1.12",
3232
"phpstan/phpstan-phpunit": "^1.0",
3333
"phpstan/phpstan-strict-rules": "^1.0",
34-
"phpunit/phpunit": "^9.1 || ^10.0"
34+
"phpunit/phpunit": "^9.0 || ^10.0"
3535
},
3636
"config": {
3737
"sort-packages": true

lib/MC/Google/Visualization.php

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,40 +55,34 @@ class Visualization
5555
/**
5656
* The default entity that will be used if the "from" part of a query is left out. Setting this to null
5757
* will make a "from" clause required.
58-
*
59-
* @var null|string
6058
*/
61-
protected $defaultEntity;
59+
protected ?string $defaultEntity = null;
6260

6361
/**
6462
* The entity schema that defines which tables are exposed to visualization clients, along with their fields, joins, and callbacks.
6563
*
6664
* @var array<string, Entity>
6765
*/
68-
protected $entities = [];
66+
protected array $entities = [];
6967

7068
/**
7169
* If pivots are being used or MC_Google_Visualization is handling the whole request, this must be a PDO
7270
* connection to your database.
73-
*
74-
* @var null|PDO
7571
*/
76-
protected $db;
72+
protected ?PDO $db;
7773

7874
/**
7975
* The SQL dialect to use when auto-generating SQL statements from the parsed query tokens
8076
* defaults to "mysql". Allowed values are "mysql", "postgres", or "sqlite". Patches are welcome for the rest.
81-
*
82-
* @var string
8377
*/
84-
protected $sqlDialect = 'mysql';
78+
protected string $sqlDialect = 'mysql';
8579

8680
/**
8781
* If a format string is not provided by the query, these will be used to format values by default.
8882
*
8983
* @var array<string, string>
9084
*/
91-
protected $defaultFormat = [
85+
protected array $defaultFormat = [
9286
'date' => 'm/d/Y',
9387
'datetime' => 'm/d/Y h:ia',
9488
'time' => 'h:ia',
@@ -98,10 +92,8 @@ class Visualization
9892

9993
/**
10094
* The current supported version of the Data Source protocol.
101-
*
102-
* @var float
10395
*/
104-
protected $version = 0.5;
96+
protected float $version = 0.5;
10597

10698
/**
10799
* Create a new instance. This must be done before the library can be used. Pass in a PDO connection and
@@ -543,11 +535,7 @@ public function getRowValues(array $row, array $meta): string
543535
if (1 === preg_match('#^num:(\d+)(.*)$#i', $format, $matches)) {
544536
$digits = (int) $matches[1];
545537
$extras = str_split($matches[2]);
546-
if (2 === count($extras)) {
547-
$formatted = number_format($val, $digits, $extras[0], $extras[1]);
548-
} else {
549-
$formatted = number_format($val, $digits);
550-
}
538+
$formatted = 2 === count($extras) ? number_format($val, $digits, $extras[0], $extras[1]) : number_format($val, $digits);
551539
} elseif ('dollars' === $format) {
552540
$formatted = '$'.number_format($val, 2);
553541
} elseif ('percent' === $format) {
@@ -769,7 +757,7 @@ public function parseQuery(string $str): array
769757
$groupby = $token->getValues();
770758
array_shift($groupby);
771759
array_shift($groupby);
772-
$query['groupby'] = array_filter($groupby);
760+
$query['groupby'] = array_filter($groupby, static fn (?string $s): bool => null !== $s && '' !== $s);
773761

774762
break;
775763

@@ -779,7 +767,7 @@ public function parseQuery(string $str): array
779767
}
780768
$pivot = $token->getValues();
781769
array_shift($pivot);
782-
$query['pivot'] = array_filter($pivot);
770+
$query['pivot'] = array_filter($pivot, static fn (?string $s): bool => null !== $s && '' !== $s);
783771

784772
break;
785773

@@ -987,7 +975,7 @@ protected function generateSQL(array &$meta): string
987975
}
988976

989977
$pivotSql = 'SELECT '.implode(', ', $pivotFields).' FROM '.$meta['table'];
990-
if (count($pivotJoins) > 0) {
978+
if ([] !== $pivotJoins) {
991979
$pivotSql .= ' '.implode(' ', $pivotJoins);
992980
}
993981
$pivotSql .= ' GROUP BY '.implode(', ', $pivotGroup);
@@ -1083,7 +1071,7 @@ protected function generateSQL(array &$meta): string
10831071
$wheres[] = $meta['global_where'];
10841072
}
10851073

1086-
if (count($wheres) > 0) {
1074+
if ([] !== $wheres) {
10871075
$sql .= ' WHERE '.implode(' AND ', $wheres);
10881076
}
10891077

@@ -1353,6 +1341,8 @@ protected function addDependantCallbackFields(array $fieldSpec, array $entity, a
13531341
*
13541342
* @param Token $token the token or token group to recursively parse
13551343
* @param null|array $fields the collector array reference to receive the flattened select field values
1344+
*
1345+
* @param-out array $fields
13561346
*/
13571347
protected function parseFieldTokens(Token $token, ?array &$fields = null): void
13581348
{
@@ -1385,6 +1375,8 @@ protected function parseFieldTokens(Token $token, ?array &$fields = null): void
13851375
*
13861376
* @param Token $token the token or token group to parse
13871377
* @param null|array<array{type: string, value: string}> $where the collector array of tokens that make up the where clause
1378+
*
1379+
* @param-out array $where
13881380
*/
13891381
protected function parseWhereTokens(Token $token, ?array &$where = null): void
13901382
{

lib/MC/Google/Visualization_Error.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
class Visualization_Error extends Exception
1010
{
11-
/** @var string */
12-
public $type = 'server_error';
11+
public string $type = 'server_error';
1312

14-
/** @var string */
15-
public $summary = 'Server Error';
13+
public string $summary = 'Server Error';
1614
}

lib/MC/Google/Visualization_QueryError.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
class Visualization_QueryError extends Visualization_Error
88
{
9-
/** @var string */
10-
public $type = 'invalid_query';
9+
public string $type = 'invalid_query';
1110

12-
/** @var string */
13-
public $summary = 'Invalid Query';
11+
public string $summary = 'Invalid Query';
1412
}

lib/MC/Parser.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ class Parser
2525
{
2626
/**
2727
* By default, the parser ignores these characters when they occur between tokens.
28-
*
29-
* @var string
3028
*/
31-
public static $whitespace = " \t\n\r";
29+
public static string $whitespace = " \t\n\r";
3230

3331
/**
3432
* Return a Set with the function arguments as the subexpressions.

lib/MC/Parser/Def.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
*/
1313
abstract class Def
1414
{
15-
/** @var null|string */
16-
public $name;
15+
public ?string $name = null;
1716

18-
/** @var bool */
19-
public $suppress = false;
17+
public bool $suppress = false;
2018

2119
/**
2220
* Parse a string, and return the result or throw a parser exception.

lib/MC/Parser/Def/IsEmpty.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
*/
1212
class IsEmpty extends Def
1313
{
14-
/** @var bool */
15-
public $suppress = true;
14+
public bool $suppress = true;
1615

1716
public function _parse(string $str, int $loc): array
1817
{

lib/MC/Parser/Def/Literal.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,22 @@
1010

1111
class Literal extends Def
1212
{
13-
/** @var string */
14-
public $search;
13+
public string $search;
1514

16-
/** @var bool */
17-
public $caseless = false;
15+
public bool $caseless = false;
1816

19-
/** @var bool */
20-
public $fullword = true;
17+
public bool $fullword = true;
2118

2219
/**
2320
* Match against an exact set of characters in the string.
2421
*
25-
* @param string $str the search string
22+
* @param string $search the search string
2623
* @param bool $caseless set to true to ignore case
2724
* @param bool $fullword set to false to allow a literal followed by a non-whitespace character
2825
*/
29-
public function __construct(string $str, bool $caseless = false, bool $fullword = true)
26+
public function __construct(string $search, bool $caseless = false, bool $fullword = true)
3027
{
31-
$this->search = $str;
28+
$this->search = $search;
3229
$this->caseless = $caseless;
3330
$this->fullword = $fullword;
3431
}
@@ -38,7 +35,7 @@ public function __construct(string $str, bool $caseless = false, bool $fullword
3835
*/
3936
public function _parse(string $str, int $loc): array
4037
{
41-
$match = !$this->caseless ? strpos($str, $this->search, $loc) : stripos($str, $this->search, $loc);
38+
$match = $this->caseless ? stripos($str, $this->search, $loc) : strpos($str, $this->search, $loc);
4239

4340
if ($match !== $loc) {
4441
throw new ParseError('Expected: '.$this->search, $str, $loc);

0 commit comments

Comments
 (0)