@@ -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
@@ -769,7 +761,7 @@ public function parseQuery(string $str): array
769761 $ groupby = $ token ->getValues ();
770762 array_shift ($ groupby );
771763 array_shift ($ groupby );
772- $ query ['groupby ' ] = array_filter ($ groupby );
764+ $ query ['groupby ' ] = array_filter ($ groupby, static fn (? string $ s ): bool => null !== $ s && '' !== $ s );
773765
774766 break ;
775767
@@ -779,7 +771,7 @@ public function parseQuery(string $str): array
779771 }
780772 $ pivot = $ token ->getValues ();
781773 array_shift ($ pivot );
782- $ query ['pivot ' ] = array_filter ($ pivot );
774+ $ query ['pivot ' ] = array_filter ($ pivot, static fn (? string $ s ): bool => null !== $ s && '' !== $ s );
783775
784776 break ;
785777
@@ -1007,7 +999,6 @@ protected function generateSQL(array &$meta): string
1007999 $ stmt = $ this ->db ->query ($ pivotSql );
10081000 assert (false !== $ stmt );
10091001 $ rows = $ stmt ->fetchAll (PDO ::FETCH_ASSOC );
1010- assert (false !== $ rows );
10111002 foreach ($ rows as $ row ) {
10121003 // Create a version of all function-ed fields for each unique combination of pivot values
10131004 foreach ($ funcFields as $ field ) {
@@ -1353,6 +1344,8 @@ protected function addDependantCallbackFields(array $fieldSpec, array $entity, a
13531344 *
13541345 * @param Token $token the token or token group to recursively parse
13551346 * @param null|array $fields the collector array reference to receive the flattened select field values
1347+ *
1348+ * @param-out array $fields
13561349 */
13571350 protected function parseFieldTokens (Token $ token , ?array &$ fields = null ): void
13581351 {
@@ -1385,6 +1378,8 @@ protected function parseFieldTokens(Token $token, ?array &$fields = null): void
13851378 *
13861379 * @param Token $token the token or token group to parse
13871380 * @param null|array<array{type: string, value: string}> $where the collector array of tokens that make up the where clause
1381+ *
1382+ * @param-out array $where
13881383 */
13891384 protected function parseWhereTokens (Token $ token , ?array &$ where = null ): void
13901385 {
0 commit comments