1 | <?php |
||
17 | class PhpQuickProfiler |
||
18 | { |
||
19 | |||
20 | /** @var integer */ |
||
21 | protected $startTime; |
||
22 | |||
23 | /** @var Console */ |
||
24 | protected $console; |
||
25 | |||
26 | /** @var Display */ |
||
27 | protected $display; |
||
28 | |||
29 | /** @var array */ |
||
30 | protected $profiledQueries = array(); |
||
31 | |||
32 | /** |
||
33 | * @param double $startTime |
||
34 | */ |
||
35 | public function __construct($startTime = null) |
||
42 | |||
43 | /** |
||
44 | * @param Console $console |
||
45 | */ |
||
46 | public function setConsole(Console $console) |
||
50 | |||
51 | /** |
||
52 | * @param Display $display |
||
53 | */ |
||
54 | public function setDisplay(Display $display) |
||
58 | |||
59 | /** |
||
60 | * Get data about files loaded for the application to current point |
||
61 | * |
||
62 | * @returns array |
||
63 | */ |
||
64 | public function gatherFileData() |
||
76 | |||
77 | /** |
||
78 | * Get data about memory usage of the application |
||
79 | * |
||
80 | * @returns array |
||
81 | */ |
||
82 | public function gatherMemoryData() |
||
91 | |||
92 | /** |
||
93 | * @param array $profiled_queries |
||
94 | */ |
||
95 | public function setProfiledQueries(array $profiledQueries) |
||
99 | |||
100 | /** |
||
101 | * Get data about sql usage of the application |
||
102 | * |
||
103 | * @param object $dbConnection |
||
104 | * @returns array |
||
105 | */ |
||
106 | public function gatherQueryData($dbConnection) |
||
122 | |||
123 | /** |
||
124 | * Attempts to explain a query |
||
125 | * |
||
126 | * @param object $dbConnection |
||
127 | * @param string $query |
||
128 | * @param array $parameters |
||
129 | * @throws Exception |
||
130 | * @return array |
||
131 | */ |
||
132 | protected function explainQuery($dbConnection, $query, $parameters = array()) |
||
147 | |||
148 | /** |
||
149 | * Attempts to figure out what kind of explain query format the db wants |
||
150 | * |
||
151 | * @param string $query |
||
152 | * @param string $driver |
||
153 | * @throws Exception |
||
154 | * @return string |
||
155 | */ |
||
156 | protected function getExplainQuery($query, $driver) |
||
165 | |||
166 | /** |
||
167 | * Get data about speed of the application |
||
168 | * |
||
169 | * @returns array |
||
170 | */ |
||
171 | public function gatherSpeedData() |
||
181 | |||
182 | /** |
||
183 | * Triggers end display of the profiling data |
||
184 | * |
||
185 | * @param object $dbConnection |
||
186 | * @throws Exception |
||
187 | */ |
||
188 | public function display($dbConnection = null) |
||
202 | } |
||
203 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.