Completed
Push — master ( 1745e6...0c2269 )
by Sebastian
03:54
created
src/Seboettg/CiteProc/Rendering/Date/Date.php 2 patches
Doc Comments   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     }
255 255
 
256 256
     /**
257
-     * @param $differentParts
257
+     * @param integer $differentParts
258 258
      * @param DateTime $from
259 259
      * @param DateTime $to
260 260
      * @param $delim
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 
407 407
     /**
408 408
      * @param $datePart
409
-     * @param $from
410
-     * @param $to
409
+     * @param DateTime $from
410
+     * @param DateTime $to
411 411
      * @param $delim
412 412
      * @return string
413 413
      */
@@ -421,6 +421,7 @@  discard block
 block discarded – undo
421 421
     }
422 422
 
423 423
     /**
424
+     * @param string $format
424 425
      * @return bool
425 426
      */
426 427
     private function hasDatePartsFromLocales($format)
@@ -430,6 +431,7 @@  discard block
 block discarded – undo
430 431
     }
431 432
 
432 433
     /**
434
+     * @param string $format
433 435
      * @return array
434 436
      */
435 437
     private function getDatePartsFromLocales($format)
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         if ($this->dateParts->count() < 1 && in_array($form, self::$localizedDateFormats)) {
143 143
             if ($this->hasDatePartsFromLocales($form)) {
144 144
                 $datePartsFromLocales = $this->getDatePartsFromLocales($form);
145
-                array_filter($datePartsFromLocales, function (\SimpleXMLElement $item) use ($dateParts) {
145
+                array_filter($datePartsFromLocales, function(\SimpleXMLElement $item) use ($dateParts) {
146 146
                     return in_array($item["name"], $dateParts);
147 147
                 });
148 148
 
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
                 $ret = $this->renderDateRange($toRender, $from, $to, $delim);
213 213
             }
214 214
 
215
-            if (isset($var->raw) && preg_match("/(\p{L}+)\s?([\-\-\&,])\s?(\p{L}+)/u", $var->raw, $matches)){
216
-                return $matches[1].$matches[2].$matches[3];
215
+            if (isset($var->raw) && preg_match("/(\p{L}+)\s?([\-\-\&,])\s?(\p{L}+)/u", $var->raw, $matches)) {
216
+                return $matches[1] . $matches[2] . $matches[3];
217 217
             }
218 218
         }
219 219
         // fallback:
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         $data = [];
243 243
         foreach ($dates as $date) {
244 244
             if ($date[0] < 1000) {
245
-                $dateTime = new DateTime(0,0,0);
245
+                $dateTime = new DateTime(0, 0, 0);
246 246
                 $dateTime->setDay(0)->setMonth(0)->setYear(0);
247 247
                 $data[] = $dateTime;
248 248
             }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
                 $dp = $this->dateParts->toArray();
348 348
                 $i = 0;
349 349
                 $dateParts_ = [];
350
-                array_walk($dp, function ($datePart, $key) use (&$i, &$dateParts_, $differentParts) {
350
+                array_walk($dp, function($datePart, $key) use (&$i, &$dateParts_, $differentParts) {
351 351
                     if (strpos($key, "year") !== false || strpos($key, "month") !== false) {
352 352
                         $dateParts_["yearmonth"][] = $datePart;
353 353
                     }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                 $dp = $this->dateParts->toArray();
361 361
                 $i = 0;
362 362
                 $dateParts_ = [];
363
-                array_walk($dp, function ($datePart, $key) use (&$i, &$dateParts_, $differentParts) {
363
+                array_walk($dp, function($datePart, $key) use (&$i, &$dateParts_, $differentParts) {
364 364
                     if (strpos($key, "year") !== false || strpos($key, "day") !== false) {
365 365
                         $dateParts_["yearday"][] = $datePart;
366 366
                     }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
                 $dp = $this->dateParts->toArray();
374 374
                 $i = 0;
375 375
                 $dateParts_ = [];
376
-                array_walk($dp, function ($datePart, $key) use (&$i, &$dateParts_, $differentParts) {
376
+                array_walk($dp, function($datePart, $key) use (&$i, &$dateParts_, $differentParts) {
377 377
                     //$bit = sprintf("%03d", decbin($differentParts));
378 378
                     if (strpos($key, "month") !== false || strpos($key, "day") !== false) {
379 379
                         $dateParts_["monthday"][] = $datePart;
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         $from = $datePart->renderWithoutAffixes($from, $this);
424 424
         $to = $datePart->renderWithoutAffixes($to, $this);
425 425
         $suffix = !empty($to) ? $datePart->renderSuffix() : "";
426
-        return $prefix.$from.$delim.$to.$suffix;
426
+        return $prefix . $from . $delim . $to . $suffix;
427 427
     }
428 428
 
429 429
     /**
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
         // no custom date parts within the date element (this)?
449 449
         if (!empty($dateFromLocale)) {
450 450
 
451
-            $dateForm = array_filter(is_array($dateFromLocale) ? $dateFromLocale : [$dateFromLocale], function ($element) use ($format) {
451
+            $dateForm = array_filter(is_array($dateFromLocale) ? $dateFromLocale : [$dateFromLocale], function($element) use ($format) {
452 452
                 /** @var \SimpleXMLElement $element */
453
-                $dateForm = (string)$element->attributes()["form"];
453
+                $dateForm = (string) $element->attributes()["form"];
454 454
                 return $dateForm === $format;
455 455
             });
456 456
 
Please login to merge, or discard this patch.
src/Seboettg/CiteProc/Rendering/Layout.php 2 patches
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -73,8 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
         if (CiteProc::getContext()->isModeBibliography()) {
75 75
             if ($data instanceof DataList) {
76
-                foreach ($data as $citationNumber => $item) {
77
-                    ++self::$numberOfCitedItems;
76
+                foreach ($data as $citationNumber => $item) {++self::$numberOfCitedItems;
78 77
                     CiteProc::getContext()->getResults()->append($this->wrapBibEntry($this->renderSingle($item, $citationNumber)));
79 78
                 }
80 79
                 $ret .= implode($this->delimiter, CiteProc::getContext()->getResults()->toArray());
@@ -82,7 +81,7 @@  discard block
 block discarded – undo
82 81
                 $ret .= $this->wrapBibEntry($this->renderSingle($data, $citationNumber));
83 82
             }
84 83
 
85
-            return "<div class=\"csl-bib-body\">".$ret."\n</div>";
84
+            return "<div class=\"csl-bib-body\">" . $ret . "\n</div>";
86 85
 
87 86
         } else if (CiteProc::getContext()->isModeCitation()) {
88 87
             if (is_array($data) || $data instanceof DataList) {
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -127,6 +127,9 @@
 block discarded – undo
127 127
         return self::$numberOfCitedItems;
128 128
     }
129 129
 
130
+    /**
131
+     * @param string $value
132
+     */
130 133
     private function wrapBibEntry($value)
131 134
     {
132 135
         return "\n  <div class=\"csl-entry\">" . $value . "</div>";
Please login to merge, or discard this patch.
src/Seboettg/CiteProc/Rendering/Name/Name.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -146,8 +146,7 @@
 block discarded – undo
146 146
                         $resultNames[] = $this->formatName($name, $rank);
147 147
                     }
148 148
                 }
149
-            }
150
-            else {
149
+            } else {
151 150
                 $resultNames[] = $this->formatName($name, $rank);
152 151
             }
153 152
         }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -99,6 +99,9 @@
 block discarded – undo
99 99
         $this->initDelimiterAttributes($node);
100 100
     }
101 101
 
102
+    /**
103
+     * @param integer $citationNumber
104
+     */
102 105
     public function render($data, $citationNumber = null)
103 106
     {
104 107
         if (!$this->attributesInitialized) {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
         $lastName = null;
114 114
         $resultNames = [];
115 115
         $count = 0;
116
-        $hasPreceding = CiteProc::getContext()->getCitationItems()->hasKey($citationNumber-1);
116
+        $hasPreceding = CiteProc::getContext()->getCitationItems()->hasKey($citationNumber - 1);
117 117
 
118 118
         if ($hasPreceding) {
119 119
             /** @var \stdClass $preceding */
120
-            $preceding = CiteProc::getContext()->getCitationItems()->get($citationNumber-1);
120
+            $preceding = CiteProc::getContext()->getCitationItems()->get($citationNumber - 1);
121 121
         }
122 122
 
123 123
         $subsequentSubstitution = CiteProc::getContext()->getCitationItems()->getSubsequentAuthorSubstitute();
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         which allows for advanced sorting. */
216 216
 
217 217
         if ($this->form == 'count') {
218
-            return (int)count($resultNames);
218
+            return (int) count($resultNames);
219 219
         }
220 220
 
221 221
         return $text;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         if (count($this->nameParts) > 0) {
235 235
             /** @var NamePart $namePart */
236 236
             foreach ($this->nameParts as $namePart) {
237
-                $nameObj->{$namePart->getName()} =   $namePart->render($name);
237
+                $nameObj->{$namePart->getName()} = $namePart->render($name);
238 238
             }
239 239
         }
240 240
 
Please login to merge, or discard this patch.
src/Seboettg/CiteProc/Locale/LocaleXmlParserTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         /** @var \SimpleXMLElement $node */
62 62
         foreach ($locale as $node) {
63
-            switch($node->getName()) {
63
+            switch ($node->getName()) {
64 64
                 case 'style-options':
65 65
                     $this->optionsXml->add('options', $node);
66 66
                     foreach ($node->attributes() as $name => $value) {
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                     }
109 109
                     break;
110 110
                 case 'date':
111
-                    $form = (string)$node["form"];
111
+                    $form = (string) $node["form"];
112 112
                     $this->dateXml->add($form, $node);
113 113
                     foreach ($node->children() as $child) {
114 114
                         $date = new \stdClass();
Please login to merge, or discard this patch.
src/Seboettg/CiteProc/Style/InheritableNameAttributesTrait.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $parentStyleElement = null;
215 215
         if ($this instanceof  Name) {
216 216
             $parentStyleElement = ($context->isModeBibliography() ? $context->getBibliography() : $context->getCitation());
217
-        } else if ($this instanceof StyleElement){
217
+        } else if ($this instanceof StyleElement) {
218 218
             $parentStyleElement = $context->getRoot();
219 219
         }
220 220
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
             switch ($nameAttribute) {
224 224
                 case 'and':
225 225
                     if (!empty($attribute)) {
226
-                        $this->and = (string)$attribute;
226
+                        $this->and = (string) $attribute;
227 227
 
228 228
                     } else if (!empty($parentStyleElement)) { //inherit from parent style
229 229
                         $this->and = $parentStyleElement->getAnd();
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
                     break;
232 232
                 case 'delimiter-precedes-et-al':
233 233
                     if (!empty($attribute)) {
234
-                        $this->delimiterPrecedesEtAl = (string)$attribute;
234
+                        $this->delimiterPrecedesEtAl = (string) $attribute;
235 235
                     } else if (!empty($parentStyleElement)) { //inherit from parent style
236 236
                         $this->delimiterPrecedesEtAl = $parentStyleElement->getDelimiterPrecedesEtAl();
237 237
                     }
238 238
                     break;
239 239
                 case 'delimiter-precedes-last':
240 240
                     if (!empty($attribute)) {
241
-                        $this->delimiterPrecedesLast = (string)$attribute;
241
+                        $this->delimiterPrecedesLast = (string) $attribute;
242 242
                     } else if (!empty($parentStyleElement)) { //inherit from parent style
243 243
                         $this->delimiterPrecedesLast = $parentStyleElement->getDelimiterPrecedesLast();
244 244
                     }
@@ -252,14 +252,14 @@  discard block
 block discarded – undo
252 252
                     break;
253 253
                 case 'et-al-use-first':
254 254
                     if (!empty($attribute)) {
255
-                        $this->etAlUseFirst = intval((string)$attribute);
255
+                        $this->etAlUseFirst = intval((string) $attribute);
256 256
                     } else if (!empty($parentStyleElement)) {
257 257
                         $this->etAlUseFirst = $parentStyleElement->getEtAlUseFirst();
258 258
                     }
259 259
                     break;
260 260
                 case 'et-al-subsequent-min':
261 261
                     if (!empty($attribute)) {
262
-                        $this->etAlSubsequentMin = intval((string)$attribute);
262
+                        $this->etAlSubsequentMin = intval((string) $attribute);
263 263
                     } else if (!empty($parentStyleElement)) {
264 264
                         $this->etAlSubsequentMin = $parentStyleElement->getEtAlSubsequentMin();
265 265
                     }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                     break;
290 290
                 case 'initialize-with':
291 291
                     if (!empty($attribute)) {
292
-                        $this->initializeWith = (string)$attribute;
292
+                        $this->initializeWith = (string) $attribute;
293 293
                     } else if (!empty($parentStyleElement)) {
294 294
                         $this->initializeWith = $parentStyleElement->getInitializeWith();
295 295
                     }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
                 case 'name-form':
312 312
                     if ($this instanceof Root || $this instanceof StyleElement) {
313 313
                         if (!empty($attribute)) {
314
-                            $this->nameForm = (string)$attribute;
314
+                            $this->nameForm = (string) $attribute;
315 315
                         } else if (!empty($parentStyleElement)) {
316 316
                             $this->nameForm = $parentStyleElement->getNameForm();
317 317
                         }
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
                 case 'form':
321 321
                     if ($this instanceof Name) {
322 322
                         if (!empty($attribute)) {
323
-                            $this->form = (string)$attribute;
323
+                            $this->form = (string) $attribute;
324 324
                         } else if (!empty($parentStyleElement)) {
325 325
                             $this->form = $parentStyleElement->getNameForm();
326 326
                         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                 case 'name-delimiter':
330 330
                     if ($this instanceof Root || $this instanceof StyleElement) {
331 331
                         if (!empty($attribute)) {
332
-                            $this->nameDelimiter = (string)$attribute;
332
+                            $this->nameDelimiter = (string) $attribute;
333 333
                         } else if (!empty($parentStyleElement)) {
334 334
                             $this->nameDelimiter = $parentStyleElement->getNameDelimiter();
335 335
                         }
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                 case 'delimiter':
339 339
                     if ($this instanceof Name) {
340 340
                         if (!empty($attribute)) {
341
-                            $this->delimiter = (string)$attribute;
341
+                            $this->delimiter = (string) $attribute;
342 342
                         } else if (!empty($parentStyleElement)) {
343 343
                             $this->delimiter = $parentStyleElement->getNameDelimiter();
344 344
                         }
Please login to merge, or discard this patch.
src/Seboettg/CiteProc/Util/StringHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $wordArray = explode(" ", $text);
66 66
 
67
-        array_walk($wordArray, function (&$word) {
67
+        array_walk($wordArray, function(&$word) {
68 68
             $word = ucfirst($word);
69 69
         });
70 70
 
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
     public static function capitalizeForTitle($titleString)
75 75
     {
76 76
         if (preg_match('/(.+[^\<\>][\.:\/;\?\!]\s?)([a-z])(.+)/', $titleString, $match)) {
77
-            $titleString = $match[1].StringHelper::mb_ucfirst($match[2]).$match[3];
77
+            $titleString = $match[1] . StringHelper::mb_ucfirst($match[2]) . $match[3];
78 78
         }
79 79
 
80 80
         $wordArray = explode(" ", $titleString);
81 81
 
82
-        array_walk($wordArray, function (&$word) {
82
+        array_walk($wordArray, function(&$word) {
83 83
 
84 84
             $words = explode("-", $word);
85 85
             if (count($words) > 1) {
86
-                array_walk($words, function (&$w) {
86
+                array_walk($words, function(&$w) {
87 87
                     $w = StringHelper::keepLowerCase($w) ? $w : StringHelper::mb_ucfirst($w);
88 88
                 });
89 89
                 $word = implode("-", $words);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
     public static function keepLowerCase($word)
98 98
     {
99
-        $lowerCase =  in_array($word, self::PREPOSITIONS) ||
99
+        $lowerCase = in_array($word, self::PREPOSITIONS) ||
100 100
             in_array($word, self::ARTICLES) ||
101 101
             in_array($word, self::CONJUNCTIONS) ||
102 102
             in_array($word, self::ADJECTIVES);
Please login to merge, or discard this patch.
src/Seboettg/CiteProc/Rendering/Name/Names.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         /** @var \SimpleXMLElement $attribute */
128 128
         foreach ($node->attributes() as $attribute) {
129 129
             if ("variable" === $attribute->getName()) {
130
-                $this->variables = new ArrayList(explode(" ", (string)$attribute));
130
+                $this->variables = new ArrayList(explode(" ", (string) $attribute));
131 131
                 break;
132 132
             }
133 133
         }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                     $str .= $this->label->render("");
175 175
                 }
176 176
                 $vars = $this->variables->toArray();
177
-                $vars = array_filter($vars, function ($value) {
177
+                $vars = array_filter($vars, function($value) {
178 178
                     return !($value === "editor" || $value === "translator");
179 179
                 });
180 180
                 $this->variables->setArray($vars);
Please login to merge, or discard this patch.
src/Seboettg/CiteProc/Rendering/Number.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                     $num2 = Util\Number::dec2roman($matches[3]);
100 100
                     $text = $this->buildNumberRangeString($num1, $num2, $matches[2]);
101 101
                 } else {
102
-                    $text =  Util\Number::dec2roman($var);
102
+                    $text = Util\Number::dec2roman($var);
103 103
                 }
104 104
                 break;
105 105
             case 'numeric':
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $numRange = "$num1 " . htmlentities(self::RANGE_DELIMITER_AMPERSAND) . " $num2";
159 159
         } else if (self::RANGE_DELIMITER_COMMA === $delim) {
160 160
             $numRange = $num1 . htmlentities(self::RANGE_DELIMITER_COMMA) . " $num2";
161
-        } else  {
161
+        } else {
162 162
             $numRange = $num1 . self::RANGE_DELIMITER_HYPHEN . $num2;
163 163
         }
164 164
         return $numRange;
Please login to merge, or discard this patch.
src/Seboettg/CiteProc/Rendering/Choose/ChooseIf.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
 
48 48
         foreach ($node->attributes() as $name => $value) {
49 49
             if ('match' !== $name) {
50
-                $this->constraints->append(Factory::createConstraint((string)$name, (string)$value));
50
+                $this->constraints->append(Factory::createConstraint((string) $name, (string) $value));
51 51
             }
52 52
         }
53 53
 
Please login to merge, or discard this patch.