@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | private const IF = "if"; |
34 | 34 | private const ELSE_IF = "elseif"; |
35 | - private const ELSE = "else"; |
|
35 | + private const ELSE { |
|
36 | + = "else"; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | private MapInterface $children; |
38 | 40 | |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | $elseIf->add(new ChooseElseIf($child, $this)); |
61 | 63 | break; |
62 | 64 | case 'else': |
63 | - $this->children->put(self::ELSE, new ChooseElse($child, $this)); |
|
65 | + $this->children->put(self::ELSE { |
|
66 | + , new ChooseElse($child, $this)); |
|
67 | + } |
|
64 | 68 | break; |
65 | 69 | } |
66 | 70 | } |
@@ -101,9 +105,11 @@ discard block |
||
101 | 105 | } |
102 | 106 | |
103 | 107 | // !$matchedIfs ensures that each previous condition has not been met |
104 | - if (!$matchedIfs && $this->children->containsKey(self::ELSE)) { //ELSE |
|
108 | + if (!$matchedIfs && $this->children->containsKey(self::ELSE { |
|
109 | + )) { //ELSE |
|
105 | 110 | $result->add($this->children->get(self::ELSE)->render($data)); |
106 | 111 | } |
112 | + } |
|
107 | 113 | return $result->joinToString(""); |
108 | 114 | } |
109 | 115 |
@@ -76,15 +76,14 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | if (CiteProc::getContext()->isModeBibliography()) { |
79 | - foreach ($data as $citationNumber => $item) { |
|
80 | - ++self::$numberOfCitedItems; |
|
79 | + foreach ($data as $citationNumber => $item) {++self::$numberOfCitedItems; |
|
81 | 80 | CiteProc::getContext()->getResults()->add( |
82 | 81 | $this->wrapBibEntry($item, $this->renderSingle($item, $citationNumber)) |
83 | 82 | ); |
84 | 83 | } |
85 | 84 | $ret .= implode($this->delimiter, CiteProc::getContext()->getResults()->toArray()); |
86 | 85 | $ret = StringHelper::clearApostrophes($ret); |
87 | - return "<div class=\"csl-bib-body\">".$ret."\n</div>"; |
|
86 | + return "<div class=\"csl-bib-body\">" . $ret . "\n</div>"; |
|
88 | 87 | } elseif (CiteProc::getContext()->isModeCitation()) { |
89 | 88 | if ($citationItems->isNotEmpty()) { //is there a filter for specific citations? |
90 | 89 | if ($this->isGroupedCitations($citationItems)) { //if citation items grouped? |
@@ -149,7 +148,7 @@ discard block |
||
149 | 148 | if (!empty($inMargin) && !empty($margin) && CiteProc::getContext()->isModeBibliography()) { |
150 | 149 | $leftMargin = $this->removeConsecutiveChars($this->htmlentities($this->format(implode("", $inMargin)))); |
151 | 150 | $rightInline = $this->removeConsecutiveChars( |
152 | - $this->htmlentities($this->format(implode("", $margin))). |
|
151 | + $this->htmlentities($this->format(implode("", $margin))) . |
|
153 | 152 | $this->suffix |
154 | 153 | ); |
155 | 154 | $res = '<div class="csl-left-margin">' . trim($leftMargin) . '</div>'; |
@@ -178,7 +177,7 @@ discard block |
||
178 | 177 | private function wrapBibEntry($dataItem, $value) |
179 | 178 | { |
180 | 179 | $value = $this->addAffixes($value); |
181 | - return "\n ". |
|
180 | + return "\n " . |
|
182 | 181 | "<div class=\"csl-entry\">" . |
183 | 182 | $renderedItem = CiteProcHelper::applyAdditionMarkupFunction($dataItem, "csl-entry", $value) . |
184 | 183 | "</div>"; |
@@ -217,7 +216,7 @@ discard block |
||
217 | 216 | $newDataList = new DataList(); |
218 | 217 | $newDataList->setArray($data |
219 | 218 | ->filter(fn ($dataItem) => $citationItems->containsValue($dataItem->id)) |
220 | - ->map(function ($dataItem) use ($citationItems) { |
|
219 | + ->map(function($dataItem) use ($citationItems) { |
|
221 | 220 | $dataItem->citationNumber = $citationItems |
222 | 221 | ->filter(fn ($_, $citationItem) => $citationItem === $dataItem->id) |
223 | 222 | ->getKeys() |
@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | $dp = $datePartsList->toArray(); |
27 | 27 | $dateParts_ = []; |
28 | - array_walk($dp, function (Pair $datePartPair) use (&$dateParts_) { |
|
28 | + array_walk($dp, function(Pair $datePartPair) use (&$dateParts_) { |
|
29 | 29 | $datePart = $datePartPair->getValue(); |
30 | 30 | $key = $datePartPair->getKey(); |
31 | 31 | if (strpos($key, "month") !== false || strpos($key, "day") !== false) { |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | public function parseDateRange(ListInterface $datePartsList, DateTime $from, DateTime $to, string $delimiter): string |
20 | 20 | { |
21 | - return $datePartsList->mapNotNull(function (Pair $pair) use ($from, $to, $delimiter) { |
|
21 | + return $datePartsList->mapNotNull(function(Pair $pair) use ($from, $to, $delimiter) { |
|
22 | 22 | $key = $pair->getKey(); |
23 | 23 | $datePart = $pair->getValue(); |
24 | 24 | if (strpos($key, "year") !== false) { |
@@ -22,7 +22,7 @@ |
||
22 | 22 | { |
23 | 23 | $map = mapOf(pair(self::YEAR, emptyMap()), pair(self::MONTH, null)); |
24 | 24 | $i = 0; |
25 | - $datePartsList->forEach(function (string $key, DatePart $datePart) use ($map, &$i) { |
|
25 | + $datePartsList->forEach(function(string $key, DatePart $datePart) use ($map, &$i) { |
|
26 | 26 | if (strpos($key, self::YEAR) !== false || strpos($key, self::DAY) !== false) { |
27 | 27 | $map[self::YEARDAY][$i++] = $datePart; |
28 | 28 | } |
@@ -103,7 +103,7 @@ |
||
103 | 103 | DateTime $to, |
104 | 104 | string $delimiter |
105 | 105 | ): string { |
106 | - return $dateParts->map(function (Pair $datePartPair) use ($from, $to, $delimiter) { |
|
106 | + return $dateParts->map(function(Pair $datePartPair) use ($from, $to, $delimiter) { |
|
107 | 107 | $datePart = $datePartPair->getValue(); |
108 | 108 | if ($datePart instanceof MapInterface || is_array($datePart)) { |
109 | 109 | $renderedFrom = $datePart[0]->render($from, $this->parentDateObject); |
@@ -26,7 +26,7 @@ |
||
26 | 26 | ): string { |
27 | 27 | $dp = $datePartsList->toArray(); |
28 | 28 | $dateParts = []; |
29 | - array_walk($dp, function (Pair $datePartPair) use (&$dateParts) { |
|
29 | + array_walk($dp, function(Pair $datePartPair) use (&$dateParts) { |
|
30 | 30 | $datePart = $datePartPair->getValue(); |
31 | 31 | $key = $datePartPair->getKey(); |
32 | 32 | if (strpos($key, "year") !== false || strpos($key, "month") !== false) { |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | if (isset($var->raw) && preg_match("/(\p{L}+)\s?([\-–&,])\s?(\p{L}+)/u", $var->raw, $matches)) { |
191 | - return $matches[1].$matches[2].$matches[3]; |
|
191 | + return $matches[1] . $matches[2] . $matches[3]; |
|
192 | 192 | } |
193 | 193 | } elseif (!empty($this->datePartsAttribute)) { |
194 | 194 | // fallback: |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | if (!empty($dateFromLocale)) { |
255 | 255 | $dateForm = array_filter( |
256 | 256 | is_array($dateFromLocale) ? $dateFromLocale : [$dateFromLocale], |
257 | - function ($element) use ($format) { |
|
257 | + function($element) use ($format) { |
|
258 | 258 | /** @var SimpleXMLElement $element */ |
259 | 259 | $dateForm = (string) $element->attributes()["form"]; |
260 | 260 | return $dateForm === $format; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | if ($this->dateParts->count() < 1 && in_array($form, self::$localizedDateFormats)) { |
317 | 317 | if ($this->hasDatePartsFromLocales($form)) { |
318 | 318 | $datePartsFromLocales = $this->getDatePartsFromLocales($form); |
319 | - array_filter($datePartsFromLocales, function (SimpleXMLElement $item) use ($dateParts) { |
|
319 | + array_filter($datePartsFromLocales, function(SimpleXMLElement $item) use ($dateParts) { |
|
320 | 320 | return $dateParts->contains($item["name"]); |
321 | 321 | }); |
322 | 322 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $this->dateParts->add( |
330 | 330 | "$form-$datePart", |
331 | 331 | new DatePart( |
332 | - new SimpleXMLElement('<date-part name="'.$datePart.'" form="'.$form.'" />') |
|
332 | + new SimpleXMLElement('<date-part name="' . $datePart . '" form="' . $form . '" />') |
|
333 | 333 | ) |
334 | 334 | ); |
335 | 335 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | { |
367 | 367 | $glue = $this->datePartsHaveAffixes() ? "" : " "; |
368 | 368 | $result = $this->dateParts |
369 | - ->filter(function (Pair $datePartPair) use ($dateParts) { |
|
369 | + ->filter(function(Pair $datePartPair) use ($dateParts) { |
|
370 | 370 | list($_, $p) = explode("-", $datePartPair->getKey()); |
371 | 371 | return $dateParts->contains($p); |
372 | 372 | }) |
@@ -44,7 +44,7 @@ |
||
44 | 44 | |
45 | 45 | public function __toString(): string |
46 | 46 | { |
47 | - $directives = "\t".implode("\n\t", $this->directives->toArray()); |
|
48 | - return $this->selectorType.$this->selector." {\n".$directives."\n}\n"; |
|
47 | + $directives = "\t" . implode("\n\t", $this->directives->toArray()); |
|
48 | + return $this->selectorType . $this->selector . " {\n" . $directives . "\n}\n"; |
|
49 | 49 | } |
50 | 50 | } |