1414 */
1515use Cake \Database \Query ;
1616use Cake \Datasource \ConnectionManager ;
17+ use Cake \Error \Debugger ;
1718use Cake \Log \Log ;
1819use DebugKit \DebugSql ;
20+ use DebugKit \DebugStatements ;
1921
2022$ hasDebugKitConfig = ConnectionManager::getConfig ('debug_kit ' );
2123if (!$ hasDebugKitConfig && !in_array ('sqlite ' , PDO ::getAvailableDrivers ())) {
3739 ]);
3840}
3941
42+ if (!function_exists ('debugKitDump ' )) {
43+ function debugKitDump (mixed $ var , ?bool $ showHtml = null , bool $ showFrom = true ): mixed
44+ {
45+ $ location = [];
46+ if ($ showFrom ) {
47+ $ trace = Debugger::trace (['start ' => 0 , 'depth ' => 1 , 'format ' => 'array ' ]);
48+ if (isset ($ trace [0 ]['line ' ]) && isset ($ trace [0 ]['file ' ])) {
49+ $ location = [
50+ 'line ' => $ trace [0 ]['line ' ],
51+ 'file ' => $ trace [0 ]['file ' ],
52+ ];
53+ }
54+ }
55+
56+ return DebugStatements::add ($ var , $ showHtml , $ location );
57+ }
58+ }
59+
4060if (!function_exists ('sql ' )) {
4161 /**
4262 * Prints out the SQL statements generated by a Query object.
5070 * data in a browser-friendly way.
5171 * @return \Cake\Database\Query
5272 */
53- function sql (Query $ query , $ showValues = true , $ showHtml = null )
73+ function sql (Query $ query , bool $ showValues = true , ? bool $ showHtml = null ): Query
5474 {
5575 return DebugSql::sql ($ query , $ showValues , $ showHtml , 1 );
5676 }
@@ -69,7 +89,7 @@ function sql(Query $query, $showValues = true, $showHtml = null)
6989 * data in a browser-friendly way.
7090 * @return void
7191 */
72- function sqld (Query $ query , $ showValues = true , $ showHtml = null )
92+ function sqld (Query $ query , bool $ showValues = true , ? bool $ showHtml = null ): void
7393 {
7494 DebugSql::sqld ($ query , $ showValues , $ showHtml , 2 );
7595 }
0 commit comments