Passed
Push — master ( 951ca4...e301fa )
by
unknown
09:47
created
DefaultSettings.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@
 block discarded – undo
8 8
  *
9 9
  * @codeCoverageIgnore
10 10
  */
11
-if ( !defined( 'MEDIAWIKI' ) ) {
12
-	die( 'This file is part of the SemanticCite extension, it is not a valid entry point.' );
11
+if (!defined('MEDIAWIKI')) {
12
+	die('This file is part of the SemanticCite extension, it is not a valid entry point.');
13 13
 }
14 14
 
15 15
 // In-text citation reference format options
16
-define( 'SCI_CITEREF_NUM', 1 );
17
-define( 'SCI_CITEREF_KEY', 2 );
16
+define('SCI_CITEREF_NUM', 1);
17
+define('SCI_CITEREF_KEY', 2);
18 18
 
19 19
 /**
20 20
  * Specifies the caption format of the citation reference, either as a number
Please login to merge, or discard this patch.
SemanticCite.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public static function load() {
27 27
 
28
-		if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
28
+		if (is_readable(__DIR__ . '/vendor/autoload.php')) {
29 29
 			include_once __DIR__ . '/vendor/autoload.php';
30 30
 		}
31 31
 
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 	/**
37 37
 	 * @since 1.1
38 38
 	 */
39
-	public static function initExtension( $credits = [] ) {
39
+	public static function initExtension($credits = []) {
40 40
 
41 41
 		// See https://phabricator.wikimedia.org/T151136
42
-		define( 'SCI_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'UNKNOWN' );
42
+		define('SCI_VERSION', isset($credits['version']) ? $credits['version'] : 'UNKNOWN');
43 43
 
44 44
 		// Extend the upgrade key provided by SMW to ensure that an DB
45 45
 		// schema is updated accordingly before using the extension
46
-		if ( isset( $GLOBALS['smwgUpgradeKey'] ) ) {
46
+		if (isset($GLOBALS['smwgUpgradeKey'])) {
47 47
 		//	$GLOBALS['smwgUpgradeKey'] .= ':scite:2018-09';
48 48
 		}
49 49
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		// Register resource files
62 62
 		$GLOBALS['wgResourceModules']['ext.scite.styles'] = [
63 63
 			'styles'  => 'res/scite.styles.css',
64
-			'localBasePath' => __DIR__ ,
64
+			'localBasePath' => __DIR__,
65 65
 			'remoteExtPath' => 'SemanticCite',
66 66
 			'position' => 'top',
67 67
 			'group'    => 'ext.smw',
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 				'res/scite.text.selector.js',
77 77
 				'res/scite.page.creator.js'
78 78
 			],
79
-			'localBasePath' => __DIR__ ,
79
+			'localBasePath' => __DIR__,
80 80
 			'remoteExtPath' => 'SemanticCite',
81 81
 			'position' => 'top',
82 82
 			'group'    => 'ext.smw',
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		];
92 92
 
93 93
 		// #71
94
-		if ( version_compare( $GLOBALS['wgVersion'], '1.32', '<' ) ) {
94
+		if (version_compare($GLOBALS['wgVersion'], '1.32', '<')) {
95 95
 			$dependencies = [
96 96
 				'onoi.qtip',
97 97
 				'onoi.blobstore',
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			'scripts' => [
112 112
 				'res/scite.tooltip.js'
113 113
 			],
114
-			'localBasePath' => __DIR__ ,
114
+			'localBasePath' => __DIR__,
115 115
 			'remoteExtPath' => 'SemanticCite',
116 116
 			'dependencies'  => $dependencies,
117 117
 			'messages' => [
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public static function onExtensionFunction() {
136 136
 
137
-		if ( !defined( 'SMW_VERSION' ) ) {
138
-			if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
139
-				die( "\nThe 'Semantic Cite' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" );
137
+		if (!defined('SMW_VERSION')) {
138
+			if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
139
+				die("\nThe 'Semantic Cite' extension requires 'Semantic MediaWiki' to be installed and enabled.\n");
140 140
 			} else {
141
-				die( '<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticCite/">Semantic Cite</a> extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> to be installed and enabled.<br />' );
141
+				die('<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticCite/">Semantic Cite</a> extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> to be installed and enabled.<br />');
142 142
 			}
143 143
 		}
144 144
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 
164 164
 		$hookRegistry = new HookRegistry(
165 165
 			$applicationFactory->getStore(),
166
-			$applicationFactory->newCacheFactory()->newMediaWikiCompositeCache( $GLOBALS['scigReferenceListCacheType'] ),
167
-			new Options( $configuration )
166
+			$applicationFactory->newCacheFactory()->newMediaWikiCompositeCache($GLOBALS['scigReferenceListCacheType']),
167
+			new Options($configuration)
168 168
 		);
169 169
 
170 170
 		$hookRegistry->register();
Please login to merge, or discard this patch.
src/Bibtex/BibtexProcessor.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param BibtexParser $bibtexParser
27 27
 	 * @param BibtexAuthorListParser $bibtexAuthorListParser
28 28
 	 */
29
-	public function __construct( BibtexParser $bibtexParser, BibtexAuthorListParser $bibtexAuthorListParser ) {
29
+	public function __construct(BibtexParser $bibtexParser, BibtexAuthorListParser $bibtexAuthorListParser) {
30 30
 		$this->bibtexParser = $bibtexParser;
31 31
 		$this->bibtexAuthorListParser = $bibtexAuthorListParser;
32 32
 	}
@@ -36,30 +36,30 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param ParserParameterProcessor $parserParameterProcessor
38 38
 	 */
39
-	public function doProcess( ParserParameterProcessor $parserParameterProcessor ) {
39
+	public function doProcess(ParserParameterProcessor $parserParameterProcessor) {
40 40
 
41 41
 		$bibtex = $this->doPreprocess(
42
-			$parserParameterProcessor->getParameterValuesFor( 'bibtex' )
42
+			$parserParameterProcessor->getParameterValuesFor('bibtex')
43 43
 		);
44 44
 
45
-		$parameters = $this->bibtexParser->parse( $bibtex );
45
+		$parameters = $this->bibtexParser->parse($bibtex);
46 46
 
47
-		foreach ( $parameters as $key => $value ) {
47
+		foreach ($parameters as $key => $value) {
48 48
 
49 49
 			// The explicit parameters precedes the one found in bibtex
50
-			if ( $key === 'reference' && ( $parserParameterProcessor->hasParameter( 'reference' ) || $parserParameterProcessor->getFirstParameter() !== '' ) ) {
50
+			if ($key === 'reference' && ($parserParameterProcessor->hasParameter('reference') || $parserParameterProcessor->getFirstParameter() !== '')) {
51 51
 				continue;
52 52
 			}
53 53
 
54
-			if ( $key === 'type' && $parserParameterProcessor->hasParameter( 'type' ) ) {
54
+			if ($key === 'type' && $parserParameterProcessor->hasParameter('type')) {
55 55
 				continue;
56 56
 			}
57 57
 
58
-			if ( $key === 'author' ) {
58
+			if ($key === 'author') {
59 59
 
60 60
 				$parserParameterProcessor->setParameter(
61 61
 					$key,
62
-					$this->bibtexAuthorListParser->parse( $value )
62
+					$this->bibtexAuthorListParser->parse($value)
63 63
 				);
64 64
 
65 65
 				// Add the original value for easier post-processing in a template
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
 		}
75 75
 	}
76 76
 
77
-	private function doPreprocess( array $bibtex ) {
77
+	private function doPreprocess(array $bibtex) {
78 78
 
79
-		$bibtex = end( $bibtex );
79
+		$bibtex = end($bibtex);
80 80
 
81 81
 		// Avoid things like {{Stable theories}}" which are not supported in MW
82 82
 		// since the parser replaces it with [[:Template:Stable theories]]
83
-		$this->replace( '{{', "{", $bibtex );
84
-		$this->replace( '}}', "}", $bibtex );
83
+		$this->replace('{{', "{", $bibtex);
84
+		$this->replace('}}', "}", $bibtex);
85 85
 
86
-		$this->replace( '{\textquotesingle}', "'", $bibtex );
87
-		$this->replace( '$\upgamma$', "γ", $bibtex );
86
+		$this->replace('{\textquotesingle}', "'", $bibtex);
87
+		$this->replace('$\upgamma$', "γ", $bibtex);
88 88
 
89 89
 		return $bibtex;
90 90
 	}
91 91
 
92
-	private function replace( $search, $with, &$on ) {
93
-		$on = strpos( $on, $search ) !== false ? str_replace( $search, $with, $on ) : $on;
92
+	private function replace($search, $with, &$on) {
93
+		$on = strpos($on, $search) !== false ? str_replace($search, $with, $on) : $on;
94 94
 	}
95 95
 
96 96
 }
Please login to merge, or discard this patch.
src/Bibtex/BibtexAuthorListParser.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @return array
36 36
 	 */
37
-	public function parse( $input ) {
37
+	public function parse($input) {
38 38
 
39 39
 		$authorList = [];
40 40
 
41 41
 		// split on ' and '
42
-		$authorArray = preg_split("/\s(and|&)\s/i", trim( $input ) );
42
+		$authorArray = preg_split("/\s(and|&)\s/i", trim($input));
43 43
 
44
-		foreach( $authorArray as $value ) {
44
+		foreach ($authorArray as $value) {
45 45
 			$appellation = '';
46 46
 			$prefix = '';
47 47
 
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 
51 51
 			$this->prefix = [];
52 52
 
53
-			$author = explode( ",", preg_replace("/\s{2,}/", ' ', trim( $value ) ) );
54
-			$size = count( $author );
53
+			$author = explode(",", preg_replace("/\s{2,}/", ' ', trim($value)));
54
+			$size = count($author);
55 55
 
56 56
 			// No commas therefore something like Mark Grimshaw, Mark Nicholas Grimshaw, M N Grimshaw, Mark N. Grimshaw
57
-			if( $size == 1 ) {
57
+			if ($size == 1) {
58 58
 				// Is complete surname enclosed in {...}, unless the string starts with a backslash (\) because then it is
59 59
 				// probably a special latex-sign..
60 60
 				// 2006.02.11 DR: in the last case, any NESTED curly braces should also be taken into account! so second
61 61
 				// clause rules out things such as author="a{\"{o}}"
62 62
 				//
63
-				if( preg_match("/(.*){([^\\\].*)}/", $value, $matches) &&
64
-					!(preg_match("/(.*){\\\.{.*}.*}/", $value, $matches2 ) ) ) {
63
+				if (preg_match("/(.*){([^\\\].*)}/", $value, $matches) &&
64
+					!(preg_match("/(.*){\\\.{.*}.*}/", $value, $matches2))) {
65 65
 					$author = explode(" ", $matches[1]);
66 66
 					$surname = $matches[2];
67 67
 				} else {
@@ -69,50 +69,50 @@  discard block
 block discarded – undo
69 69
 					// last of array is surname (no prefix if entered correctly)
70 70
 					$surname = array_pop($author);
71 71
 				}
72
-			} elseif( $size == 2 ) { // Something like Grimshaw, Mark or Grimshaw, Mark Nicholas  or Grimshaw, M N or Grimshaw, Mark N.
72
+			} elseif ($size == 2) { // Something like Grimshaw, Mark or Grimshaw, Mark Nicholas  or Grimshaw, M N or Grimshaw, Mark N.
73 73
 				// first of array is surname (perhaps with prefix)
74
-				list( $surname, $prefix ) = $this->grabSurname( array_shift( $author ) );
74
+				list($surname, $prefix) = $this->grabSurname(array_shift($author));
75 75
 			} else { // If $size is 3, we're looking at something like Bush, Jr. III, George W
76 76
 				// middle of array is 'Jr.', 'IV' etc.
77
-				$appellation = implode(' ', array_splice( $author, 1, 1 ) );
77
+				$appellation = implode(' ', array_splice($author, 1, 1));
78 78
 				// first of array is surname (perhaps with prefix)
79
-				list( $surname, $prefix ) = $this->grabSurname( array_shift( $author ) );
79
+				list($surname, $prefix) = $this->grabSurname(array_shift($author));
80 80
 			}
81 81
 
82
-			$remainder = implode( " ", $author );
82
+			$remainder = implode(" ", $author);
83 83
 
84
-			list( $firstname, $initials ) = $this->grabFirstnameInitials( $remainder );
84
+			list($firstname, $initials) = $this->grabFirstnameInitials($remainder);
85 85
 
86
-			if( $this->prefix !== [] ) {
87
-				$prefix = implode(' ', $this->prefix );
86
+			if ($this->prefix !== []) {
87
+				$prefix = implode(' ', $this->prefix);
88 88
 			}
89 89
 
90
-			$surname = $surname . ' ' . trim( $appellation );
90
+			$surname = $surname . ' ' . trim($appellation);
91 91
 
92
-			$authorList[] = $this->concatenate( $firstname, $initials, $surname, $prefix );
92
+			$authorList[] = $this->concatenate($firstname, $initials, $surname, $prefix);
93 93
 		}
94 94
 
95 95
 		return $authorList;
96 96
 	}
97 97
 
98
-	private function concatenate( $firstname, $initials, $surname, $prefix ) {
98
+	private function concatenate($firstname, $initials, $surname, $prefix) {
99 99
 
100 100
 		$author = [
101
-			trim( $firstname ),
102
-			trim( $initials ),
103
-			trim( $prefix ),
104
-			trim( $surname )
101
+			trim($firstname),
102
+			trim($initials),
103
+			trim($prefix),
104
+			trim($surname)
105 105
 		];
106 106
 
107
-		return implode( ' ', array_filter( $author ) );
107
+		return implode(' ', array_filter($author));
108 108
 	}
109 109
 
110 110
 	/**
111 111
 	 * @note firstname and initials which may be of form "A.B.C." or "A. B. C. " or " A B C " etc.
112 112
 	 */
113
-	private function grabFirstnameInitials( $remainder ) {
113
+	private function grabFirstnameInitials($remainder) {
114 114
 
115
-		$array = explode( " ", $remainder );
115
+		$array = explode(" ", $remainder);
116 116
 
117 117
 		$firstname = '';
118 118
 		$initials = '';
@@ -120,25 +120,25 @@  discard block
 block discarded – undo
120 120
 		$initialsArray = [];
121 121
 		$firstnameArray = [];
122 122
 
123
-		foreach( $array as $value ) {
123
+		foreach ($array as $value) {
124 124
 			$firstChar = substr($value, 0, 1);
125 125
 
126
-			if( ( ord( $firstChar ) >= 97 ) && ( ord( $firstChar ) <= 122) ) {
126
+			if ((ord($firstChar) >= 97) && (ord($firstChar) <= 122)) {
127 127
 				$this->prefix[] = $value;
128
-			} elseif( preg_match("/[a-zA-Z]{2,}/", trim( $value ) ) ) {
128
+			} elseif (preg_match("/[a-zA-Z]{2,}/", trim($value))) {
129 129
 				$firstnameArray[] = trim($value);
130 130
 			} else {
131
-				$initialsArray[] = str_replace(".", " ", trim( $value ) );
131
+				$initialsArray[] = str_replace(".", " ", trim($value));
132 132
 			}
133 133
 		}
134 134
 
135
-		foreach( $initialsArray as $initial) {
136
-			$initials .= ' ' . trim ( $initial );
135
+		foreach ($initialsArray as $initial) {
136
+			$initials .= ' ' . trim($initial);
137 137
 		}
138 138
 
139 139
 		$firstname = implode(" ", $firstnameArray);
140 140
 
141
-		return [ $firstname, $initials ];
141
+		return [$firstname, $initials];
142 142
 	}
143 143
 
144 144
 	/**
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 	 * characterised by first character lowercased.  Any uppercased part means
147 147
 	 * lowercased parts following are part of the surname (e.g. Van den Bussche)
148 148
 	 */
149
-	private function grabSurname( $input ) {
150
-		$surnameArray = explode(" ", $input );
149
+	private function grabSurname($input) {
150
+		$surnameArray = explode(" ", $input);
151 151
 
152 152
 		$noPrefix = false;
153 153
 		$surname = [];
154 154
 		$prefix = [];
155 155
 
156
-		foreach( $surnameArray as $value ) {
156
+		foreach ($surnameArray as $value) {
157 157
 			$firstChar = substr($value, 0, 1);
158 158
 
159
-			if( !$noPrefix && ( ord( $firstChar ) >= 97 ) && ( ord( $firstChar ) <= 122 ) ) {
159
+			if (!$noPrefix && (ord($firstChar) >= 97) && (ord($firstChar) <= 122)) {
160 160
 				$prefix[] = $value;
161 161
 			} else {
162 162
 				$surname[] = $value;
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 
167 167
 		$surname = implode(" ", $surname);
168 168
 
169
-		if( $prefix !== [] ) {
170
-			return [ $surname, implode(" ", $prefix ) ];
169
+		if ($prefix !== []) {
170
+			return [$surname, implode(" ", $prefix)];
171 171
 		}
172 172
 
173
-		return [ $surname, false ];
173
+		return [$surname, false];
174 174
 	}
175 175
 }
Please login to merge, or discard this patch.
src/Bibtex/BibtexParser.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -41,107 +41,107 @@
 block discarded – undo
41 41
 	 *
42 42
 	 * @return array
43 43
 	 */
44
-	public function parse( $bibtex ) {
44
+	public function parse($bibtex) {
45 45
 
46
-		if ( ( $matches = $this->findBibtexFormatMatches( $bibtex ) ) === [] ) {
46
+		if (($matches = $this->findBibtexFormatMatches($bibtex)) === []) {
47 47
 			return [];
48 48
 		}
49 49
 
50 50
 		$head = [
51
-			'type'      => strtolower( trim( $matches[1] ) ),
51
+			'type'      => strtolower(trim($matches[1])),
52 52
 			'reference' => $matches[2]
53 53
 		];
54 54
 
55
-		return $head + $this->parseFields( $matches[3] );
55
+		return $head + $this->parseFields($matches[3]);
56 56
 	}
57 57
 
58
-	private function findBibtexFormatMatches( $bibtex ) {
58
+	private function findBibtexFormatMatches($bibtex) {
59 59
 
60
-		$matches = preg_split("/@(.*)[{(](.*),/U", $bibtex, 2, PREG_SPLIT_DELIM_CAPTURE );
60
+		$matches = preg_split("/@(.*)[{(](.*),/U", $bibtex, 2, PREG_SPLIT_DELIM_CAPTURE);
61 61
 
62 62
 		// Silently retreat from processing
63
-		if ( !isset( $matches[2] ) ) {
63
+		if (!isset($matches[2])) {
64 64
 			return [];
65 65
 		}
66 66
 
67
-		if( preg_match("/=/", $matches[2] ) ) {
68
-			$matches = preg_split("/@(.*)\s*[{(](.*)/U", $bibtex, 2, PREG_SPLIT_DELIM_CAPTURE );
67
+		if (preg_match("/=/", $matches[2])) {
68
+			$matches = preg_split("/@(.*)\s*[{(](.*)/U", $bibtex, 2, PREG_SPLIT_DELIM_CAPTURE);
69 69
 		}
70 70
 
71 71
 		return $matches;
72 72
 	}
73 73
 
74
-	private function parseFields( $content ) {
74
+	private function parseFields($content) {
75 75
 		$elements = [];
76 76
 		$values = [];
77 77
 
78
-		$length = strlen( $content );
78
+		$length = strlen($content);
79 79
 
80
-		if( $content[$length - 1] == "}" ||  $content[$length - 1] == ")" ||  $content[$length - 1] == ",") {
81
-			$content = substr( $content,  0, $length - 1 );
80
+		if ($content[$length - 1] == "}" || $content[$length - 1] == ")" || $content[$length - 1] == ",") {
81
+			$content = substr($content, 0, $length - 1);
82 82
 		}
83 83
 
84
-		$split = preg_split("/=/",  $content, 2 );
84
+		$split = preg_split("/=/", $content, 2);
85 85
 		$string = $split[1];
86 86
 
87
-		while( $string ) {
88
-			list( $entry, $string ) = $this->splitField( $string );
87
+		while ($string) {
88
+			list($entry, $string) = $this->splitField($string);
89 89
 			$values[] = $entry;
90 90
 		}
91 91
 
92
-		foreach( $values as $value ) {
93
-			$pos = strpos( $content, $value);
94
-			$content = substr_replace( $content, '', $pos, strlen( $value ) );
92
+		foreach ($values as $value) {
93
+			$pos = strpos($content, $value);
94
+			$content = substr_replace($content, '', $pos, strlen($value));
95 95
 		}
96 96
 
97
-		$rev = strrev( trim( $content ) );
97
+		$rev = strrev(trim($content));
98 98
 
99
-		if( $rev[0] != ',') {
99
+		if ($rev[0] != ',') {
100 100
 			 $content .= ',';
101 101
 		}
102 102
 
103
-		$keys = preg_split("/=,/",  $content );
103
+		$keys = preg_split("/=,/", $content);
104 104
 		array_pop($keys);
105 105
 
106
-		foreach( $keys as $key ) {
107
-			$value = trim( array_shift( $values ) );
108
-			$rev = strrev( $value );
106
+		foreach ($keys as $key) {
107
+			$value = trim(array_shift($values));
108
+			$rev = strrev($value);
109 109
 
110 110
 			// remove any dangling ',' left on final field of entry
111
-			if( $rev[0] == ',') {
111
+			if ($rev[0] == ',') {
112 112
 				$value = rtrim($value, ",");
113 113
 			}
114 114
 
115
-			if(!$value) {
115
+			if (!$value) {
116 116
 				continue;
117 117
 			}
118 118
 
119 119
 			$key = strtolower(trim($key));
120 120
 			$value = trim($value);
121
-			$elements[$key] = $this->removeDelimiters( $value );
121
+			$elements[$key] = $this->removeDelimiters($value);
122 122
 		}
123 123
 
124 124
 		return $elements;
125 125
 	}
126 126
 
127
-	private function splitField( $seg ) {
127
+	private function splitField($seg) {
128 128
 
129
-		$array = preg_split("/,\s*([-_.:,a-zA-Z0-9]+)\s*={1}\s*/U", $seg, PREG_SPLIT_DELIM_CAPTURE );
129
+		$array = preg_split("/,\s*([-_.:,a-zA-Z0-9]+)\s*={1}\s*/U", $seg, PREG_SPLIT_DELIM_CAPTURE);
130 130
 
131 131
 	//	if(!array_key_exists( 1, $array ) ) {
132 132
 	//		return array( $array[0], FALSE);
133 133
 	//	}
134 134
 
135
-		return isset( $array[1] ) ? [ $array[0], $array[1] ] : [ $array[0], false ];
135
+		return isset($array[1]) ? [$array[0], $array[1]] : [$array[0], false];
136 136
 	}
137 137
 
138
-	private function removeDelimiters( $string ) {
138
+	private function removeDelimiters($string) {
139 139
 
140
-		if( $string  && ( $string[0] == "\"") ) {
140
+		if ($string && ($string[0] == "\"")) {
141 141
 			$string = substr($string, 1);
142 142
 			$string = substr($string, 0, -1);
143
-		} else if ( $string && ( $string[0] == "{") ) {
144
-			if( strlen( $string ) > 0 && $string[strlen($string)-1] == "}" ) {
143
+		} else if ($string && ($string[0] == "{")) {
144
+			if (strlen($string) > 0 && $string[strlen($string) - 1] == "}") {
145 145
 				$string = substr($string, 1);
146 146
 				$string = substr($string, 0, -1);
147 147
 			}
Please login to merge, or discard this patch.
src/ReferenceListFactory.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param NamespaceExaminer $namespaceExaminer
39 39
 	 * @param CitationReferencePositionJournal $citationReferencePositionJournal
40 40
 	 */
41
-	public function __construct( Store $store, NamespaceExaminer $namespaceExaminer, CitationReferencePositionJournal $citationReferencePositionJournal ) {
41
+	public function __construct(Store $store, NamespaceExaminer $namespaceExaminer, CitationReferencePositionJournal $citationReferencePositionJournal) {
42 42
 		$this->store = $store;
43 43
 		$this->namespaceExaminer = $namespaceExaminer;
44 44
 		$this->citationReferencePositionJournal = $citationReferencePositionJournal;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		$htmlColumnListRenderer = $mwCollaboratorFactory->newHtmlColumnListRenderer();
56 56
 
57 57
 		$referenceListOutputRenderer = new ReferenceListOutputRenderer(
58
-			new CitationResourceMatchFinder( $this->store ),
58
+			new CitationResourceMatchFinder($this->store),
59 59
 			$this->citationReferencePositionJournal,
60 60
 			$htmlColumnListRenderer
61 61
 		);
@@ -73,28 +73,28 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return CachedReferenceListOutputRenderer
75 75
 	 */
76
-	public function newCachedReferenceListOutputRenderer( MediaWikiContextInteractor $contextInteractor, Cache $cache, CacheKeyProvider $cacheKeyProvider, Options $options ) {
76
+	public function newCachedReferenceListOutputRenderer(MediaWikiContextInteractor $contextInteractor, Cache $cache, CacheKeyProvider $cacheKeyProvider, Options $options) {
77 77
 
78 78
 		$referenceListOutputRenderer = $this->newReferenceListOutputRenderer();
79 79
 
80 80
 		$referenceListOutputRenderer->setNumberOfReferenceListColumns(
81
-			$options->get( 'numberOfReferenceListColumns' )
81
+			$options->get('numberOfReferenceListColumns')
82 82
 		);
83 83
 
84 84
 		$referenceListOutputRenderer->setResponsiveMonoColumnCharacterBoundLength(
85
-			$options->get( 'responsiveMonoColumnCharacterBoundLength' )
85
+			$options->get('responsiveMonoColumnCharacterBoundLength')
86 86
 		);
87 87
 
88 88
 		$referenceListOutputRenderer->setReferenceListType(
89
-			$options->get( 'referenceListType' )
89
+			$options->get('referenceListType')
90 90
 		);
91 91
 
92 92
 		$referenceListOutputRenderer->setBrowseLinkToCitationResourceVisibility(
93
-			$options->get( 'browseLinkToCitationResource' )
93
+			$options->get('browseLinkToCitationResource')
94 94
 		);
95 95
 
96 96
 		$referenceListOutputRenderer->setCitationReferenceCaptionFormat(
97
-			$options->get( 'citationReferenceCaptionFormat' )
97
+			$options->get('citationReferenceCaptionFormat')
98 98
 		);
99 99
 
100 100
 		$cachedReferenceListOutputRenderer = new CachedReferenceListOutputRenderer(
Please login to merge, or discard this patch.
src/MediaWikiContextInteractor.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param IContextSource $context
34 34
 	 */
35
-	public function __construct( IContextSource $context ) {
35
+	public function __construct(IContextSource $context) {
36 36
 		$this->context = $context;
37 37
 		$this->revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
38 38
 	}
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 	 * @return int
46 46
 	 */
47 47
 	public function getOldId() {
48
-		$oldid = $this->context->getRequest()->getInt( 'oldid' );
48
+		$oldid = $this->context->getRequest()->getInt('oldid');
49 49
 		$title = $this->context->getTitle();
50 50
 
51
-		switch ( $this->context->getRequest()->getText( 'direction' ) ) {
51
+		switch ($this->context->getRequest()->getText('direction')) {
52 52
 			case 'next':
53 53
 				# output next revision, or nothing if there isn't one
54 54
 				$nextid = 0;
55
-				if ( $oldid ) {
56
-					$revision = $this->revisionLookup->getRevisionById( $oldid );
57
-					$nextRevision = $this->revisionLookup->getNextRevision( $revision );
58
-					if ( $nextRevision ) {
55
+				if ($oldid) {
56
+					$revision = $this->revisionLookup->getRevisionById($oldid);
57
+					$nextRevision = $this->revisionLookup->getNextRevision($revision);
58
+					if ($nextRevision) {
59 59
 						$nextid = $nextRevision->getId();
60 60
 					}
61 61
 				}
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 			case 'prev':
65 65
 				# output previous revision, or nothing if there isn't one
66 66
 				$previd = 0;
67
-				if ( !$oldid ) {
67
+				if (!$oldid) {
68 68
 					# get the current revision so we can get the penultimate one
69 69
 					$oldid = $title->getLatestRevID();
70 70
 				}
71
-				if ( $oldid ) {
72
-					$revision = $this->revisionLookup->getRevisionById( $oldid );
73
-					$previousRevision = $this->revisionLookup->getPreviousRevision( $revision );
74
-					if ( $previousRevision ) {
71
+				if ($oldid) {
72
+					$revision = $this->revisionLookup->getRevisionById($oldid);
73
+					$previousRevision = $this->revisionLookup->getPreviousRevision($revision);
74
+					if ($previousRevision) {
75 75
 						$previd = $previousRevision->getId();
76 76
 					}
77 77
 				}
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return boolean
94 94
 	 */
95
-	public function hasMagicWord( $magicword ) {
95
+	public function hasMagicWord($magicword) {
96 96
 
97 97
 		$outputPage = $this->context->getOutput();
98 98
 
99
-		if ( isset( $outputPage->smwmagicwords ) && in_array( $magicword, $outputPage->smwmagicwords ) ) {
99
+		if (isset($outputPage->smwmagicwords) && in_array($magicword, $outputPage->smwmagicwords)) {
100 100
 			return true;
101 101
 		}
102 102
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return boolean
112 112
 	 */
113
-	public function hasAction( $action ) {
114
-		return \Action::getActionName( $this->context ) === $action;
113
+	public function hasAction($action) {
114
+		return \Action::getActionName($this->context) === $action;
115 115
 	}
116 116
 
117 117
 	/**
Please login to merge, or discard this patch.
src/ReferenceBacklinksLookup.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @param Store $store
41 41
 	 */
42
-	public function __construct( Store $store ) {
42
+	public function __construct(Store $store) {
43 43
 		$this->store = $store;
44 44
 	}
45 45
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @param Store $store
50 50
 	 */
51
-	public function setStore( Store $store ) {
51
+	public function setStore(Store $store) {
52 52
 		$this->store = $store;
53 53
 	}
54 54
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @param mixed|null $requestOptions
59 59
 	 */
60
-	public function setRequestOptions( $requestOptions = null ) {
60
+	public function setRequestOptions($requestOptions = null) {
61 61
 
62
-		if ( $requestOptions === null ) {
62
+		if ($requestOptions === null) {
63 63
 			return;
64 64
 		}
65 65
 
@@ -74,21 +74,21 @@  discard block
 block discarded – undo
74 74
 	 * @param DIWikiPage $subject
75 75
 	 * @param string &$html
76 76
 	 */
77
-	public function getSpecialPropertySearchFurtherLink( DIProperty $property, DIWikiPage $subject, &$html ) {
77
+	public function getSpecialPropertySearchFurtherLink(DIProperty $property, DIWikiPage $subject, &$html) {
78 78
 
79
-		if ( $property->getKey() !== PropertyRegistry::SCI_CITE_REFERENCE || ( $citationKey = $this->tryToFindCitationKeyFor( $subject ) ) === null ) {
79
+		if ($property->getKey() !== PropertyRegistry::SCI_CITE_REFERENCE || ($citationKey = $this->tryToFindCitationKeyFor($subject)) === null) {
80 80
 			return true;
81 81
 		}
82 82
 
83 83
 		$html .= \Html::element(
84 84
 			'a',
85 85
 			[
86
-				'href' => \SpecialPage::getSafeTitleFor( 'SearchByProperty' )->getLocalURL( [
86
+				'href' => \SpecialPage::getSafeTitleFor('SearchByProperty')->getLocalURL([
87 87
 					'property' => $property->getLabel(),
88 88
 					'value' => $citationKey->getString()
89
-				] )
89
+				])
90 90
 			],
91
-			wfMessage( 'smw_browse_more' )->text()
91
+			wfMessage('smw_browse_more')->text()
92 92
 		);
93 93
 
94 94
 		return false;
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @param SemanticData $semanticData
104 104
 	 */
105
-	public function addReferenceBacklinksTo( SemanticData $semanticData ) {
105
+	public function addReferenceBacklinksTo(SemanticData $semanticData) {
106 106
 
107
-		$key = $this->tryToFindCitationKeyFor( $semanticData->getSubject() );
107
+		$key = $this->tryToFindCitationKeyFor($semanticData->getSubject());
108 108
 
109 109
 		$property = new DIProperty(
110 110
 			PropertyRegistry::SCI_CITE_REFERENCE
111 111
 		);
112 112
 
113
-		foreach ( $this->findReferenceBacklinksFor( $key ) as $subject ) {
114
-			$semanticData->addPropertyObjectValue( $property, $subject );
113
+		foreach ($this->findReferenceBacklinksFor($key) as $subject) {
114
+			$semanticData->addPropertyObjectValue($property, $subject);
115 115
 		}
116 116
 	}
117 117
 
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return DIBlob|null
124 124
 	 */
125
-	public function tryToFindCitationKeyFor( DIWikiPage $subject ) {
125
+	public function tryToFindCitationKeyFor(DIWikiPage $subject) {
126 126
 
127
-		$keys = $this->store->getSemanticData( $subject )->getPropertyValues(
128
-			new DIProperty( PropertyRegistry::SCI_CITE_KEY )
127
+		$keys = $this->store->getSemanticData($subject)->getPropertyValues(
128
+			new DIProperty(PropertyRegistry::SCI_CITE_KEY)
129 129
 		);
130 130
 
131 131
 		// Not a resource that contains a citation key
132
-		if ( $keys === null || $keys === [] ) {
132
+		if ($keys === null || $keys === []) {
133 133
 			return null;
134 134
 		}
135 135
 
136
-		return end( $keys );
136
+		return end($keys);
137 137
 	}
138 138
 
139 139
 	/**
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @return DIWikiPage[]
145 145
 	 */
146
-	public function findReferenceBacklinksFor( $key = null ) {
146
+	public function findReferenceBacklinksFor($key = null) {
147 147
 
148
-		if ( $key === null ) {
148
+		if ($key === null) {
149 149
 			return [];
150 150
 		}
151 151
 
152
-		$property = new DIProperty( PropertyRegistry::SCI_CITE_REFERENCE );
152
+		$property = new DIProperty(PropertyRegistry::SCI_CITE_REFERENCE);
153 153
 
154 154
 		$description = new ValueDescription(
155 155
 			$key,
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 			$description
162 162
 		);
163 163
 
164
-		$query = new Query( $someProperty );
165
-		$query->setLimit( $this->limit );
166
-		$query->setOffset( $this->offset );
164
+		$query = new Query($someProperty);
165
+		$query->setLimit($this->limit);
166
+		$query->setOffset($this->offset);
167 167
 
168
-		if ( defined( 'SMWQuery::PROC_CONTEXT' ) ) {
169
-			$query->setOption( Query::PROC_CONTEXT, 'SCI.ReferenceBacklinksLookup' );
168
+		if (defined('SMWQuery::PROC_CONTEXT')) {
169
+			$query->setOption(Query::PROC_CONTEXT, 'SCI.ReferenceBacklinksLookup');
170 170
 		}
171 171
 
172
-		return $this->store->getQueryResult( $query )->getResults();
172
+		return $this->store->getQueryResult($query)->getResults();
173 173
 	}
174 174
 
175 175
 }
Please login to merge, or discard this patch.
src/PropertyRegistry.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,16 +5,16 @@  discard block
 block discarded – undo
5 5
 use SMW\PropertyRegistry as CorePropertyRegistry;
6 6
 
7 7
 // Globally defined predefined property labels
8
-define( 'SCI_PROP_CITE_KEY', 'Citation key' );
9
-define( 'SCI_PROP_CITE_REFERENCE', 'Citation reference' );
10
-define( 'SCI_PROP_CITE_TEXT', 'Citation text' );
11
-define( 'SCI_PROP_CITE', 'Citation resource' );
12
-define( 'SCI_PROP_DOI', 'DOI' );
13
-define( 'SCI_PROP_PMCID', 'PMCID' );
14
-define( 'SCI_PROP_PMID', 'PMID' );
15
-define( 'SCI_PROP_OCLC', 'OCLC' );
16
-define( 'SCI_PROP_VIAF', 'VIAF' );
17
-define( 'SCI_PROP_OLID', 'OLID' );
8
+define('SCI_PROP_CITE_KEY', 'Citation key');
9
+define('SCI_PROP_CITE_REFERENCE', 'Citation reference');
10
+define('SCI_PROP_CITE_TEXT', 'Citation text');
11
+define('SCI_PROP_CITE', 'Citation resource');
12
+define('SCI_PROP_DOI', 'DOI');
13
+define('SCI_PROP_PMCID', 'PMCID');
14
+define('SCI_PROP_PMID', 'PMID');
15
+define('SCI_PROP_OCLC', 'OCLC');
16
+define('SCI_PROP_VIAF', 'VIAF');
17
+define('SCI_PROP_OLID', 'OLID');
18 18
 
19 19
 /**
20 20
  * @license GNU GPL v2+
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return boolean
44 44
 	 */
45
-	public function registerTo( CorePropertyRegistry $corePropertyRegistry ) {
45
+	public function registerTo(CorePropertyRegistry $corePropertyRegistry) {
46 46
 
47 47
 		$propertyDefinitions = [
48 48
 
49 49
 			self::SCI_OLID => [
50 50
 				'label' => SCI_PROP_OLID,
51 51
 				'type'  => '_sci_olid',
52
-				'alias' => [ wfMessage( 'sci-property-alias-olid' )->text(), 'olid', 'Olid' ],
52
+				'alias' => [wfMessage('sci-property-alias-olid')->text(), 'olid', 'Olid'],
53 53
 				'visibility' => true,
54 54
 				'annotableByUser' => true
55 55
 			],
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			self::SCI_VIAF => [
58 58
 				'label' => SCI_PROP_VIAF,
59 59
 				'type'  => '_sci_viaf',
60
-				'alias' => [ wfMessage( 'sci-property-alias-viaf' )->text(), 'viaf', 'Viaf' ],
60
+				'alias' => [wfMessage('sci-property-alias-viaf')->text(), 'viaf', 'Viaf'],
61 61
 				'visibility' => true,
62 62
 				'annotableByUser' => true
63 63
 			],
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			self::SCI_OCLC => [
66 66
 				'label' => SCI_PROP_OCLC,
67 67
 				'type'  => '_sci_oclc',
68
-				'alias' => [ wfMessage( 'sci-property-alias-oclc' )->text(), 'oclc', 'Oclc' ],
68
+				'alias' => [wfMessage('sci-property-alias-oclc')->text(), 'oclc', 'Oclc'],
69 69
 				'visibility' => true,
70 70
 				'annotableByUser' => true
71 71
 			],
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 			self::SCI_DOI => [
74 74
 				'label' => SCI_PROP_DOI,
75 75
 				'type'  => '_sci_doi',
76
-				'alias' => [ wfMessage( 'sci-property-alias-doi' )->text(), 'Doi', 'doi' ],
76
+				'alias' => [wfMessage('sci-property-alias-doi')->text(), 'Doi', 'doi'],
77 77
 				'visibility' => true,
78 78
 				'annotableByUser' => true
79 79
 			],
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 			self::SCI_PMCID => [
82 82
 				'label' => SCI_PROP_PMCID,
83 83
 				'type'  => '_sci_pmcid',
84
-				'alias' => [ wfMessage( 'sci-property-alias-pmcid' )->text(), 'Pmcid', 'pmcid' ],
84
+				'alias' => [wfMessage('sci-property-alias-pmcid')->text(), 'Pmcid', 'pmcid'],
85 85
 				'visibility' => true,
86 86
 				'annotableByUser' => true
87 87
 			],
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 			self::SCI_PMID => [
90 90
 				'label' => SCI_PROP_PMID,
91 91
 				'type'  => '_sci_pmid',
92
-				'alias' => [ wfMessage( 'sci-property-alias-pmid' )->text(), 'Pmid', 'pmid' ],
92
+				'alias' => [wfMessage('sci-property-alias-pmid')->text(), 'Pmid', 'pmid'],
93 93
 				'visibility' => true,
94 94
 				'annotableByUser' => true
95 95
 			],
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			self::SCI_CITE_KEY => [
98 98
 				'label' => SCI_PROP_CITE_KEY,
99 99
 				'type'  => '_txt',
100
-				'alias' => [ wfMessage( 'sci-property-alias-citation-key' )->text() ],
100
+				'alias' => [wfMessage('sci-property-alias-citation-key')->text()],
101 101
 				'visibility' => true,
102 102
 				'annotableByUser' => true
103 103
 			],
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			self::SCI_CITE_REFERENCE => [
108 108
 				'label' => SCI_PROP_CITE_REFERENCE,
109 109
 				'type'  => '_sci_ref',
110
-				'alias' => [ wfMessage( 'sci-property-alias-citation-reference' )->text(), 'CiteRef' ],
110
+				'alias' => [wfMessage('sci-property-alias-citation-reference')->text(), 'CiteRef'],
111 111
 				'visibility' => true,
112 112
 				'annotableByUser' => true
113 113
 			],
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 			self::SCI_CITE_TEXT => [
116 116
 				'label' => SCI_PROP_CITE_TEXT,
117 117
 				'type'  => '_txt',
118
-				'alias' => [ wfMessage( 'sci-property-alias-citation-text' )->text() ],
118
+				'alias' => [wfMessage('sci-property-alias-citation-text')->text()],
119 119
 				'visibility' => true,
120 120
 				'annotableByUser' => true
121 121
 			],
@@ -123,20 +123,20 @@  discard block
 block discarded – undo
123 123
 			self::SCI_CITE => [
124 124
 				'label' => SCI_PROP_CITE,
125 125
 				'type'  => '__sob',
126
-				'alias' => [ wfMessage( 'sci-property-alias-citation-resource' )->text() ],
126
+				'alias' => [wfMessage('sci-property-alias-citation-resource')->text()],
127 127
 				'visibility' => true,
128 128
 				'annotableByUser' => false
129 129
 			]
130 130
 		];
131 131
 
132
-		foreach ( $propertyDefinitions as $propertyId => $definition ) {
133
-			$this->addPropertyDefinitionFor( $corePropertyRegistry, $propertyId, $definition  );
132
+		foreach ($propertyDefinitions as $propertyId => $definition) {
133
+			$this->addPropertyDefinitionFor($corePropertyRegistry, $propertyId, $definition);
134 134
 		}
135 135
 
136 136
 		return true;
137 137
 	}
138 138
 
139
-	private function addPropertyDefinitionFor( $corePropertyRegistry, $propertyId, $definition ) {
139
+	private function addPropertyDefinitionFor($corePropertyRegistry, $propertyId, $definition) {
140 140
 
141 141
 		$corePropertyRegistry->registerProperty(
142 142
 			$propertyId,
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			$definition['annotableByUser']
147 147
 		);
148 148
 
149
-		foreach ( $definition['alias'] as $alias ) {
149
+		foreach ($definition['alias'] as $alias) {
150 150
 			$corePropertyRegistry->registerPropertyAlias(
151 151
 				$propertyId,
152 152
 				$alias
Please login to merge, or discard this patch.