You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewVisualization_Error('You must pass a PDO connection to the MC Google Visualization Server if you want to let the server handle the entire request');
215
240
}
216
241
217
-
$reqId = $params['reqId'];
242
+
$reqId = (int) $params['reqId'];
218
243
$queryParsed = $this->parseQuery($query);
219
244
$meta = $this->generateMetadata($queryParsed);
220
245
$sql = $this->generateSQL($meta);
@@ -236,13 +261,13 @@ public function handleQuery(string $query, array $params): string
@@ -251,9 +276,11 @@ public function handleQuery(string $query, array $params): string
251
276
/**
252
277
* Given the results of parseQuery(), introspect against the entity definitions provided and return the metadata array used to generate the SQL.
253
278
*
254
-
* @param array $query the visualization query broken up into sections
279
+
* @param array<string, mixed> $query the visualization query broken up into sections
255
280
*
256
-
* @return array the metadata array from merging the query with the entity table definitions
281
+
* @phpstan-param QueryParsed $query
282
+
*
283
+
* @return array<string, mixed> the metadata array from merging the query with the entity table definitions
257
284
*
258
285
* @throws Visualization_QueryError
259
286
* @throws Visualization_Error
@@ -704,7 +731,9 @@ public function getGrammar(): Def
704
731
*
705
732
* @param string $str the query string to parse
706
733
*
707
-
* @return array the parsed query as an array, keyed by each part of the query (select, from, where, groupby, pivot, orderby, limit, offset, label, format, options
734
+
* @return array<string, mixed> the parsed query as an array, keyed by each part of the query (select, from, where, groupby, pivot, orderby, limit, offset, label, format, options
735
+
*
736
+
* @phpstan-return QueryParsed
708
737
*
709
738
* @throws ParseError
710
739
* @throws Visualization_QueryError
@@ -727,8 +756,10 @@ public function parseQuery(string $str): array
727
756
break;
728
757
729
758
case'from':
730
-
$vals = $token->getValues();
731
-
$query['from'] = $vals[1];
759
+
$from = $token->getValues();
760
+
$from = $from[1];
761
+
assert(null !== $from);
762
+
$query['from'] = $from;
732
763
733
764
break;
734
765
@@ -744,7 +775,7 @@ public function parseQuery(string $str): array
744
775
$groupby = $token->getValues();
745
776
array_shift($groupby);
746
777
array_shift($groupby);
747
-
$query['groupby'] = $groupby;
778
+
$query['groupby'] = array_filter($groupby);
748
779
749
780
break;
750
781
@@ -754,7 +785,7 @@ public function parseQuery(string $str): array
754
785
}
755
786
$pivot = $token->getValues();
756
787
array_shift($pivot);
757
-
$query['pivot'] = $pivot;
788
+
$query['pivot'] = array_filter($pivot);
758
789
759
790
break;
760
791
@@ -784,13 +815,15 @@ public function parseQuery(string $str): array
784
815
case'limit':
785
816
$limit = $token->getValues();
786
817
$limit = $limit[1];
818
+
assert(null !== $limit);
787
819
$query['limit'] = $limit;
788
820
789
821
break;
790
822
791
823
case'offset':
792
824
$offset = $token->getValues();
793
825
$offset = $offset[1];
826
+
assert(null !== $offset);
794
827
$query['offset'] = $offset;
795
828
796
829
break;
@@ -803,6 +836,7 @@ public function parseQuery(string $str): array
803
836
$count = count($labels);
804
837
for ($i = 0; $i < $count; $i += 2) {
805
838
$field = $labels[$i];
839
+
assert(null !== $labels[$i + 1]);
806
840
$label = trim($labels[$i + 1], '\'"');
807
841
$queryLabels[$field] = $label;
808
842
}
@@ -818,6 +852,7 @@ public function parseQuery(string $str): array
@@ -38,7 +38,7 @@ public function parse(string $str): Token
38
38
/**
39
39
* Parse a string, cleaning up whitespace when we're done.
40
40
*
41
-
* @return arrayA two-item array of the string location where parsing stopped, and the MC_Token instance that matches the grammar conditions
41
+
* @return array{int, null|Token} A two-item array of the string location where parsing stopped and the MC_Token instance that matches the grammar conditions
42
42
*
43
43
* @throws ParseError
44
44
*/
@@ -61,7 +61,7 @@ public function parsePart(string $str, int $loc): array
61
61
* @param string $str the string to parse
62
62
* @param int $loc the index to start parsing
63
63
*
64
-
* @return arrayA two-item array of the string location where parsing stopped, and the MC_Token instance that matches the grammar conditions
64
+
* @return array{int, null|Token} A two-item array of the string location where parsing stopped, and the Token instance that matches the grammar conditions
65
65
*
66
66
* @throws ParseError
67
67
*/
@@ -103,11 +103,9 @@ public function suppress(): self
103
103
/**
104
104
* Return a token instance, copying over this Def's name and flagging suppression.
105
105
*
106
-
* @param mixed $value
107
-
*
108
106
* @return null|Token the new token, or null if the token should be suppressed
0 commit comments