Passed
Push — master ( cf2ee8...35ad91 )
by Jeroen De
02:06
created
src/Definition/V4ModuleDefinition.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -34,61 +34,61 @@  discard block
 block discarded – undo
34 34
 class V4ModuleDefinition implements ModuleDefinition {
35 35
 
36 36
 	static private $moduleDescriptions = [
37
-		'functions'         => [ 'styles' => [ 'functions' => [ 'position' => 'functions' ] ] ],
38
-		'variables'         => [ 'styles' => [ 'variables' => [ 'position' => 'variables' ] ], 'dependencies' => 'functions' ],
39
-		'mixins'            => [ 'styles' => 'mixins' ],
40
-		'root'              => [ 'styles' => 'root' ],
41
-		'reboot'            => [ 'styles' => 'reboot' ],
42
-		'type'              => [ 'styles' => 'type' ],
43
-		'images'            => [ 'styles' => 'images' ],
44
-		'code'              => [ 'styles' => 'code' ],
45
-		'grid'              => [ 'styles' => 'grid' ],
46
-		'tables'            => [ 'styles' => 'tables' ],
47
-		'forms'             => [ 'styles' => 'forms' ],
48
-		'buttons'           => [ 'styles' => 'buttons' ],
49
-		'transitions'       => [ 'styles' => 'transitions' ],
50
-		'dropdown'          => [ 'styles' => 'dropdown', 'scripts' => 'dropdown.js', 'dependencies' => [ 'popper', 'js-util' ] ],
51
-		'button-group'      => [ 'styles' => 'button-group', 'dependencies' => [ 'buttons' ] ],
52
-		'input-group'       => [ 'styles' => 'input-group', 'dependencies' => [ 'forms' ] ],
53
-		'custom-forms'      => [ 'styles' => 'custom-forms' ],
54
-		'nav'               => [ 'styles' => 'nav' ],
55
-		'navbar'            => [ 'styles' => 'navbar' ],
56
-		'card'              => [ 'styles' => 'card' ],
57
-		'breadcrumb'        => [ 'styles' => 'breadcrumb' ],
58
-		'pagination'        => [ 'styles' => 'pagination' ],
59
-		'badge'             => [ 'styles' => 'badge' ],
60
-		'jumbotron'         => [ 'styles' => 'jumbotron' ],
61
-		'alert'             => [ 'styles' => 'alert' ],
62
-		'progress'          => [ 'styles' => 'progress' ],
63
-		'media'             => [ 'styles' => 'media' ],
64
-		'list-group'        => [ 'styles' => 'list-group' ],
65
-		'close'             => [ 'styles' => 'close' ],
66
-		'toasts'            => [ 'styles' => 'toasts', 'scripts' => 'toast.js', 'dependencies' => 'js-util' ],
67
-		'modal'             => [ 'styles' => 'modal', 'scripts' => 'modal.js' ],
68
-		'tooltip'           => [ 'styles' => 'tooltip', 'dependencies' => [ 'popper', 'js-util' ] ],
69
-		'popover'           => [ 'styles' => 'popover', 'dependencies' => [ 'popper', 'tooltip', 'js-util' ] ],
70
-		'carousel'          => [ 'styles' => 'carousel', 'scripts' => 'carousel.js', 'dependencies' => 'js-util' ],
71
-		'spinners'          => [ 'styles' => 'spinners' ],
72
-		'utilities'         => [ 'styles' => 'utilities' ],
73
-		'print'             => [ 'styles' => 'print' ],
74
-		'active-buttons'    => [ 'scripts' => 'button.js', 'dependencies' => [ 'buttons' ] ],
75
-		'dismissable-alert' => [ 'scripts' => 'alert.js', 'dependencies' => [ 'alert', 'js-util' ] ],
76
-		'collapse'          => [ 'scripts' => 'collapse.js' ],
77
-		'scrollspy'         => [ 'scripts' => 'scrollspy.js', 'dependencies' => [ 'popper', 'js-util' ] ],
78
-		'tab'               => [ 'scripts' => 'tab.js', 'dependencies' => [ 'list-group' ] ],
79
-		'js-util'           => [ 'scripts' => 'util.js' ],
80
-		'popper'            => [ 'scripts' => 'popper.js' ],
37
+		'functions'         => ['styles' => ['functions' => ['position' => 'functions']]],
38
+		'variables'         => ['styles' => ['variables' => ['position' => 'variables']], 'dependencies' => 'functions'],
39
+		'mixins'            => ['styles' => 'mixins'],
40
+		'root'              => ['styles' => 'root'],
41
+		'reboot'            => ['styles' => 'reboot'],
42
+		'type'              => ['styles' => 'type'],
43
+		'images'            => ['styles' => 'images'],
44
+		'code'              => ['styles' => 'code'],
45
+		'grid'              => ['styles' => 'grid'],
46
+		'tables'            => ['styles' => 'tables'],
47
+		'forms'             => ['styles' => 'forms'],
48
+		'buttons'           => ['styles' => 'buttons'],
49
+		'transitions'       => ['styles' => 'transitions'],
50
+		'dropdown'          => ['styles' => 'dropdown', 'scripts' => 'dropdown.js', 'dependencies' => ['popper', 'js-util']],
51
+		'button-group'      => ['styles' => 'button-group', 'dependencies' => ['buttons']],
52
+		'input-group'       => ['styles' => 'input-group', 'dependencies' => ['forms']],
53
+		'custom-forms'      => ['styles' => 'custom-forms'],
54
+		'nav'               => ['styles' => 'nav'],
55
+		'navbar'            => ['styles' => 'navbar'],
56
+		'card'              => ['styles' => 'card'],
57
+		'breadcrumb'        => ['styles' => 'breadcrumb'],
58
+		'pagination'        => ['styles' => 'pagination'],
59
+		'badge'             => ['styles' => 'badge'],
60
+		'jumbotron'         => ['styles' => 'jumbotron'],
61
+		'alert'             => ['styles' => 'alert'],
62
+		'progress'          => ['styles' => 'progress'],
63
+		'media'             => ['styles' => 'media'],
64
+		'list-group'        => ['styles' => 'list-group'],
65
+		'close'             => ['styles' => 'close'],
66
+		'toasts'            => ['styles' => 'toasts', 'scripts' => 'toast.js', 'dependencies' => 'js-util'],
67
+		'modal'             => ['styles' => 'modal', 'scripts' => 'modal.js'],
68
+		'tooltip'           => ['styles' => 'tooltip', 'dependencies' => ['popper', 'js-util']],
69
+		'popover'           => ['styles' => 'popover', 'dependencies' => ['popper', 'tooltip', 'js-util']],
70
+		'carousel'          => ['styles' => 'carousel', 'scripts' => 'carousel.js', 'dependencies' => 'js-util'],
71
+		'spinners'          => ['styles' => 'spinners'],
72
+		'utilities'         => ['styles' => 'utilities'],
73
+		'print'             => ['styles' => 'print'],
74
+		'active-buttons'    => ['scripts' => 'button.js', 'dependencies' => ['buttons']],
75
+		'dismissable-alert' => ['scripts' => 'alert.js', 'dependencies' => ['alert', 'js-util']],
76
+		'collapse'          => ['scripts' => 'collapse.js'],
77
+		'scrollspy'         => ['scripts' => 'scrollspy.js', 'dependencies' => ['popper', 'js-util']],
78
+		'tab'               => ['scripts' => 'tab.js', 'dependencies' => ['list-group']],
79
+		'js-util'           => ['scripts' => 'util.js'],
80
+		'popper'            => ['scripts' => 'popper.js'],
81 81
 
82
-		'bs-core'   => [ 'dependencies' => [ 'variables', 'mixins' ] ],
83
-		'bs-reboot' => [ 'dependencies' => [ 'bs-core', 'reboot' ] ],
84
-		'bs-grid'   => [ 'styles' => 'bootstrap-grid' ],
82
+		'bs-core'   => ['dependencies' => ['variables', 'mixins']],
83
+		'bs-reboot' => ['dependencies' => ['bs-core', 'reboot']],
84
+		'bs-grid'   => ['styles' => 'bootstrap-grid'],
85 85
 
86
-		'bs-basic'  => [ 'dependencies' => [
86
+		'bs-basic'  => ['dependencies' => [
87 87
 			'bs-core', 'root', 'reboot', 'type', 'images', 'code', 'grid',
88 88
 			'tables', 'transitions', 'utilities', 'print'
89
-		] ],
89
+		]],
90 90
 
91
-		'bs-all'    => [ 'dependencies' => [
91
+		'bs-all'    => ['dependencies' => [
92 92
 			'bs-core', 'root', 'reboot', 'type', 'images', 'code', 'grid',
93 93
 			'tables', 'forms', 'buttons', 'transitions', 'dropdown',
94 94
 			'button-group', 'input-group', 'custom-forms', 'nav', 'navbar',
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			'progress', 'media', 'list-group', 'close', 'toasts', 'modal', 'tooltip',
97 97
 			'popover', 'carousel', 'spinners', 'utilities', 'print', 'active-buttons',
98 98
 			'dismissable-alert', 'collapse', 'scrollspy', 'tab', 'js-util',
99
-		] ],
99
+		]],
100 100
 
101 101
 
102 102
 		// TODO: Add each SCSS util separately?
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 
105 105
 	];
106 106
 
107
-	static private $coreModules = [	'bs-core' ];
108
-	static private $optionalModules = [ 'bs-all' ];
107
+	static private $coreModules = ['bs-core'];
108
+	static private $optionalModules = ['bs-all'];
109 109
 
110 110
 	/**
111 111
 	 * @see ModuleDefinition::get
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 * @return array
118 118
 	 * @throws InvalidArgumentException
119 119
 	 */
120
-	public function get( $key ) {
120
+	public function get($key) {
121 121
 
122
-		switch ( $key ) {
122
+		switch ($key) {
123 123
 			case 'core':
124 124
 				return self::$coreModules;
125 125
 			case 'optional':
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				return self::$moduleDescriptions;
129 129
 		}
130 130
 
131
-		throw new InvalidArgumentException( 'Expected a valid key' );
131
+		throw new InvalidArgumentException('Expected a valid key');
132 132
 	}
133 133
 
134 134
 }
Please login to merge, or discard this patch.
src/Definition/ModuleDefinition.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,6 +36,6 @@
 block discarded – undo
36 36
 	 * @param string $key
37 37
 	 * @return array
38 38
 	 */
39
-	public function get( $key );
39
+	public function get($key);
40 40
 
41 41
 }
Please login to merge, or discard this patch.
src/BootstrapManager.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @param ModuleDefinition $moduleDefinition
51 51
 	 */
52
-	public function __construct( ModuleDefinition $moduleDefinition ) {
52
+	public function __construct(ModuleDefinition $moduleDefinition) {
53 53
 		$this->moduleDefinition = $moduleDefinition;
54
-		$this->moduleDescriptions = $this->moduleDefinition->get( 'descriptions' );
54
+		$this->moduleDescriptions = $this->moduleDefinition->get('descriptions');
55 55
 	}
56 56
 
57 57
 	/**
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public static function getInstance() {
65 65
 
66
-		if ( self::$instance === null ) {
67
-			self::$instance = new self( new V4ModuleDefinition );
66
+		if (self::$instance === null) {
67
+			self::$instance = new self(new V4ModuleDefinition);
68 68
 		}
69 69
 
70 70
 		return self::$instance;
@@ -84,29 +84,29 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param string|string[] $modules
86 86
 	 */
87
-	public function addBootstrapModule( $modules ) {
87
+	public function addBootstrapModule($modules) {
88 88
 
89 89
 		$modules = (array) $modules;
90 90
 
91
-		foreach ( $modules as $module ) {
91
+		foreach ($modules as $module) {
92 92
 
93 93
 			// if the module is known
94
-			if ( isset( $this->moduleDescriptions[ $module ] ) ) {
94
+			if (isset($this->moduleDescriptions[$module])) {
95 95
 
96
-				$description = $this->moduleDescriptions[ $module ];
96
+				$description = $this->moduleDescriptions[$module];
97 97
 
98 98
 				// prevent adding this module again; this also prevents infinite recursion in case
99 99
 				// of dependency resolution
100
-				unset( $this->moduleDescriptions[ $module ] );
100
+				unset($this->moduleDescriptions[$module]);
101 101
 
102 102
 				// first add any dependencies recursively, so they are available when the styles and
103 103
 				// scripts of $module are loaded
104
-				if ( isset( $description[ 'dependencies' ] ) ) {
105
-					$this->addBootstrapModule( $description[ 'dependencies' ] );
104
+				if (isset($description['dependencies'])) {
105
+					$this->addBootstrapModule($description['dependencies']);
106 106
 				}
107 107
 
108
-				$this->addFilesToGlobalResourceModules( 'styles', $description );
109
-				$this->addFilesToGlobalResourceModules( 'scripts', $description );
108
+				$this->addFilesToGlobalResourceModules('styles', $description);
109
+				$this->addFilesToGlobalResourceModules('scripts', $description);
110 110
 
111 111
 			}
112 112
 		}
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @param string       $filetype 'styles'|'scripts'
117 117
 	 * @param mixed[]      $description
118 118
 	 */
119
-	protected function addFilesToGlobalResourceModules ( $filetype, $description ) {
119
+	protected function addFilesToGlobalResourceModules($filetype, $description) {
120 120
 
121
-		if ( isset( $description[ $filetype ] ) ) {
121
+		if (isset($description[$filetype])) {
122 122
 
123
-			$this->adjustArrayElementOfResourceModuleDescription( $filetype, $description[ $filetype ], $filetype );
123
+			$this->adjustArrayElementOfResourceModuleDescription($filetype, $description[$filetype], $filetype);
124 124
 
125 125
 		}
126 126
 	}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @since  4.0
132 132
 	 */
133 133
 	public function addCoreBootstrapModules() {
134
-		$this->addBootstrapModule( $this->moduleDefinition->get( 'core' ) );
134
+		$this->addBootstrapModule($this->moduleDefinition->get('core'));
135 135
 	}
136 136
 
137 137
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @since  1.0
141 141
 	 */
142 142
 	public function addAllBootstrapModules() {
143
-		$this->addBootstrapModule( $this->moduleDefinition->get( 'optional' ) );
143
+		$this->addBootstrapModule($this->moduleDefinition->get('optional'));
144 144
 	}
145 145
 
146 146
 	/**
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @internal param string $path
153 153
 	 */
154
-	public function addStyleFile( $path, $position = 'main' ) {
155
-		$this->adjustArrayElementOfResourceModuleDescription( 'styles', [ $path => [ 'position' => $position ] ] );
154
+	public function addStyleFile($path, $position = 'main') {
155
+		$this->adjustArrayElementOfResourceModuleDescription('styles', [$path => ['position' => $position]]);
156 156
 	}
157 157
 
158 158
 	/**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param string $key   the SCSS variable name
162 162
 	 * @param string $value the value to assign to the variable
163 163
 	 */
164
-	public function setScssVariable( $key, $value ) {
165
-		$this->setScssVariables( [ $key => $value ] );
164
+	public function setScssVariable($key, $value) {
165
+		$this->setScssVariables([$key => $value]);
166 166
 	}
167 167
 
168 168
 	/**
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @param mixed[] $variables
172 172
 	 */
173
-	public function setScssVariables( $variables ) {
174
-		$this->adjustArrayElementOfResourceModuleDescription( 'variables', $variables );
173
+	public function setScssVariables($variables) {
174
+		$this->adjustArrayElementOfResourceModuleDescription('variables', $variables);
175 175
 	}
176 176
 
177 177
 	/**
178 178
 	 * @since 1.1
179 179
 	 * @param string|string[] $files
180 180
 	 */
181
-	public function addCacheTriggerFile( $files ){
182
-		$this->adjustArrayElementOfResourceModuleDescription( 'cacheTriggers', $files );
181
+	public function addCacheTriggerFile($files) {
182
+		$this->adjustArrayElementOfResourceModuleDescription('cacheTriggers', $files);
183 183
 	}
184 184
 
185 185
 	/**
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 	 * @param mixed  $value
188 188
 	 * @param string $filetype 'styles'|'scripts'
189 189
 	 */
190
-	protected function adjustArrayElementOfResourceModuleDescription( $key, $value, $filetype = 'styles' ) {
190
+	protected function adjustArrayElementOfResourceModuleDescription($key, $value, $filetype = 'styles') {
191 191
 
192
-		if (!isset($GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.' . $filetype ][ $key ])) {
193
-			$GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.' . $filetype ][ $key ] = [];
192
+		if (!isset($GLOBALS['wgResourceModules']['ext.bootstrap.' . $filetype][$key])) {
193
+			$GLOBALS['wgResourceModules']['ext.bootstrap.' . $filetype][$key] = [];
194 194
 		}
195 195
 
196
-		$GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.' . $filetype ][ $key ] =
196
+		$GLOBALS['wgResourceModules']['ext.bootstrap.' . $filetype][$key] =
197 197
 			array_merge(
198
-				$GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.' . $filetype ][ $key ],
198
+				$GLOBALS['wgResourceModules']['ext.bootstrap.' . $filetype][$key],
199 199
 				(array) $value
200 200
 			);
201 201
 	}
Please login to merge, or discard this patch.
src/Hooks/SetupAfterCache.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @param mixed[] $configuration
51 51
 	 */
52
-	public function __construct( array $configuration ) {
52
+	public function __construct(array $configuration) {
53 53
 		$this->configuration = $configuration;
54 54
 	}
55 55
 
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 		$this->assertAcceptableConfiguration();
69 69
 
70 70
 		$this->registerResourceLoaderModules(
71
-			$this->isReadablePath( $this->configuration['localBasePath'] ),
72
-			$this->configuration[ 'remoteBasePath' ]
71
+			$this->isReadablePath($this->configuration['localBasePath']),
72
+			$this->configuration['remoteBasePath']
73 73
 		);
74 74
 
75 75
 		$this->registerCacheTriggers();
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 	 * @param string $localBasePath
84 84
 	 * @param string $remoteBasePath
85 85
 	 */
86
-	protected function registerResourceLoaderModules( $localBasePath, $remoteBasePath ) {
86
+	protected function registerResourceLoaderModules($localBasePath, $remoteBasePath) {
87 87
 
88
-		$GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.styles' ] = array_replace_recursive(
88
+		$GLOBALS['wgResourceModules']['ext.bootstrap.styles'] = array_replace_recursive(
89 89
 			[
90 90
 				'localBasePath' => $localBasePath . '/scss',
91 91
 				'remoteBasePath' => $remoteBasePath . '/scss',
@@ -99,20 +99,20 @@  discard block
 block discarded – undo
99 99
 					'composer.lock' => null,
100 100
 				],
101 101
 			],
102
-			array_key_exists( 'ext.bootstrap.styles', $GLOBALS[ 'wgResourceModules' ] ) ? $GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.styles' ] : []
102
+			array_key_exists('ext.bootstrap.styles', $GLOBALS['wgResourceModules']) ? $GLOBALS['wgResourceModules']['ext.bootstrap.styles'] : []
103 103
 		);
104 104
 
105
-		$GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.scripts' ] = array_replace_recursive(
105
+		$GLOBALS['wgResourceModules']['ext.bootstrap.scripts'] = array_replace_recursive(
106 106
 			[
107 107
 				'localBasePath'  => $localBasePath . '/js',
108 108
 				'remoteBasePath' => $remoteBasePath . '/js',
109 109
 				'scripts' => [],
110 110
 			],
111
-			array_key_exists( 'ext.bootstrap.scripts', $GLOBALS[ 'wgResourceModules' ] ) ? $GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.scripts' ] : []
111
+			array_key_exists('ext.bootstrap.scripts', $GLOBALS['wgResourceModules']) ? $GLOBALS['wgResourceModules']['ext.bootstrap.scripts'] : []
112 112
 		);
113 113
 
114
-		$GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap' ] = [
115
-			'dependencies' => [ 'ext.bootstrap.styles', 'ext.bootstrap.scripts' ],
114
+		$GLOBALS['wgResourceModules']['ext.bootstrap'] = [
115
+			'dependencies' => ['ext.bootstrap.styles', 'ext.bootstrap.scripts'],
116 116
 		];
117 117
 	}
118 118
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 * @param string $id
121 121
 	 * @return bool
122 122
 	 */
123
-	protected function hasConfiguration( $id ) {
124
-		return isset( $this->configuration[ $id ] );
123
+	protected function hasConfiguration($id) {
124
+		return isset($this->configuration[$id]);
125 125
 	}
126 126
 
127 127
 	/**
@@ -129,28 +129,28 @@  discard block
 block discarded – undo
129 129
 	 * @return string
130 130
 	 * @throws RuntimeException
131 131
 	 */
132
-	protected function isReadablePath( $localBasePath ) {
132
+	protected function isReadablePath($localBasePath) {
133 133
 
134
-		$localBasePath = str_replace( [ '\\', '/' ], DIRECTORY_SEPARATOR, $localBasePath );
134
+		$localBasePath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $localBasePath);
135 135
 
136
-		if ( is_readable( $localBasePath ) ) {
136
+		if (is_readable($localBasePath)) {
137 137
 			return $localBasePath;
138 138
 		}
139 139
 
140
-		throw new RuntimeException( "Expected an accessible {$localBasePath} path" );
140
+		throw new RuntimeException("Expected an accessible {$localBasePath} path");
141 141
 	}
142 142
 
143 143
 	protected function registerCacheTriggers() {
144 144
 
145 145
 		$defaultRecacheTriggers = [
146
-			'LocalSettings.php' => $this->configuration[ 'IP' ] . '/LocalSettings.php',
147
-			'composer.lock' => $this->configuration[ 'IP' ] . '/composer.lock',
146
+			'LocalSettings.php' => $this->configuration['IP'] . '/LocalSettings.php',
147
+			'composer.lock' => $this->configuration['IP'] . '/composer.lock',
148 148
 		];
149 149
 
150
-		foreach ( $defaultRecacheTriggers as $key => $filename ) {
151
-			if ( array_key_exists( $key, $GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.styles' ][ 'cacheTriggers' ] ) &&
152
-				$GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.styles' ][ 'cacheTriggers' ][ $key ] === null ) {
153
-				$GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.styles' ][ 'cacheTriggers' ][ $key ] = $filename;
150
+		foreach ($defaultRecacheTriggers as $key => $filename) {
151
+			if (array_key_exists($key, $GLOBALS['wgResourceModules']['ext.bootstrap.styles']['cacheTriggers']) &&
152
+				$GLOBALS['wgResourceModules']['ext.bootstrap.styles']['cacheTriggers'][$key] === null) {
153
+				$GLOBALS['wgResourceModules']['ext.bootstrap.styles']['cacheTriggers'][$key] = $filename;
154 154
 			}
155 155
 		}
156 156
 	}
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 			'IP' => 'Full path to working directory ($IP) not found.',
164 164
 		];
165 165
 
166
-		foreach ( $configElements as $key => $errorMessage ) {
167
-			if ( !$this->hasConfiguration( $key ) ) {
168
-				throw new InvalidArgumentException( $errorMessage );
166
+		foreach ($configElements as $key => $errorMessage) {
167
+			if (!$this->hasConfiguration($key)) {
168
+				throw new InvalidArgumentException($errorMessage);
169 169
 			}
170 170
 		}
171 171
 	}
Please login to merge, or discard this patch.
src/ResourceLoaderSCSSModule.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 	 * @param string|null $localBasePath
74 74
 	 * @param string|null $remoteBasePath
75 75
 	 */
76
-	public function __construct( $options = [], $localBasePath = null, $remoteBasePath = null ) {
76
+	public function __construct($options = [], $localBasePath = null, $remoteBasePath = null) {
77 77
 
78
-		parent::__construct( $options, $localBasePath, $remoteBasePath );
78
+		parent::__construct($options, $localBasePath, $remoteBasePath);
79 79
 
80
-		$this->applyOptions( $options );
80
+		$this->applyOptions($options);
81 81
 	}
82 82
 
83 83
 	/**
84 84
 	 * @param mixed[] $options
85 85
 	 */
86
-	protected function applyOptions( $options ) {
86
+	protected function applyOptions($options) {
87 87
 
88 88
 		$mapConfigToLocalVar = [
89 89
 			'variables'      => 'variables',
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 			'cacheTriggers' => 'cacheTriggers',
92 92
 		];
93 93
 
94
-		foreach ( $mapConfigToLocalVar as $config => $local ) {
95
-			if ( isset( $options[ $config ] ) ) {
96
-				$this->$local = $options[ $config ];
94
+		foreach ($mapConfigToLocalVar as $config => $local) {
95
+			if (isset($options[$config])) {
96
+				$this->$local = $options[$config];
97 97
 			}
98 98
 		}
99 99
 	}
@@ -105,40 +105,40 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return array
107 107
 	 */
108
-	public function getStyles( ResourceLoaderContext $context ) {
108
+	public function getStyles(ResourceLoaderContext $context) {
109 109
 
110
-		if ( $this->styleText === null ) {
110
+		if ($this->styleText === null) {
111 111
 
112
-			$this->retrieveStylesFromCache( $context );
112
+			$this->retrieveStylesFromCache($context);
113 113
 
114
-			if ( $this->styleText === null ) {
115
-				$this->compileStyles( $context );
114
+			if ($this->styleText === null) {
115
+				$this->compileStyles($context);
116 116
 			}
117 117
 		}
118 118
 
119
-		return [ 'all' => $this->styleText ];
119
+		return ['all' => $this->styleText];
120 120
 	}
121 121
 
122 122
 	/**
123 123
 	 * @param ResourceLoaderContext $context
124 124
 	 */
125
-	protected function retrieveStylesFromCache( ResourceLoaderContext $context ) {
125
+	protected function retrieveStylesFromCache(ResourceLoaderContext $context) {
126 126
 
127 127
 		// Try for cache hit
128
-		$cacheKey = $this->getCacheKey( $context );
129
-		$cacheResult = $this->getCache()->get( $cacheKey );
128
+		$cacheKey = $this->getCacheKey($context);
129
+		$cacheResult = $this->getCache()->get($cacheKey);
130 130
 
131
-		if ( is_array( $cacheResult ) ) {
131
+		if (is_array($cacheResult)) {
132 132
 
133
-			if ( $this->isCacheOutdated( $cacheResult[ 'storetime' ] ) ) {
134
-				wfDebug( "SCSS: Cache miss for {$this->getName()}: Cache outdated.\n", 'private' );
133
+			if ($this->isCacheOutdated($cacheResult['storetime'])) {
134
+				wfDebug("SCSS: Cache miss for {$this->getName()}: Cache outdated.\n", 'private');
135 135
 			} else {
136
-				$this->styleText = $cacheResult[ 'styles' ];
137
-				wfDebug( "SCSS: Cache hit for {$this->getName()}: Got styles from cache.\n", 'private' );
136
+				$this->styleText = $cacheResult['styles'];
137
+				wfDebug("SCSS: Cache hit for {$this->getName()}: Got styles from cache.\n", 'private');
138 138
 			}
139 139
 
140 140
 		} else {
141
-			wfDebug( "SCSS: Cache miss for {$this->getName()}: Styles not found in cache.\n", 'private' );
141
+			wfDebug("SCSS: Cache miss for {$this->getName()}: Styles not found in cache.\n", 'private');
142 142
 		}
143 143
 	}
144 144
 
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	protected function getCache() {
149 149
 
150
-		if ( $this->cache === null ) {
151
-			$this->cache = ObjectCache::getInstance( $GLOBALS[ 'egScssCacheType' ] );
150
+		if ($this->cache === null) {
151
+			$this->cache = ObjectCache::getInstance($GLOBALS['egScssCacheType']);
152 152
 		}
153 153
 
154 154
 		return $this->cache;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @param BagOStuff $cache
161 161
 	 */
162
-	public function setCache( BagOStuff $cache ) {
162
+	public function setCache(BagOStuff $cache) {
163 163
 		$this->cache = $cache;
164 164
 	}
165 165
 
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return string
170 170
 	 */
171
-	protected function getCacheKey( ResourceLoaderContext $context ) {
171
+	protected function getCacheKey(ResourceLoaderContext $context) {
172 172
 
173
-		if ( $this->cacheKey === null ) {
173
+		if ($this->cacheKey === null) {
174 174
 
175
-			$styles = serialize( $this->styles );
175
+			$styles = serialize($this->styles);
176 176
 
177 177
 			$vars = $this->variables;
178
-			ksort( $vars );
179
-			$vars = serialize( $vars );
178
+			ksort($vars);
179
+			$vars = serialize($vars);
180 180
 
181 181
 			// have to hash the module config, else it may become too long
182
-			$configHash = md5( $styles . $vars );
182
+			$configHash = md5($styles . $vars);
183 183
 
184 184
 			$this->cacheKey = wfMemcKey(
185 185
 				'ext',
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @return bool
199 199
 	 */
200
-	protected function isCacheOutdated( $cacheStoreTime ) {
200
+	protected function isCacheOutdated($cacheStoreTime) {
201 201
 
202
-		foreach ( $this->cacheTriggers as $triggerFile ) {
202
+		foreach ($this->cacheTriggers as $triggerFile) {
203 203
 
204
-			if ( $triggerFile !== null && $cacheStoreTime < filemtime( $triggerFile ) ) {
204
+			if ($triggerFile !== null && $cacheStoreTime < filemtime($triggerFile)) {
205 205
 				return true;
206 206
 			}
207 207
 
@@ -213,18 +213,18 @@  discard block
 block discarded – undo
213 213
 	/**
214 214
 	 * @param ResourceLoaderContext $context
215 215
 	 */
216
-	protected function compileStyles( ResourceLoaderContext $context ) {
216
+	protected function compileStyles(ResourceLoaderContext $context) {
217 217
 
218 218
 		$scss = new Compiler();
219
-		$scss->setImportPaths( $this->getLocalPath( '' ) );
219
+		$scss->setImportPaths($this->getLocalPath(''));
220 220
 
221 221
 		// Allows inlining of arbitrary files regardless of extension, .css in particular
222 222
 		$scss->addImportPath(
223 223
 
224 224
 			// addImportPath is declared as requiring a string param, but actually also understand callables
225 225
 			/** @scrutinizer ignore-type */
226
-			function ( $path ) {
227
-				if ( file_exists( $path ) ) {
226
+			function($path) {
227
+				if (file_exists($path)) {
228 228
 					return $path;
229 229
 				}
230 230
 				return null;
@@ -236,27 +236,27 @@  discard block
 block discarded – undo
236 236
 
237 237
 			$imports = $this->getStyleFilesList();
238 238
 
239
-			foreach ( $imports as $key => $import ) {
240
-				$path = str_replace( [ '\\', '"' ], [ '\\\\', '\\"' ], $import );
241
-				$imports[ $key ] = '@import "' . $path . '";';
239
+			foreach ($imports as $key => $import) {
240
+				$path = str_replace(['\\', '"'], ['\\\\', '\\"'], $import);
241
+				$imports[$key] = '@import "' . $path . '";';
242 242
 			}
243 243
 
244
-			$scss->setVariables( $this->variables );
244
+			$scss->setVariables($this->variables);
245 245
 
246
-			$style = $scss->compile( implode( $imports ) );
246
+			$style = $scss->compile(implode($imports));
247 247
 
248
-			if ( $this->getFlip( $context ) ) {
249
-				$style = CSSJanus::transform( $style, true, false );
248
+			if ($this->getFlip($context)) {
249
+				$style = CSSJanus::transform($style, true, false);
250 250
 			}
251 251
 
252 252
 			$this->styleText = $style;
253 253
 
254
-			$this->updateCache( $context );
254
+			$this->updateCache($context);
255 255
 
256
-		} catch ( Exception $e ) {
256
+		} catch (Exception $e) {
257 257
 
258
-			$this->purgeCache( $context );
259
-			wfDebug( $e->getMessage() );
258
+			$this->purgeCache($context);
259
+			wfDebug($e->getMessage());
260 260
 			$this->styleText = '/* SCSS compile error: ' . $e->getMessage() . '*/';
261 261
 		}
262 262
 
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
 	/**
266 266
 	 * @param ResourceLoaderContext $context
267 267
 	 */
268
-	protected function updateCache( ResourceLoaderContext $context ) {
268
+	protected function updateCache(ResourceLoaderContext $context) {
269 269
 
270 270
 		$this->getCache()->set(
271
-			$this->getCacheKey( $context ),
272
-			[ 'styles' => $this->styleText, 'storetime' => time() ]
271
+			$this->getCacheKey($context),
272
+			['styles' => $this->styleText, 'storetime' => time()]
273 273
 		);
274 274
 	}
275 275
 
276 276
 	/**
277 277
 	 * @param ResourceLoaderContext $context
278 278
 	 */
279
-	protected function purgeCache( ResourceLoaderContext $context ) {
280
-		$this->getCache()->delete( $this->getCacheKey( $context ) );
279
+	protected function purgeCache(ResourceLoaderContext $context) {
280
+		$this->getCache()->delete($this->getCacheKey($context));
281 281
 	}
282 282
 
283 283
 	/**
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 	 * @return array
292 292
 	 */
293 293
 	protected function getStyleFilesList() {
294
-		$styles = self::collateFilePathListByOption( $this->styles, 'position', 'main' );
294
+		$styles = self::collateFilePathListByOption($this->styles, 'position', 'main');
295 295
 		$imports = [];
296 296
 
297
-		foreach ( $this->styleModulePositions as $position ) {
298
-			if ( isset( $styles[ $position ] ) ) {
299
-				$imports = array_merge( $imports, $styles[ $position ] );
297
+		foreach ($this->styleModulePositions as $position) {
298
+			if (isset($styles[$position])) {
299
+				$imports = array_merge($imports, $styles[$position]);
300 300
 			}
301 301
 		}
302 302
 
Please login to merge, or discard this patch.
src/Bootstrap.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -51,14 +51,14 @@
 block discarded – undo
51 51
 	 */
52 52
 	public static function init() {
53 53
 
54
-		$GLOBALS[ 'wgHooks' ][ 'SetupAfterCache' ][] = function () {
54
+		$GLOBALS['wgHooks']['SetupAfterCache'][] = function() {
55 55
 
56 56
 			$configuration = [];
57
-			$configuration[ 'IP' ] = $GLOBALS[ 'IP' ];
58
-			$configuration[ 'remoteBasePath' ] = $GLOBALS[ 'wgExtensionAssetsPath' ] . '/Bootstrap/resources/bootstrap';
59
-			$configuration[ 'localBasePath' ] = $GLOBALS[ 'wgExtensionDirectory' ] . '/Bootstrap/resources/bootstrap';
57
+			$configuration['IP'] = $GLOBALS['IP'];
58
+			$configuration['remoteBasePath'] = $GLOBALS['wgExtensionAssetsPath'] . '/Bootstrap/resources/bootstrap';
59
+			$configuration['localBasePath'] = $GLOBALS['wgExtensionDirectory'] . '/Bootstrap/resources/bootstrap';
60 60
 
61
-			$setupAfterCache = new SetupAfterCache( $configuration );
61
+			$setupAfterCache = new SetupAfterCache($configuration);
62 62
 			$setupAfterCache->process();
63 63
 		};
64 64
 	}
Please login to merge, or discard this patch.