Passed
Push — master ( e26094...28949d )
by Paul
02:50
created
plugin/Modules/Globals.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,51 +15,51 @@  discard block
 block discarded – undo
15 15
      */
16 16
     protected $entries;
17 17
 
18
-    public function __construct(Application $app)
18
+    public function __construct( Application $app )
19 19
     {
20 20
         $this->app = $app;
21
-        $this->entries = [];
21
+        $this->entries = [ ];
22 22
     }
23 23
 
24 24
     public function entries(): array
25 25
     {
26
-        if (!empty($this->entries)) {
26
+        if( !empty( $this->entries ) ) {
27 27
             return $this->entries;
28 28
         }
29
-        if (is_admin() && $screen = get_current_screen()) {
30
-            $reflection = new \ReflectionClass($screen);
31
-            $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
32
-            $values = [];
33
-            foreach ($properties as $property) {
34
-                $values[$property->getName()] = $property->getValue($screen);
29
+        if( is_admin() && $screen = get_current_screen() ) {
30
+            $reflection = new \ReflectionClass( $screen );
31
+            $properties = $reflection->getProperties( \ReflectionProperty::IS_PUBLIC );
32
+            $values = [ ];
33
+            foreach( $properties as $property ) {
34
+                $values[ $property->getName() ] = $property->getValue( $screen );
35 35
             }
36
-            $this->entries[] = [
36
+            $this->entries[ ] = [
37 37
                 'name' => 'WP_Screen',
38
-                'value' => var_export($values, true),
38
+                'value' => var_export( $values, true ),
39 39
             ];
40 40
         }
41
-        $this->entries[] = [
41
+        $this->entries[ ] = [
42 42
             'name' => '$_GET',
43
-            'value' => var_export($_GET, true),
43
+            'value' => var_export( $_GET, true ),
44 44
         ];
45
-        $this->entries[] = [
45
+        $this->entries[ ] = [
46 46
             'name' => '$_SERVER',
47
-            'value' => var_export($_SERVER, true),
47
+            'value' => var_export( $_SERVER, true ),
48 48
         ];
49
-        $this->entries[] = [
49
+        $this->entries[ ] = [
50 50
             'name' => '$_COOKIE',
51
-            'value' => var_export($_COOKIE, true),
51
+            'value' => var_export( $_COOKIE, true ),
52 52
         ];
53
-        $this->entries[] = [
53
+        $this->entries[ ] = [
54 54
             'name' => '$_SESSION',
55
-            'value' => var_export(isset($_SESSION) ? $_SESSION : [], true),
55
+            'value' => var_export( isset( $_SESSION ) ? $_SESSION : [ ], true ),
56 56
         ];
57 57
         return $this->entries;
58 58
     }
59 59
 
60 60
     public function hasEntries(): bool
61 61
     {
62
-        return !empty($this->entries());
62
+        return !empty( $this->entries() );
63 63
     }
64 64
 
65 65
     public function id(): string
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 
75 75
     public function label(): string
76 76
     {
77
-        return __('Globals', 'blackbar');
77
+        return __( 'Globals', 'blackbar' );
78 78
     }
79 79
 
80 80
     public function render(): void
81 81
     {
82
-        $this->app->render('panels/globals', ['globals' => $this]);
82
+        $this->app->render( 'panels/globals', [ 'globals' => $this ] );
83 83
     }
84 84
 }
Please login to merge, or discard this patch.
plugin/Modules/Templates.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@  discard block
 block discarded – undo
15 15
      */
16 16
     protected $entries;
17 17
 
18
-    public function __construct(Application $app)
18
+    public function __construct( Application $app )
19 19
     {
20 20
         $this->app = $app;
21
-        $this->entries = [];
21
+        $this->entries = [ ];
22 22
     }
23 23
 
24 24
     public function entries(): array
25 25
     {
26
-        if (!empty($this->entries)) {
26
+        if( !empty( $this->entries ) ) {
27 27
             return $this->entries;
28 28
         }
29
-        if (class_exists('\GeminiLabs\Castor\Facades\Development')
30
-            && class_exists('\GeminiLabs\Castor\Helpers\Development')
31
-            && method_exists('\GeminiLabs\Castor\Helpers\Development', 'templatePaths')) { // @phpstan-ignore-line
29
+        if( class_exists( '\GeminiLabs\Castor\Facades\Development' )
30
+            && class_exists( '\GeminiLabs\Castor\Helpers\Development' )
31
+            && method_exists( '\GeminiLabs\Castor\Helpers\Development', 'templatePaths' ) ) { // @phpstan-ignore-line
32 32
             $this->entries = \GeminiLabs\Castor\Facades\Development::templatePaths();
33 33
         } else {
34
-            $files = array_values(array_filter(get_included_files(), function ($file) {
35
-                $bool = false !== strpos($file, '/themes/') && false === strpos($file, '/functions.php');
36
-                return (bool) apply_filters('blackbar/templates/file', $bool, $file);
37
-            }));
38
-            $this->entries = array_map(function ($file) {
39
-                return str_replace(trailingslashit(WP_CONTENT_DIR), '', $file);
40
-            }, $files);
34
+            $files = array_values( array_filter( get_included_files(), function( $file ) {
35
+                $bool = false !== strpos( $file, '/themes/' ) && false === strpos( $file, '/functions.php' );
36
+                return (bool) apply_filters( 'blackbar/templates/file', $bool, $file );
37
+            }) );
38
+            $this->entries = array_map( function( $file ) {
39
+                return str_replace( trailingslashit( WP_CONTENT_DIR ), '', $file );
40
+            }, $files );
41 41
         }
42 42
         return $this->entries;
43 43
     }
44 44
 
45 45
     public function hasEntries(): bool
46 46
     {
47
-        return !empty($this->entries());
47
+        return !empty( $this->entries() );
48 48
     }
49 49
 
50 50
     public function id(): string
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 
60 60
     public function label(): string
61 61
     {
62
-        return __('Templates', 'blackbar');
62
+        return __( 'Templates', 'blackbar' );
63 63
     }
64 64
 
65 65
     public function render(): void
66 66
     {
67
-        $this->app->render('panels/templates', ['templates' => $this]);
67
+        $this->app->render( 'panels/templates', [ 'templates' => $this ] );
68 68
     }
69 69
 }
Please login to merge, or discard this patch.
plugin/Modules/Profiler.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
      */
28 28
     protected $timers;
29 29
 
30
-    public function __construct(Application $app)
30
+    public function __construct( Application $app )
31 31
     {
32 32
         $this->app = $app;
33 33
         $this->noise = (float) 0; // This is the time that WordPress takes to execute the all hook.
34 34
         $this->start = (float) 0;
35 35
         $this->stop = (float) 0;
36
-        $this->timers = [];
36
+        $this->timers = [ ];
37 37
     }
38 38
 
39 39
     public function entries(): array
40 40
     {
41
-        $entries = [];
42
-        foreach ($this->timers as $timer) {
43
-            $entries[] = [
44
-                'memory' => $this->getMemoryString($timer),
45
-                'name' => $this->getNameString($timer),
46
-                'time' => $this->getTimeString($timer),
41
+        $entries = [ ];
42
+        foreach( $this->timers as $timer ) {
43
+            $entries[ ] = [
44
+                'memory' => $this->getMemoryString( $timer ),
45
+                'name' => $this->getNameString( $timer ),
46
+                'time' => $this->getTimeString( $timer ),
47 47
             ];
48 48
         }
49 49
         return $entries;
@@ -54,33 +54,33 @@  discard block
 block discarded – undo
54 54
         return $this->timers;
55 55
     }
56 56
 
57
-    public function getMemoryString(array $timer): string
57
+    public function getMemoryString( array $timer ): string
58 58
     {
59
-        return (string) round($this->normalize($timer)['memory'] / 1000);
59
+        return (string) round( $this->normalize( $timer )[ 'memory' ] / 1000 );
60 60
     }
61 61
 
62
-    public function getNameString(array $timer): string
62
+    public function getNameString( array $timer ): string
63 63
     {
64
-        return $this->normalize($timer)['name'];
64
+        return $this->normalize( $timer )[ 'name' ];
65 65
     }
66 66
 
67
-    public function getTimeString(array $timer): string
67
+    public function getTimeString( array $timer ): string
68 68
     {
69
-        $timer = $this->normalize($timer);
70
-        $index = array_search($timer['name'], array_column($this->timers, 'name'));
71
-        $start = $this->start + ($index * $this->noise);
72
-        return number_format(round(($timer['time'] - $start) * 1000, 4), 4);
69
+        $timer = $this->normalize( $timer );
70
+        $index = array_search( $timer[ 'name' ], array_column( $this->timers, 'name' ) );
71
+        $start = $this->start + ( $index * $this->noise );
72
+        return number_format( round( ( $timer[ 'time' ] - $start ) * 1000, 4 ), 4 );
73 73
     }
74 74
 
75 75
     public function getTotalTime(): float
76 76
     {
77
-        $totalNoise = (count($this->timers) - 1) * $this->noise;
77
+        $totalNoise = ( count( $this->timers ) - 1 ) * $this->noise;
78 78
         return $this->stop - $this->start - $totalNoise;
79 79
     }
80 80
 
81 81
     public function hasEntries(): bool
82 82
     {
83
-        return !empty($this->timers);
83
+        return !empty( $this->timers );
84 84
     }
85 85
 
86 86
     public function id(): string
@@ -95,30 +95,30 @@  discard block
 block discarded – undo
95 95
 
96 96
     public function label(): string
97 97
     {
98
-        $label = __('Profiler', 'blackbar');
99
-        $time = number_format($this->getTotalTime() * 1000, 0);
100
-        if ($time > 0) {
101
-            $label .= sprintf(' (%s %s)', $time, __('ms', 'blackbar'));
98
+        $label = __( 'Profiler', 'blackbar' );
99
+        $time = number_format( $this->getTotalTime() * 1000, 0 );
100
+        if( $time > 0 ) {
101
+            $label .= sprintf( ' (%s %s)', $time, __( 'ms', 'blackbar' ) );
102 102
         }
103 103
         return $label;
104 104
     }
105 105
 
106 106
     public function render(): void
107 107
     {
108
-        $this->app->render('panels/profiler', ['profiler' => $this]);
108
+        $this->app->render( 'panels/profiler', [ 'profiler' => $this ] );
109 109
     }
110 110
 
111
-    public function trace(string $name): void
111
+    public function trace( string $name ): void
112 112
     {
113
-        $microtime = microtime(true); // float
114
-        if (!$this->start) {
113
+        $microtime = microtime( true ); // float
114
+        if( !$this->start ) {
115 115
             $this->start = $microtime;
116 116
         }
117
-        if ('blackbar/profiler/noise' === $name) {
117
+        if( 'blackbar/profiler/noise' === $name ) {
118 118
             $this->noise = $microtime - $this->start;
119 119
             return;
120 120
         }
121
-        $this->timers[] = [
121
+        $this->timers[ ] = [
122 122
             'memory' => memory_get_peak_usage(),
123 123
             'name' => $name,
124 124
             'time' => $microtime,
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
         $this->stop = $microtime;
127 127
     }
128 128
 
129
-    protected function normalize(array $timer): array
129
+    protected function normalize( array $timer ): array
130 130
     {
131
-        return wp_parse_args($timer, [
131
+        return wp_parse_args( $timer, [
132 132
             'memory' => 0,
133 133
             'name' => '',
134 134
             'time' => (float) 0,
135
-        ]);
135
+        ] );
136 136
     }
137 137
 }
Please login to merge, or discard this patch.
plugin/Modules/Console.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -36,28 +36,28 @@  discard block
 block discarded – undo
36 36
      */
37 37
     protected $entries;
38 38
 
39
-    public function __construct(Application $app)
39
+    public function __construct( Application $app )
40 40
     {
41 41
         $this->app = $app;
42
-        $this->entries = [];
42
+        $this->entries = [ ];
43 43
     }
44 44
 
45 45
     public function entries(): array
46 46
     {
47
-        $entries = [];
48
-        foreach ($this->entries as $entry) {
49
-            $entry['name'] = ucfirst($entry['errname']);
50
-            if ($entry['count'] > 1) {
51
-                $entry['message'] = sprintf('(%s) %s', $entry['count'], $entry['message']);
47
+        $entries = [ ];
48
+        foreach( $this->entries as $entry ) {
49
+            $entry[ 'name' ] = ucfirst( $entry[ 'errname' ] );
50
+            if( $entry[ 'count' ] > 1 ) {
51
+                $entry[ 'message' ] = sprintf( '(%s) %s', $entry[ 'count' ], $entry[ 'message' ] );
52 52
             }
53
-            $entries[] = $entry;
53
+            $entries[ ] = $entry;
54 54
         }
55 55
         return $entries;
56 56
     }
57 57
 
58 58
     public function hasEntries(): bool
59 59
     {
60
-        return !empty($this->entries);
60
+        return !empty( $this->entries );
61 61
     }
62 62
 
63 63
     public function id(): string
@@ -73,75 +73,75 @@  discard block
 block discarded – undo
73 73
     public function label(): string
74 74
     {
75 75
         $class = '';
76
-        $entryCount = count($this->entries);
76
+        $entryCount = count( $this->entries );
77 77
         $errorCount = 0;
78
-        $label = __('Console', 'blackbar');
79
-        foreach ($this->entries as $entry) {
80
-            if (in_array($entry['errno'], [E_WARNING])) {
78
+        $label = __( 'Console', 'blackbar' );
79
+        foreach( $this->entries as $entry ) {
80
+            if( in_array( $entry[ 'errno' ], [ E_WARNING ] ) ) {
81 81
                 $class = 'glbb-warning';
82 82
             }
83
-            if (in_array($entry['errno'], [E_ERROR])) {
83
+            if( in_array( $entry[ 'errno' ], [ E_ERROR ] ) ) {
84 84
                 ++$errorCount;
85 85
             }
86 86
         }
87
-        if ($errorCount > 0) {
87
+        if( $errorCount > 0 ) {
88 88
             $class = 'glbb-error';
89
-            $label = sprintf('%s (%d, %d!)', $label, $entryCount, $errorCount);
90
-        } elseif ($entryCount > 0) {
91
-            $label = sprintf('%s (%d)', $label, $entryCount);
89
+            $label = sprintf( '%s (%d, %d!)', $label, $entryCount, $errorCount );
90
+        } elseif( $entryCount > 0 ) {
91
+            $label = sprintf( '%s (%d)', $label, $entryCount );
92 92
         }
93
-        return sprintf('<span class="%s">%s</span>', $class, $label);
93
+        return sprintf( '<span class="%s">%s</span>', $class, $label );
94 94
     }
95 95
 
96 96
     public function render(): void
97 97
     {
98
-        $this->app->render('panels/console', ['console' => $this]);
98
+        $this->app->render( 'panels/console', [ 'console' => $this ] );
99 99
     }
100 100
 
101
-    public function store(string $message, string $errno = '', string $location = ''): void
101
+    public function store( string $message, string $errno = '', string $location = '' ): void
102 102
     {
103
-        if (is_numeric($errno)) {
103
+        if( is_numeric( $errno ) ) {
104 104
             // entry likely stored by set_error_handler()
105 105
             $errname = 'Unknown';
106
-            if (array_key_exists((int) $errno, static::ERROR_CODES)) {
107
-                $errname = static::ERROR_CODES[$errno];
106
+            if( array_key_exists( (int) $errno, static::ERROR_CODES ) ) {
107
+                $errname = static::ERROR_CODES[ $errno ];
108 108
             }
109 109
         } else {
110 110
             // entry likely stored by filter hook
111 111
             $errname = 'Debug';
112
-            if (array_key_exists($errno, static::MAPPED_ERROR_CODES)) {
112
+            if( array_key_exists( $errno, static::MAPPED_ERROR_CODES ) ) {
113 113
                 $errname = $errno;
114
-                $errno = static::MAPPED_ERROR_CODES[$errno];
114
+                $errno = static::MAPPED_ERROR_CODES[ $errno ];
115 115
             }
116 116
         }
117
-        $errname = strtolower($errname);
118
-        $hash = md5($errno.$errname.$message.$location);
119
-        if (array_key_exists($hash, $this->entries)) {
120
-            ++$this->entries[$hash]['count'];
117
+        $errname = strtolower( $errname );
118
+        $hash = md5( $errno . $errname . $message . $location );
119
+        if( array_key_exists( $hash, $this->entries ) ) {
120
+            ++$this->entries[ $hash ][ 'count' ];
121 121
         } else {
122
-            $this->entries[$hash] = [
122
+            $this->entries[ $hash ] = [
123 123
                 'count' => 0,
124 124
                 'errname' => $errname,
125 125
                 'errno' => (int) $errno,
126
-                'message' => $this->normalizeMessage($message, $location),
126
+                'message' => $this->normalizeMessage( $message, $location ),
127 127
             ];
128 128
         };
129 129
     }
130 130
 
131
-    protected function normalizeMessage($message, string $location): string
131
+    protected function normalizeMessage( $message, string $location ): string
132 132
     {
133
-        if ($message instanceof \DateTime) {
134
-            $message = $message->format('Y-m-d H:i:s');
135
-        } elseif (is_object($message) || is_array($message)) {
136
-            $message = print_r(json_decode(json_encode($message)), true);
133
+        if( $message instanceof \DateTime ) {
134
+            $message = $message->format( 'Y-m-d H:i:s' );
135
+        } elseif( is_object( $message ) || is_array( $message ) ) {
136
+            $message = print_r( json_decode( json_encode( $message ) ), true );
137 137
         } else {
138
-            $message = esc_html(trim((string) $message));
138
+            $message = esc_html( trim( (string) $message ) );
139 139
         }
140
-        $location = trim($location);
141
-        if (!empty($location)) {
142
-            $location = str_replace([WP_CONTENT_DIR, ABSPATH], '', $location);
143
-            $location = sprintf('[%s] ', $location);
140
+        $location = trim( $location );
141
+        if( !empty( $location ) ) {
142
+            $location = str_replace( [ WP_CONTENT_DIR, ABSPATH ], '', $location );
143
+            $location = sprintf( '[%s] ', $location );
144 144
         }
145
-        return $location.$message;
145
+        return $location . $message;
146 146
     }
147 147
 }
Please login to merge, or discard this patch.
plugin/Modules/Actions.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -27,70 +27,70 @@  discard block
 block discarded – undo
27 27
      */
28 28
     protected $totalTime;
29 29
 
30
-    public function __construct(Application $app)
30
+    public function __construct( Application $app )
31 31
     {
32 32
         $this->app = $app;
33
-        $this->entries = [];
34
-        $this->hooks = [];
33
+        $this->entries = [ ];
34
+        $this->hooks = [ ];
35 35
         $this->totalActions = 0;
36 36
         $this->totalTime = (float) 0;
37 37
     }
38 38
 
39
-    public function callbacksForHook(string $action, array $data): void
39
+    public function callbacksForHook( string $action, array $data ): void
40 40
     {
41 41
         global $wp_filter;
42
-        if (!array_key_exists($action, $this->hooks)) {
42
+        if( !array_key_exists( $action, $this->hooks ) ) {
43 43
             return;
44 44
         }
45
-        $this->hooks[$action]['callbacks_count'] = 0;
46
-        foreach ($wp_filter[$action] as $priority => $callbacks) {
47
-            if (!array_key_exists($priority, $this->hooks[$action]['callbacks'])) {
48
-                $this->hooks[$action]['callbacks'][$priority] = [];
45
+        $this->hooks[ $action ][ 'callbacks_count' ] = 0;
46
+        foreach( $wp_filter[ $action ] as $priority => $callbacks ) {
47
+            if( !array_key_exists( $priority, $this->hooks[ $action ][ 'callbacks' ] ) ) {
48
+                $this->hooks[ $action ][ 'callbacks' ][ $priority ] = [ ];
49 49
             }
50
-            foreach ($callbacks as $callback) {
51
-                if (is_array($callback['function']) && 2 === count($callback['function'])) {
52
-                    list($object, $method) = $callback['function'];
53
-                    if (is_object($object)) {
54
-                        $object = get_class($object);
50
+            foreach( $callbacks as $callback ) {
51
+                if( is_array( $callback[ 'function' ] ) && 2 === count( $callback[ 'function' ] ) ) {
52
+                    list( $object, $method ) = $callback[ 'function' ];
53
+                    if( is_object( $object ) ) {
54
+                        $object = get_class( $object );
55 55
                         // $reflection = new \ReflectionClass($object);
56 56
                         // if (str_starts_with($reflection->getNamespaceName(), 'GeminiLabs\BlackBar')) {
57 57
                         //     continue; // skip blackbar callbacks
58 58
                         // }
59 59
                     }
60
-                    $this->hooks[$action]['callbacks'][$priority][] = sprintf('%s::%s', $object, $method);
61
-                } elseif (is_object($callback['function'])) {
62
-                    $this->hooks[$action]['callbacks'][$priority][] = get_class($callback['function']);
60
+                    $this->hooks[ $action ][ 'callbacks' ][ $priority ][ ] = sprintf( '%s::%s', $object, $method );
61
+                } elseif( is_object( $callback[ 'function' ] ) ) {
62
+                    $this->hooks[ $action ][ 'callbacks' ][ $priority ][ ] = get_class( $callback[ 'function' ] );
63 63
                 } else {
64
-                    $this->hooks[$action]['callbacks'][$priority][] = $callback['function'];
64
+                    $this->hooks[ $action ][ 'callbacks' ][ $priority ][ ] = $callback[ 'function' ];
65 65
                 }
66
-                ++$this->hooks[$action]['callbacks_count'];
66
+                ++$this->hooks[ $action ][ 'callbacks_count' ];
67 67
             }
68 68
         }
69 69
     }
70 70
 
71 71
     public function entries(): array
72 72
     {
73
-        if (class_exists('Debug_Bar_Slow_Actions')) {
74
-            return [];
73
+        if( class_exists( 'Debug_Bar_Slow_Actions' ) ) {
74
+            return [ ];
75 75
         }
76
-        if (!empty($this->entries) || empty($this->hooks)) {
76
+        if( !empty( $this->entries ) || empty( $this->hooks ) ) {
77 77
             return $this->entries;
78 78
         }
79
-        foreach ($this->hooks as $action => $data) {
80
-            $total = $this->totalTimeForHook($data);
81
-            $this->hooks[$action]['total'] = $total;
79
+        foreach( $this->hooks as $action => $data ) {
80
+            $total = $this->totalTimeForHook( $data );
81
+            $this->hooks[ $action ][ 'total' ] = $total;
82 82
             $this->totalTime += $total;
83
-            $this->totalActions += $data['count'];
84
-            $this->callbacksForHook($action, $data);
83
+            $this->totalActions += $data[ 'count' ];
84
+            $this->callbacksForHook( $action, $data );
85 85
         }
86
-        uasort($this->hooks, [$this, 'sortByTime']);
87
-        $this->entries = array_slice($this->hooks, 0, 50); // return the 50 slowest actions
86
+        uasort( $this->hooks, [ $this, 'sortByTime' ] );
87
+        $this->entries = array_slice( $this->hooks, 0, 50 ); // return the 50 slowest actions
88 88
         return $this->entries;
89 89
     }
90 90
 
91 91
     public function hasEntries(): bool
92 92
     {
93
-        return !empty($this->entries());
93
+        return !empty( $this->entries() );
94 94
     }
95 95
 
96 96
     public function id(): string
@@ -105,62 +105,62 @@  discard block
 block discarded – undo
105 105
 
106 106
     public function label(): string
107 107
     {
108
-        $label = __('Hooks', 'blackbar');
109
-        if (class_exists('Debug_Bar_Slow_Actions')) {
108
+        $label = __( 'Hooks', 'blackbar' );
109
+        if( class_exists( 'Debug_Bar_Slow_Actions' ) ) {
110 110
             return $label;
111 111
         }
112 112
         $this->entries(); // calculates the totalTime
113
-        if ($this->totalTime > 0) {
114
-            $label = sprintf('%s (%.2f %s)', $label, $this->totalTime, __('ms', 'blackbar'));
113
+        if( $this->totalTime > 0 ) {
114
+            $label = sprintf( '%s (%.2f %s)', $label, $this->totalTime, __( 'ms', 'blackbar' ) );
115 115
         }
116 116
         return $label;
117 117
     }
118 118
 
119 119
     public function render(): void
120 120
     {
121
-        $this->app->render('panels/actions', ['actions' => $this]);
121
+        $this->app->render( 'panels/actions', [ 'actions' => $this ] );
122 122
     }
123 123
 
124 124
     public function startTimer(): void
125 125
     {
126
-        if (!isset($this->hooks[current_filter()])) {
127
-            $this->hooks[current_filter()] = [
128
-                'callbacks' => [],
126
+        if( !isset( $this->hooks[ current_filter() ] ) ) {
127
+            $this->hooks[ current_filter() ] = [
128
+                'callbacks' => [ ],
129 129
                 'count' => 0,
130
-                'stack' => [],
131
-                'time' => [],
130
+                'stack' => [ ],
131
+                'time' => [ ],
132 132
             ];
133
-            add_action(current_filter(), [$this, 'stopTimer'], 9999); // @phpstan-ignore-line
133
+            add_action( current_filter(), [ $this, 'stopTimer' ], 9999 ); // @phpstan-ignore-line
134 134
         }
135
-        ++$this->hooks[current_filter()]['count'];
136
-        array_push($this->hooks[current_filter()]['stack'], ['start' => microtime(true)]);
135
+        ++$this->hooks[ current_filter() ][ 'count' ];
136
+        array_push( $this->hooks[ current_filter() ][ 'stack' ], [ 'start' => microtime( true ) ] );
137 137
     }
138 138
 
139 139
     /**
140 140
      * @param mixed $filteredValue
141 141
      * @return mixed
142 142
      */
143
-    public function stopTimer($filteredValue = null)
143
+    public function stopTimer( $filteredValue = null )
144 144
     {
145
-        $time = array_pop($this->hooks[current_filter()]['stack']);
146
-        $time['stop'] = microtime(true);
147
-        array_push($this->hooks[current_filter()]['time'], $time);
145
+        $time = array_pop( $this->hooks[ current_filter() ][ 'stack' ] );
146
+        $time[ 'stop' ] = microtime( true );
147
+        array_push( $this->hooks[ current_filter() ][ 'time' ], $time );
148 148
         return $filteredValue; // In case this was a filter.
149 149
     }
150 150
 
151
-    public function totalTimeForHook(array $data): float
151
+    public function totalTimeForHook( array $data ): float
152 152
     {
153 153
         $total = 0;
154
-        foreach ($data['time'] as $time) {
155
-            $total += ($time['stop'] - $time['start']) * 1000;
154
+        foreach( $data[ 'time' ] as $time ) {
155
+            $total += ( $time[ 'stop' ] - $time[ 'start' ] ) * 1000;
156 156
         }
157 157
         return (float) $total;
158 158
     }
159 159
 
160
-    protected function sortByTime(array $a, array $b): int
160
+    protected function sortByTime( array $a, array $b ): int
161 161
     {
162
-        if ($a['total'] !== $b['total']) {
163
-            return ($a['total'] > $b['total']) ? -1 : 1;
162
+        if( $a[ 'total' ] !== $b[ 'total' ] ) {
163
+            return ( $a[ 'total' ] > $b[ 'total' ] ) ? -1 : 1;
164 164
         }
165 165
         return 0;
166 166
     }
Please login to merge, or discard this patch.
plugin/Controller.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
      */
10 10
     protected $app;
11 11
 
12
-    public function __construct(Application $app)
12
+    public function __construct( Application $app )
13 13
     {
14 14
         $this->app = $app;
15 15
     }
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function enqueueAssets(): void
22 22
     {
23
-        wp_enqueue_script(Application::ID, $this->app->url('assets/main.js'));
24
-        wp_enqueue_style(Application::ID, $this->app->url('assets/main.css'), ['dashicons']);
25
-        wp_enqueue_style(Application::ID.'-syntax', $this->app->url('assets/syntax.css'));
23
+        wp_enqueue_script( Application::ID, $this->app->url( 'assets/main.js' ) );
24
+        wp_enqueue_style( Application::ID, $this->app->url( 'assets/main.css' ), [ 'dashicons' ] );
25
+        wp_enqueue_style( Application::ID . '-syntax', $this->app->url( 'assets/syntax.css' ) );
26 26
     }
27 27
 
28 28
     /**
29 29
      * @param string $classes
30 30
      * @action admin_body_class
31 31
      */
32
-    public function filterBodyClasses($classes): string
32
+    public function filterBodyClasses( $classes ): string
33 33
     {
34
-        return trim((string) $classes.' '.Application::ID);
34
+        return trim( (string) $classes . ' ' . Application::ID );
35 35
     }
36 36
 
37 37
     /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function initActions(): void
41 41
     {
42
-        if (!class_exists('Debug_Bar_Slow_Actions')) {
42
+        if( !class_exists( 'Debug_Bar_Slow_Actions' ) ) {
43 43
             $this->app->actions->startTimer();
44 44
         }
45 45
     }
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function initConsole(): void
51 51
     {
52
-        if (Application::CONSOLE_HOOK !== func_get_arg(0)) {
52
+        if( Application::CONSOLE_HOOK !== func_get_arg( 0 ) ) {
53 53
             return;
54 54
         }
55
-        $args = array_pad(func_get_args(), 4, '');
56
-        $args = array_combine(['hook', 'message', 'errno', 'location'], $args);
57
-        $args = array_map('sanitize_text_field', $args);
58
-        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);
59
-        $entry = array_pop($backtrace); // get the fourth backtrace entry
60
-        if (empty(trim($args['location'])) && array_key_exists('file', $entry)) {
61
-            $path = explode(ABSPATH, $entry['file']);
62
-            $args['location'] = sprintf('%s:%s', array_pop($path), $entry['line']);
55
+        $args = array_pad( func_get_args(), 4, '' );
56
+        $args = array_combine( [ 'hook', 'message', 'errno', 'location' ], $args );
57
+        $args = array_map( 'sanitize_text_field', $args );
58
+        $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 );
59
+        $entry = array_pop( $backtrace ); // get the fourth backtrace entry
60
+        if( empty( trim( $args[ 'location' ] ) ) && array_key_exists( 'file', $entry ) ) {
61
+            $path = explode( ABSPATH, $entry[ 'file' ] );
62
+            $args[ 'location' ] = sprintf( '%s:%s', array_pop( $path ), $entry[ 'line' ] );
63 63
         }
64
-        $this->app->console->store($args['message'], $args['errno'], $args['location']);
64
+        $this->app->console->store( $args[ 'message' ], $args[ 'errno' ], $args[ 'location' ] );
65 65
     }
66 66
 
67 67
     /**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function initProfiler(): void
71 71
     {
72
-        if (Application::PROFILER_HOOK === func_get_arg(0)) {
73
-            $this->app->profiler->trace(func_get_arg(1));
72
+        if( Application::PROFILER_HOOK === func_get_arg( 0 ) ) {
73
+            $this->app->profiler->trace( func_get_arg( 1 ) );
74 74
         }
75 75
     }
76 76
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public function registerLanguages(): void
81 81
     {
82
-        load_plugin_textdomain(Application::ID, false,
83
-            plugin_basename($this->app->path()).'/languages/'
82
+        load_plugin_textdomain( Application::ID, false,
83
+            plugin_basename( $this->app->path() ) . '/languages/'
84 84
         );
85 85
     }
86 86
 
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function renderBar(): void
92 92
     {
93
-        apply_filters('debug', 'Profiler Stopped');
94
-        $this->app->render('debug-bar', [
93
+        apply_filters( 'debug', 'Profiler Stopped' );
94
+        $this->app->render( 'debug-bar', [
95 95
             'modules' => [ // order is intentional
96 96
                 $this->app->console,
97 97
                 $this->app->profiler,
@@ -100,6 +100,6 @@  discard block
 block discarded – undo
100 100
                 $this->app->templates,
101 101
                 $this->app->globals,
102 102
             ],
103
-        ]);
103
+        ] );
104 104
     }
105 105
 }
Please login to merge, or discard this patch.
views/panels/queries.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3
-<?php if (!defined('SAVEQUERIES') || !SAVEQUERIES) : ?>
3
+<?php if( !defined( 'SAVEQUERIES' ) || !SAVEQUERIES ) : ?>
4 4
     <table>
5 5
         <tbody>
6 6
             <tr>
7
-                <td><a href="https://wordpress.org/documentation/article/debugging-in-wordpress/#savequeries">SAVEQUERIES</a> <?= _x('must be enabled to view SQL queries', 'SAVEQUERIES', 'blackbar'); ?>.</td>
7
+                <td><a href="https://wordpress.org/documentation/article/debugging-in-wordpress/#savequeries">SAVEQUERIES</a> <?= _x( 'must be enabled to view SQL queries', 'SAVEQUERIES', 'blackbar' ); ?>.</td>
8 8
             </tr>
9 9
         </tbody>
10 10
     </table>
11 11
 <?php else : ?>
12 12
     <form method="get" class="glbb-queries-filter">
13
-        <input class="glbb-input" type="text" name="glbb_query_filter" id="glbb_query_filter" placeholder="<?= __('Find Queries Containing', 'blackbar'); ?>">
14
-        <input class="glbb-input glbb-input-small" type="text" name="glbb_query_min_time" id="glbb_query_min_time" placeholder="<?= __('Minimum Execution Time', 'blackbar'); ?>">
13
+        <input class="glbb-input" type="text" name="glbb_query_filter" id="glbb_query_filter" placeholder="<?= __( 'Find Queries Containing', 'blackbar' ); ?>">
14
+        <input class="glbb-input glbb-input-small" type="text" name="glbb_query_min_time" id="glbb_query_min_time" placeholder="<?= __( 'Minimum Execution Time', 'blackbar' ); ?>">
15 15
     </form>
16 16
     <table class="glbb-queries-table">
17 17
         <tbody>
18
-            <?php foreach ($queries->entries() as $entry) : ?>
18
+            <?php foreach( $queries->entries() as $entry ) : ?>
19 19
                 <tr>
20
-                    <td class="glbb-small"><?= esc_html($entry['time']); ?></td>
21
-                    <td><pre><code class="language-sql"><?= esc_html($entry['sql']); ?></code></pre></td>
20
+                    <td class="glbb-small"><?= esc_html( $entry[ 'time' ] ); ?></td>
21
+                    <td><pre><code class="language-sql"><?= esc_html( $entry[ 'sql' ] ); ?></code></pre></td>
22 22
                 </tr>
23 23
             <?php endforeach; ?>
24 24
         </tbody>
Please login to merge, or discard this patch.
views/panels/profiler.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <table>
4
-    <?php if (!$profiler->hasEntries()) : ?>
4
+    <?php if( !$profiler->hasEntries() ) : ?>
5 5
         <tbody>
6 6
             <tr>
7
-                <td><?= __('No entries found.', 'blackbar'); ?></td>
7
+                <td><?= __( 'No entries found.', 'blackbar' ); ?></td>
8 8
             </tr>
9 9
         </tbody>
10 10
     <?php else : ?>
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
             </tr>
17 17
         </thead>
18 18
         <tbody>
19
-            <?php foreach ($profiler->entries() as $entry) : ?>
19
+            <?php foreach( $profiler->entries() as $entry ) : ?>
20 20
                 <tr>
21
-                    <td><?= esc_html($entry['name']); ?></td>
22
-                    <td style="text-align: right;"><?= esc_html(sprintf('%.2f', $entry['time'])); ?> ms</td>
23
-                    <td style="text-align: right;"><?= esc_html($entry['memory']); ?> KB</td>
21
+                    <td><?= esc_html( $entry[ 'name' ] ); ?></td>
22
+                    <td style="text-align: right;"><?= esc_html( sprintf( '%.2f', $entry[ 'time' ] ) ); ?> ms</td>
23
+                    <td style="text-align: right;"><?= esc_html( $entry[ 'memory' ] ); ?> KB</td>
24 24
                 </tr>
25 25
             <?php endforeach; ?>
26 26
         </tbody>
Please login to merge, or discard this patch.
views/panels/actions.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3
-<?php if (!$actions->hasEntries()) : ?>
3
+<?php if( !$actions->hasEntries() ) : ?>
4 4
     <table>
5 5
         <tbody>
6 6
             <tr>
7
-                <td><?= __('Please deactivate the Debug Bar Slow Actions plugin.', 'blackbar'); ?></td>
7
+                <td><?= __( 'Please deactivate the Debug Bar Slow Actions plugin.', 'blackbar' ); ?></td>
8 8
             </tr>
9 9
         </tbody>
10 10
     </table>
11 11
 <?php else : ?>
12 12
     <form method="get" class="glbb-actions-filter">
13
-        <input class="glbb-input" type="text" name="glbb_actions_callback" id="glbb_actions_callback" placeholder="<?= __('Find Callbacks Containing', 'blackbar'); ?>">
14
-        <input class="glbb-input glbb-input-small" type="text" name="glbb_actions_min_time" id="glbb_actions_min_time" placeholder="<?= __('Minimum Total Time', 'blackbar'); ?>">
13
+        <input class="glbb-input" type="text" name="glbb_actions_callback" id="glbb_actions_callback" placeholder="<?= __( 'Find Callbacks Containing', 'blackbar' ); ?>">
14
+        <input class="glbb-input glbb-input-small" type="text" name="glbb_actions_min_time" id="glbb_actions_min_time" placeholder="<?= __( 'Minimum Total Time', 'blackbar' ); ?>">
15 15
     </form>
16 16
     <table style="top:-10px;">
17 17
         <thead>
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
             </tr>
25 25
         </thead>
26 26
         <tbody>
27
-            <?php foreach ($actions->entries() as $action => $data) : ?>
27
+            <?php foreach( $actions->entries() as $action => $data ) : ?>
28 28
                 <tr class="glbb-row-collapsed">
29
-                    <th><div class="glbb-row-toggle dashicons-before dashicons-arrow-right"><?= esc_html($action); ?></div></th>
30
-                    <th><div data-callbacks="<?= esc_attr($data['callbacks_count']); ?>"><?= esc_html($data['callbacks_count']); ?></div></th>
31
-                    <th><div data-calls="<?= esc_attr($data['count']); ?>"><?= esc_html($data['count']); ?></div></th>
32
-                    <th><div data-percall="<?= esc_attr(sprintf('%.2f', $data['total'] / $data['count'])); ?>"><?= esc_html(sprintf('%.2f ms', $data['total'] / $data['count'])); ?></div></th>
33
-                    <th><div data-total="<?= esc_attr($data['total']); ?>"><?= esc_html(sprintf('%.2f ms', $data['total'])); ?></div></th>
29
+                    <th><div class="glbb-row-toggle dashicons-before dashicons-arrow-right"><?= esc_html( $action ); ?></div></th>
30
+                    <th><div data-callbacks="<?= esc_attr( $data[ 'callbacks_count' ] ); ?>"><?= esc_html( $data[ 'callbacks_count' ] ); ?></div></th>
31
+                    <th><div data-calls="<?= esc_attr( $data[ 'count' ] ); ?>"><?= esc_html( $data[ 'count' ] ); ?></div></th>
32
+                    <th><div data-percall="<?= esc_attr( sprintf( '%.2f', $data[ 'total' ] / $data[ 'count' ] ) ); ?>"><?= esc_html( sprintf( '%.2f ms', $data[ 'total' ] / $data[ 'count' ] ) ); ?></div></th>
33
+                    <th><div data-total="<?= esc_attr( $data[ 'total' ] ); ?>"><?= esc_html( sprintf( '%.2f ms', $data[ 'total' ] ) ); ?></div></th>
34 34
                 </tr>
35 35
                 <tr class="glbb-row">
36 36
                     <td colspan="5">
37 37
                         <ol>
38
-                            <?php foreach ($data['callbacks'] as $priority => $callbacks) : ?>
39
-                                <?php foreach ($callbacks as $callback) : ?>
40
-                                    <li value="<?= esc_attr($priority); ?>"><?= esc_html($callback); ?></li>
38
+                            <?php foreach( $data[ 'callbacks' ] as $priority => $callbacks ) : ?>
39
+                                <?php foreach( $callbacks as $callback ) : ?>
40
+                                    <li value="<?= esc_attr( $priority ); ?>"><?= esc_html( $callback ); ?></li>
41 41
                                 <?php endforeach; ?>
42 42
                             <?php endforeach; ?>
43 43
                         </ol>
Please login to merge, or discard this patch.