Passed
Push — master ( 28ff52...4eff68 )
by Paul
02:06
created
src/Application.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public function __construct()
19 19
 	{
20
-		$this->file = realpath( dirname( __DIR__ ).'/'.static::ID.'.php' );
20
+		$this->file = realpath( dirname( __DIR__ ) . '/' . static::ID . '.php' );
21 21
 		$this->profiler = new Profiler;
22 22
 	}
23 23
 
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 			8192 => 'Deprecated',
38 38
 		);
39 39
 		$errname = array_key_exists( $errno, $errorCodes )
40
-			? $errorCodes[$errno]
40
+			? $errorCodes[ $errno ]
41 41
 			: 'Unknown';
42
-		$hash = md5( $errno.$errstr.$errfile.$errline );
43
-		if( array_key_exists( $hash, $this->errors )) {
44
-			$this->errors[$hash]['count']++;
42
+		$hash = md5( $errno . $errstr . $errfile . $errline );
43
+		if( array_key_exists( $hash, $this->errors ) ) {
44
+			$this->errors[ $hash ][ 'count' ]++;
45 45
 		}
46 46
 		else {
47
-			$this->errors[$hash] = array(
47
+			$this->errors[ $hash ] = array(
48 48
 				"errno" => $errno,
49 49
 				"message" => $errstr,
50 50
 				"file" => $errfile,
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
 	public function init()
62 62
 	{
63 63
 		$controller = new Controller( $this );
64
-		add_action( 'admin_enqueue_scripts',    array( $controller, 'enqueueAssets' ));
65
-		add_action( 'wp_enqueue_scripts',       array( $controller, 'enqueueAssets' ));
66
-		add_action( 'plugins_loaded',           array( $controller, 'registerLanguages' ));
67
-		add_action( 'admin_footer',             array( $controller, 'renderBar' ));
68
-		add_action( 'wp_footer',                array( $controller, 'renderBar' ));
69
-		add_filter( 'admin_body_class',         array( $controller, 'filterBodyClasses' ));
70
-		add_filter( 'gform_noconflict_scripts', array( $controller, 'filterNoconflictScripts' ));
71
-		add_filter( 'gform_noconflict_styles',  array( $controller, 'filterNoconflictStyles' ));
72
-		add_filter( 'all',                      array( $controller, 'initProfiler' ));
64
+		add_action( 'admin_enqueue_scripts', array( $controller, 'enqueueAssets' ) );
65
+		add_action( 'wp_enqueue_scripts', array( $controller, 'enqueueAssets' ) );
66
+		add_action( 'plugins_loaded', array( $controller, 'registerLanguages' ) );
67
+		add_action( 'admin_footer', array( $controller, 'renderBar' ) );
68
+		add_action( 'wp_footer', array( $controller, 'renderBar' ) );
69
+		add_filter( 'admin_body_class', array( $controller, 'filterBodyClasses' ) );
70
+		add_filter( 'gform_noconflict_scripts', array( $controller, 'filterNoconflictScripts' ) );
71
+		add_filter( 'gform_noconflict_styles', array( $controller, 'filterNoconflictStyles' ) );
72
+		add_filter( 'all', array( $controller, 'initProfiler' ) );
73 73
 		apply_filters( 'debug', 'Profiler Started' );
74 74
 		apply_filters( 'debug', 'blackbar/profiler/noise' );
75
-		set_error_handler( array( $this, 'errorHandler' ), E_ALL|E_STRICT );
75
+		set_error_handler( array( $this, 'errorHandler' ), E_ALL | E_STRICT );
76 76
 	}
77 77
 
78 78
 	/**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function path( $file = '' )
83 83
 	{
84
-		return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' );
84
+		return plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' );
85 85
 	}
86 86
 
87 87
 	/**
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function render( $view, array $data = array() )
92 92
 	{
93
-		$file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view )));
94
-		if( !file_exists( $file ))return;
93
+		$file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view ) ) );
94
+		if( !file_exists( $file ) )return;
95 95
 		extract( $data );
96 96
 		include $file;
97 97
 	}
@@ -102,6 +102,6 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function url( $path = '' )
104 104
 	{
105
-		return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ));
105
+		return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) );
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,9 @@
 block discarded – undo
91 91
 	public function render( $view, array $data = array() )
92 92
 	{
93 93
 		$file = $this->path( sprintf( 'views/%s.php', str_replace( '.php', '', $view )));
94
-		if( !file_exists( $file ))return;
94
+		if( !file_exists( $file )) {
95
+			return;
96
+		}
95 97
 		extract( $data );
96 98
 		include $file;
97 99
 	}
Please login to merge, or discard this patch.
src/Controller.php 2 patches
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,9 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function initProfiler()
67 67
 	{
68
-		if( func_get_arg(0) != Application::DEBUG )return;
68
+		if( func_get_arg(0) != Application::DEBUG ) {
69
+			return;
70
+		}
69 71
 		$this->app->profiler->trace( func_get_arg(1) );
70 72
 	}
71 73
 
@@ -154,12 +156,14 @@  discard block
 block discarded – undo
154 156
 	 */
155 157
 	protected function getIncludedFiles()
156 158
 	{
157
-		$files = array_values( array_filter( get_included_files(), function( $file ) {
159
+		$files = array_values( array_filter( get_included_files(), function( $file )
160
+		{
158 161
 			$bool = strpos( $file, '/themes/' ) !== false
159 162
 				&& strpos( $file, '/functions.php' ) === false;
160 163
 			return (bool)apply_filters( 'blackbar/templates/file', $bool, $file );
161 164
 		}));
162
-		return array_map( function( $key, $value ) {
165
+		return array_map( function( $key, $value )
166
+		{
163 167
 			$value = str_replace( trailingslashit( WP_CONTENT_DIR ), '', $value );
164 168
 			return sprintf( '[%s] => %s', $key, $value );
165 169
 		}, array_keys( $files ), $files );
@@ -185,7 +189,8 @@  discard block
 block discarded – undo
185 189
 			'AND', 'FROM', 'GROUP BY', 'INNER JOIN', 'LIMIT', 'ON DUPLICATE KEY UPDATE',
186 190
 			'ORDER BY', 'SET', 'WHERE',
187 191
 		);
188
-		$replace = array_map( function( $value ) {
192
+		$replace = array_map( function( $value )
193
+		{
189 194
 			return PHP_EOL.$value;
190 195
 		}, $search );
191 196
 		foreach( $wpdb->queries as $query ) {
@@ -224,7 +229,9 @@  discard block
 block discarded – undo
224 229
 	 */
225 230
 	protected function getTemplates()
226 231
 	{
227
-		if( is_admin() )return;
232
+		if( is_admin() ) {
233
+			return;
234
+		}
228 235
 		if( class_exists( '\GeminiLabs\Castor\Facades\Development' )) {
229 236
 			ob_start();
230 237
 			\GeminiLabs\Castor\Facades\Development::printTemplatePaths();
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function enqueueAssets()
25 25
 	{
26
-		wp_enqueue_script( Application::ID, $this->app->url( 'assets/main.js' ));
27
-		wp_enqueue_style( Application::ID, $this->app->url( 'assets/main.css' ), array( 'dashicons' ));
28
-		wp_enqueue_style( Application::ID.'-syntax', $this->app->url( 'assets/syntax.css' ));
26
+		wp_enqueue_script( Application::ID, $this->app->url( 'assets/main.js' ) );
27
+		wp_enqueue_style( Application::ID, $this->app->url( 'assets/main.css' ), array( 'dashicons' ) );
28
+		wp_enqueue_style( Application::ID . '-syntax', $this->app->url( 'assets/syntax.css' ) );
29 29
 	}
30 30
 
31 31
 	/**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function filterBodyClasses( $classes )
37 37
 	{
38
-		return trim( $classes.' '.Application::ID );
38
+		return trim( $classes . ' ' . Application::ID );
39 39
 	}
40 40
 
41 41
 	/**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public function filterNoconflictScripts( $scripts )
46 46
 	{
47
-		$scripts[] = Application::ID;
47
+		$scripts[ ] = Application::ID;
48 48
 		return $scripts;
49 49
 	}
50 50
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function filterNoconflictStyles( $styles )
56 56
 	{
57
-		$styles[] = Application::ID;
58
-		$styles[] = Application::ID.'-syntax';
57
+		$styles[ ] = Application::ID;
58
+		$styles[ ] = Application::ID . '-syntax';
59 59
 		return $styles;
60 60
 	}
61 61
 
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function initProfiler()
67 67
 	{
68
-		if( func_get_arg(0) != Application::DEBUG )return;
69
-		$this->app->profiler->trace( func_get_arg(1) );
68
+		if( func_get_arg( 0 ) != Application::DEBUG )return;
69
+		$this->app->profiler->trace( func_get_arg( 1 ) );
70 70
 	}
71 71
 
72 72
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	public function registerLanguages()
77 77
 	{
78 78
 		load_plugin_textdomain( Application::ID, false,
79
-			plugin_basename( $this->app->path() ).Application::LANG
79
+			plugin_basename( $this->app->path() ) . Application::LANG
80 80
 		);
81 81
 	}
82 82
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			'queries' => $this->getQueries(),
98 98
 			'queriesLabel' => $this->getQueriesLabel(),
99 99
 			'templates' => $this->getTemplates(),
100
-		));
100
+		) );
101 101
 	}
102 102
 
103 103
 	/**
@@ -115,18 +115,18 @@  discard block
 block discarded – undo
115 115
 	{
116 116
 		$errors = array();
117 117
 		foreach( $this->app->errors as $error ) {
118
-			if( $error['errno'] == E_WARNING ) {
119
-				$error['name'] = '<span class="glbb-error">'.$error['name'].'</span>';
118
+			if( $error[ 'errno' ] == E_WARNING ) {
119
+				$error[ 'name' ] = '<span class="glbb-error">' . $error[ 'name' ] . '</span>';
120 120
 			}
121
-			if( $error['count'] > 1 ) {
122
-				$error['name'] .= ' ('.$error['count'].')';
121
+			if( $error[ 'count' ] > 1 ) {
122
+				$error[ 'name' ] .= ' (' . $error[ 'count' ] . ')';
123 123
 			}
124
-			$errors[] = array(
125
-				'name' => $error['name'],
124
+			$errors[ ] = array(
125
+				'name' => $error[ 'name' ],
126 126
 				'message' => sprintf( __( '%s on line %s in file %s', 'blackbar' ),
127
-					$error['message'],
128
-					$error['line'],
129
-					$error['file']
127
+					$error[ 'message' ],
128
+					$error[ 'line' ],
129
+					$error[ 'file' ]
130 130
 				),
131 131
 			);
132 132
 		}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	{
141 141
 		$warningCount = 0;
142 142
 		foreach( $this->app->errors as $error ) {
143
-			if( $error['errno'] == E_WARNING ) {
143
+			if( $error[ 'errno' ] == E_WARNING ) {
144 144
 				$warningCount++;
145 145
 			}
146 146
 		}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		$warnings = $warningCount > 0
149 149
 			? sprintf( ', %d!', $warningCount )
150 150
 			: '';
151
-		return sprintf( __( 'Errors (%s)', 'blackbar' ), $errorCount.$warnings );
151
+		return sprintf( __( 'Errors (%s)', 'blackbar' ), $errorCount . $warnings );
152 152
 	}
153 153
 
154 154
 	/**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 		$files = array_values( array_filter( get_included_files(), function( $file ) {
160 160
 			$bool = strpos( $file, '/themes/' ) !== false
161 161
 				&& strpos( $file, '/functions.php' ) === false;
162
-			return (bool)apply_filters( 'blackbar/templates/file', $bool, $file );
163
-		}));
162
+			return (bool) apply_filters( 'blackbar/templates/file', $bool, $file );
163
+		}) );
164 164
 		return array_map( function( $key, $value ) {
165 165
 			$value = str_replace( trailingslashit( WP_CONTENT_DIR ), '', $value );
166 166
 			return sprintf( '[%s] => %s', $key, $value );
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 			'ORDER BY', 'SET', 'WHERE',
189 189
 		);
190 190
 		$replace = array_map( function( $value ) {
191
-			return PHP_EOL.$value;
191
+			return PHP_EOL . $value;
192 192
 		}, $search );
193 193
 		foreach( $wpdb->queries as $query ) {
194
-			$miliseconds = number_format( round( $query[1] * 1000, 4 ), 4 );
195
-			$sql = preg_replace( '/\s\s+/', ' ', trim( $query[0] ));
194
+			$miliseconds = number_format( round( $query[ 1 ] * 1000, 4 ), 4 );
195
+			$sql = preg_replace( '/\s\s+/', ' ', trim( $query[ 0 ] ) );
196 196
 			$sql = str_replace( PHP_EOL, ' ', $sql );
197 197
 			$sql = str_replace( $search, $replace, $sql );
198
-			$queries[] = array(
198
+			$queries[ ] = array(
199 199
 				'ms' => $miliseconds,
200 200
 				'sql' => $sql,
201 201
 			);
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
 		global $wpdb;
215 215
 		$queryTime = 0;
216 216
 		foreach( $wpdb->queries as $query ) {
217
-			$queryTime += $query[1];
217
+			$queryTime += $query[ 1 ];
218 218
 		}
219
-		$queriesCount = '<span class="glbb-queries-count">'.count( $wpdb->queries ).'</span>';
220
-		$queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds( $queryTime ).'</span>';
219
+		$queriesCount = '<span class="glbb-queries-count">' . count( $wpdb->queries ) . '</span>';
220
+		$queriesTime = '<span class="glbb-queries-time">' . $this->convertToMiliseconds( $queryTime ) . '</span>';
221 221
 		return sprintf( __( 'SQL (%s queries in %s ms)', 'blackbar' ), $queriesCount, $queriesTime );
222 222
 	}
223 223
 
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 	protected function getTemplates()
228 228
 	{
229 229
 		if( is_admin() )return;
230
-		if( class_exists( '\GeminiLabs\Castor\Facades\Development' )) {
230
+		if( class_exists( '\GeminiLabs\Castor\Facades\Development' ) ) {
231 231
 			ob_start();
232 232
 			\GeminiLabs\Castor\Facades\Development::printTemplatePaths();
233 233
 			return ob_get_clean();
234 234
 		}
235
-		return '<pre>'.implode( PHP_EOL, $this->getIncludedFiles() ).'</pre>';
235
+		return '<pre>' . implode( PHP_EOL, $this->getIncludedFiles() ) . '</pre>';
236 236
 	}
237 237
 }
Please login to merge, or discard this patch.
autoload.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@
 block discarded – undo
8 8
 spl_autoload_register( function( $class )
9 9
 {
10 10
 	$namespaces = [
11
-		'GeminiLabs\\BlackBar\\' => __DIR__.'/src/',
12
-		'GeminiLabs\\BlackBar\\Tests\\' => __DIR__.'/tests/',
11
+		'GeminiLabs\\BlackBar\\' => __DIR__ . '/src/',
12
+		'GeminiLabs\\BlackBar\\Tests\\' => __DIR__ . '/tests/',
13 13
 	];
14 14
 	foreach( $namespaces as $prefix => $base_dir ) {
15 15
 		$len = strlen( $prefix );
16 16
 		if( strncmp( $prefix, $class, $len ) !== 0 )continue;
17
-		$file = $base_dir.str_replace( '\\', '/', substr( $class, $len )).'.php';
18
-		if( !file_exists( $file ))continue;
17
+		$file = $base_dir . str_replace( '\\', '/', substr( $class, $len ) ) . '.php';
18
+		if( !file_exists( $file ) )continue;
19 19
 		require $file;
20 20
 		break;
21 21
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,9 +13,13 @@
 block discarded – undo
13 13
 	];
14 14
 	foreach( $namespaces as $prefix => $base_dir ) {
15 15
 		$len = strlen( $prefix );
16
-		if( strncmp( $prefix, $class, $len ) !== 0 )continue;
16
+		if( strncmp( $prefix, $class, $len ) !== 0 ) {
17
+			continue;
18
+		}
17 19
 		$file = $base_dir.str_replace( '\\', '/', substr( $class, $len )).'.php';
18
-		if( !file_exists( $file ))continue;
20
+		if( !file_exists( $file )) {
21
+			continue;
22
+		}
19 23
 		require $file;
20 24
 		break;
21 25
 	}
Please login to merge, or discard this patch.
src/Profiler.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	public function getMemoryString( $timer )
41 41
 	{
42 42
 		$timer = $this->normalize( $timer );
43
-		return sprintf( '%s kB', round( $timer['memory'] / 1000 ));
43
+		return sprintf( '%s kB', round( $timer[ 'memory' ] / 1000 ) );
44 44
 	}
45 45
 
46 46
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	public function getNameString( $timer )
51 51
 	{
52 52
 		$timer = $this->normalize( $timer );
53
-		return $timer['name'];
53
+		return $timer[ 'name' ];
54 54
 	}
55 55
 
56 56
 	/**
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	public function getTimeString( $timer )
61 61
 	{
62 62
 		$timer = $this->normalize( $timer );
63
-		$index = array_search( $timer['name'], array_column( $this->timers, 'name' ));
63
+		$index = array_search( $timer[ 'name' ], array_column( $this->timers, 'name' ) );
64 64
 		$start = $this->start + ( $index * $this->noise );
65
-		$time = number_format( round(( $timer['time'] - $start ) * 1000, 4 ), 4 );
65
+		$time = number_format( round( ( $timer[ 'time' ] - $start ) * 1000, 4 ), 4 );
66 66
 		return sprintf( '%s ms', $time );
67 67
 	}
68 68
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 			$this->noise = $microtime - $this->start;
90 90
 			return;
91 91
 		}
92
-		$this->timers[] = array(
92
+		$this->timers[ ] = array(
93 93
 			'memory' => memory_get_peak_usage(),
94 94
 			'name' => $name,
95 95
 			'time' => $microtime,
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	protected function normalize( $timer )
105 105
 	{
106
-		return wp_parse_args( (array)$timer, array(
106
+		return wp_parse_args( (array) $timer, array(
107 107
 			'memory' => 0,
108 108
 			'name' => '',
109 109
 			'time' => 0,
110
-		));
110
+		) );
111 111
 	}
112 112
 }
Please login to merge, or discard this patch.