@@ -8,16 +8,20 @@ class Parser
88
99private const TIME = '# Time: ' ;
1010
11+ /** @var array<int, \PHPFUI\MySQLSlowQuery\Entry> */
1112private array $ entries = [];
1213
14+ /** @var array<int, string> */
1315private array $ extraLines = [];
1416
1517private string $ fileName = '' ;
1618
19+ // @phpstan-ignore-next-line
1720private $ handle ;
1821
1922private bool $ inSession = true ;
2023
24+ /** @var array<int, \PHPFUI\MySQLSlowQuery\Session> */
2125private array $ sessions = [];
2226
2327private string $ sortColumn = 'Query_time ' ;
@@ -39,6 +43,8 @@ public function __construct(string $fileName)
3943 *
4044 * @throws Exception\EmptyLog
4145 * @throws Exception\LogLine
46+ * @return array<int, \PHPFUI\MySQLSlowQuery\Entry>
47+ *
4248 */
4349public function getEntries (int $ session = -1 ) : array
4450{
@@ -53,6 +59,7 @@ public function getEntries(int $session = -1) : array
5359
5460foreach ($ this ->entries as $ entry )
5561{
62+ // @phpstan-ignore-next-line
5663if ($ entry ->Session == $ session )
5764{
5865$ entries [] = $ entry ;
@@ -66,10 +73,10 @@ public function getEntries(int $session = -1) : array
6673}
6774
6875/**
69- * Return \PHPFUI\MySQLSlowQuery\Session sessions from file
70- *
7176 * @throws Exception\EmptyLog
7277 * @throws Exception\LogLine
78+ * @return array<int, \PHPFUI\MySQLSlowQuery\Session> sessions from file
79+ *
7380 */
7481public function getSessions () : array
7582{
@@ -114,7 +121,7 @@ protected function entrySort(\PHPFUI\MySQLSlowQuery\Entry $lhs, \PHPFUI\MySQLSlo
114121return $ lhs ->{$ column } <=> $ rhs ->{$ column };
115122}
116123
117- private function getNextLine ()
124+ private function getNextLine () : string
118125{
119126if ($ this ->extraLines )
120127{
@@ -163,6 +170,7 @@ private function parse() : void
163170
164171$ query = [];
165172
173+ // @phpstan-ignore-next-line
166174while (\strlen ($ line = $ this ->getNextLine ()) > 0 && '# ' !== $ line [0 ])
167175{
168176if (0 === \stripos ($ line , self ::PORT ))// found a session
@@ -186,7 +194,9 @@ private function parse() : void
186194{
187195$ this ->pushLine ($ line );
188196}
197+ // @phpstan-ignore-next-line
189198$ entry ->Query = $ query ;
199+ // @phpstan-ignore-next-line
190200$ entry ->Session = \count ($ this ->sessions ) - 1 ;
191201$ this ->entries [] = $ entry ;
192202}
0 commit comments