@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | - * @param array|DataList $data |
|
| 118 | + * @param DataList $data |
|
| 119 | 119 | * @return string |
| 120 | 120 | */ |
| 121 | 121 | protected function bibliography($data) |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * @param array|DataList $data |
|
| 128 | + * @param DataList $data |
|
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | 131 | protected function citation($data) |
@@ -254,7 +254,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 430 | 431 | } |
| 431 | 432 | |
| 432 | 433 | /** |
| 434 | + * @param string $format |
|
| 433 | 435 | * @return array |
| 434 | 436 | */ |
| 435 | 437 | private function getDatePartsFromLocales($format) |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | if ($this->dateParts->count() < 1 && in_array($form, self::$localizedDateFormats)) { |
| 141 | 141 | if ($this->hasDatePartsFromLocales($form)) { |
| 142 | 142 | $datePartsFromLocales = $this->getDatePartsFromLocales($form); |
| 143 | - array_filter($datePartsFromLocales, function (\SimpleXMLElement $item) use ($dateParts) { |
|
| 143 | + array_filter($datePartsFromLocales, function(\SimpleXMLElement $item) use ($dateParts) { |
|
| 144 | 144 | return in_array($item["name"], $dateParts); |
| 145 | 145 | }); |
| 146 | 146 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $data = []; |
| 237 | 237 | foreach ($dates as $date) { |
| 238 | 238 | if ($date[0] < 1000) { |
| 239 | - $dateTime = new DateTime(0,0,0); |
|
| 239 | + $dateTime = new DateTime(0, 0, 0); |
|
| 240 | 240 | $dateTime->setDay(0)->setMonth(0)->setYear(0); |
| 241 | 241 | $data[] = $dateTime; |
| 242 | 242 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | $dp = $this->dateParts->toArray(); |
| 342 | 342 | $i = 0; |
| 343 | 343 | $dateParts_ = []; |
| 344 | - array_walk($dp, function ($datePart, $key) use (&$i, &$dateParts_, $differentParts) { |
|
| 344 | + array_walk($dp, function($datePart, $key) use (&$i, &$dateParts_, $differentParts) { |
|
| 345 | 345 | if (strpos($key, "year") !== false || strpos($key, "month") !== false) { |
| 346 | 346 | $dateParts_["yearmonth"][] = $datePart; |
| 347 | 347 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | $dp = $this->dateParts->toArray(); |
| 355 | 355 | $i = 0; |
| 356 | 356 | $dateParts_ = []; |
| 357 | - array_walk($dp, function ($datePart, $key) use (&$i, &$dateParts_, $differentParts) { |
|
| 357 | + array_walk($dp, function($datePart, $key) use (&$i, &$dateParts_, $differentParts) { |
|
| 358 | 358 | if (strpos($key, "year") !== false || strpos($key, "day") !== false) { |
| 359 | 359 | $dateParts_["yearday"][] = $datePart; |
| 360 | 360 | } |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $dp = $this->dateParts->toArray(); |
| 368 | 368 | $i = 0; |
| 369 | 369 | $dateParts_ = []; |
| 370 | - array_walk($dp, function ($datePart, $key) use (&$i, &$dateParts_, $differentParts) { |
|
| 370 | + array_walk($dp, function($datePart, $key) use (&$i, &$dateParts_, $differentParts) { |
|
| 371 | 371 | //$bit = sprintf("%03d", decbin($differentParts)); |
| 372 | 372 | if (strpos($key, "month") !== false || strpos($key, "day") !== false) { |
| 373 | 373 | $dateParts_["monthday"][] = $datePart; |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $from = $datePart->renderWithoutAffixes($from, $this); |
| 418 | 418 | $to = $datePart->renderWithoutAffixes($to, $this); |
| 419 | 419 | $suffix = !empty($to) ? $datePart->renderSuffix() : ""; |
| 420 | - return $prefix.$from.$delim.$to.$suffix; |
|
| 420 | + return $prefix . $from . $delim . $to . $suffix; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
@@ -442,9 +442,9 @@ discard block |
||
| 442 | 442 | // no custom date parts within the date element (this)? |
| 443 | 443 | if (!empty($dateFromLocale)) { |
| 444 | 444 | |
| 445 | - $dateForm = array_filter(is_array($dateFromLocale) ? $dateFromLocale : [$dateFromLocale], function ($element) use ($format) { |
|
| 445 | + $dateForm = array_filter(is_array($dateFromLocale) ? $dateFromLocale : [$dateFromLocale], function($element) use ($format) { |
|
| 446 | 446 | /** @var \SimpleXMLElement $element */ |
| 447 | - $dateForm = (string)$element->attributes()["form"]; |
|
| 447 | + $dateForm = (string) $element->attributes()["form"]; |
|
| 448 | 448 | return $dateForm === $format; |
| 449 | 449 | }); |
| 450 | 450 | |
@@ -105,6 +105,9 @@ discard block |
||
| 105 | 105 | $this->initDelimiterAttributes($node); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | + /** |
|
| 109 | + * @param integer|null $citationNumber |
|
| 110 | + */ |
|
| 108 | 111 | public function render($data, $citationNumber) |
| 109 | 112 | { |
| 110 | 113 | if (!$this->attributesInitialized) { |
@@ -266,7 +269,7 @@ discard block |
||
| 266 | 269 | } |
| 267 | 270 | |
| 268 | 271 | /** |
| 269 | - * @param $name |
|
| 272 | + * @param \stdClass $name |
|
| 270 | 273 | * @return string |
| 271 | 274 | */ |
| 272 | 275 | private function getNamesString($name, $rank) |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | $etAl = false; |
| 115 | 115 | $count = 0; |
| 116 | 116 | |
| 117 | - $hasPreceding = CiteProc::getContext()->getCitationItems()->hasKey($citationNumber-1); |
|
| 117 | + $hasPreceding = CiteProc::getContext()->getCitationItems()->hasKey($citationNumber - 1); |
|
| 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(); |
@@ -205,16 +205,16 @@ discard block |
||
| 205 | 205 | if (count($resultNames) === 1) { |
| 206 | 206 | $text .= " $etAl"; |
| 207 | 207 | } else { |
| 208 | - $text .= $this->delimiter . $etAl; |
|
| 208 | + $text .= $this->delimiter . $etAl; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | if ($this->form == 'count') { |
| 214 | 214 | if ($etAl === false) { |
| 215 | - return (int)count($resultNames); |
|
| 215 | + return (int) count($resultNames); |
|
| 216 | 216 | } else { |
| 217 | - return (int)(count($resultNames) - 1); |
|
| 217 | + return (int) (count($resultNames) - 1); |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | // strip out the last delimiter if not required |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | if (count($this->nameParts) > 0) { |
| 257 | 257 | /** @var NamePart $namePart */ |
| 258 | 258 | foreach ($this->nameParts as $namePart) { |
| 259 | - $nameObj->{$namePart->getName()} = $namePart->render($name); |
|
| 259 | + $nameObj->{$namePart->getName()} = $namePart->render($name); |
|
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | //remove last comma when no suffix exist. |
| 308 | 308 | $text = trim($text); |
| 309 | - $text = substr($text, -1) === "," ? substr($text, 0, strlen($text)-1) : $text; |
|
| 309 | + $text = substr($text, -1) === "," ? substr($text, 0, strlen($text) - 1) : $text; |
|
| 310 | 310 | break; |
| 311 | 311 | default: |
| 312 | 312 | /* |
@@ -146,8 +146,7 @@ |
||
| 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 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $parentStyleElement = null; |
| 198 | 198 | if ($this instanceof Name) { |
| 199 | 199 | $parentStyleElement = ($context->isModeBibliography() ? $context->getBibliography() : $context->getCitation()); |
| 200 | - } else if ($this instanceof StyleElement){ |
|
| 200 | + } else if ($this instanceof StyleElement) { |
|
| 201 | 201 | $parentStyleElement = $context->getRoot(); |
| 202 | 202 | } |
| 203 | 203 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | case 'and': |
| 208 | 208 | $and = ""; |
| 209 | 209 | if (!empty($attribute)) { |
| 210 | - $and = (string)$attribute; |
|
| 210 | + $and = (string) $attribute; |
|
| 211 | 211 | |
| 212 | 212 | } else if (!empty($parentStyleElement)) { //inherit from parent style |
| 213 | 213 | $and = $parentStyleElement->getAnd(); |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | break; |
| 221 | 221 | case 'delimiter-precedes-et-al': |
| 222 | 222 | if (!empty($attribute)) { |
| 223 | - $this->delimiterPrecedesEtAl = (string)$attribute; |
|
| 223 | + $this->delimiterPrecedesEtAl = (string) $attribute; |
|
| 224 | 224 | } else if (!empty($parentStyleElement)) { //inherit from parent style |
| 225 | 225 | $this->delimiterPrecedesEtAl = $parentStyleElement->getDelimiterPrecedesEtAl(); |
| 226 | 226 | } |
| 227 | 227 | break; |
| 228 | 228 | case 'delimiter-precedes-last': |
| 229 | 229 | if (!empty($attribute)) { |
| 230 | - $this->delimiterPrecedesLast = (string)$attribute; |
|
| 230 | + $this->delimiterPrecedesLast = (string) $attribute; |
|
| 231 | 231 | } else if (!empty($parentStyleElement)) { //inherit from parent style |
| 232 | 232 | $this->delimiterPrecedesLast = $parentStyleElement->getDelimiterPrecedesLast(); |
| 233 | 233 | } |
@@ -241,14 +241,14 @@ discard block |
||
| 241 | 241 | break; |
| 242 | 242 | case 'et-al-use-first': |
| 243 | 243 | if (!empty($attribute)) { |
| 244 | - $this->etAlUseFirst = intval((string)$attribute); |
|
| 244 | + $this->etAlUseFirst = intval((string) $attribute); |
|
| 245 | 245 | } else if (!empty($parentStyleElement)) { |
| 246 | 246 | $this->etAlUseFirst = $parentStyleElement->getEtAlUseFirst(); |
| 247 | 247 | } |
| 248 | 248 | break; |
| 249 | 249 | case 'et-al-subsequent-min': |
| 250 | 250 | if (!empty($attribute)) { |
| 251 | - $this->etAlSubsequentMin = intval((string)$attribute); |
|
| 251 | + $this->etAlSubsequentMin = intval((string) $attribute); |
|
| 252 | 252 | } else if (!empty($parentStyleElement)) { |
| 253 | 253 | $this->etAlSubsequentMin = $parentStyleElement->getEtAlSubsequentMin(); |
| 254 | 254 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | break; |
| 279 | 279 | case 'initialize-with': |
| 280 | 280 | if (!empty($attribute)) { |
| 281 | - $this->initializeWith = (string)$attribute; |
|
| 281 | + $this->initializeWith = (string) $attribute; |
|
| 282 | 282 | } else if (!empty($parentStyleElement)) { |
| 283 | 283 | $this->initializeWith = $parentStyleElement->getInitializeWith(); |
| 284 | 284 | } |
@@ -73,8 +73,7 @@ discard block |
||
| 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 |
||
| 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) { |
@@ -99,7 +99,7 @@ discard block |
||
| 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': |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | if (preg_match("/\s*(\d+)\s*[\-\-\&,]\s*(\d+)\s*/", $var, $matches)) { |
| 115 | 115 | $text = $this->buildNumberRangeString($matches[1], $matches[3], $matches[2]); |
| 116 | 116 | } else { |
| 117 | - $text = Util\Number::dec2roman($var); |
|
| 117 | + $text = Util\Number::dec2roman($var); |
|
| 118 | 118 | } |
| 119 | 119 | break; |
| 120 | 120 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $numRange = "$num1 " . 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; |
@@ -60,7 +60,7 @@ discard block |
||
| 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 |
||
| 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(); |