@@ -44,91 +44,91 @@ discard block |
||
44 | 44 | * (temporarily, pre-rendered strings are allowed and returned without changes) |
45 | 45 | * @return string |
46 | 46 | */ |
47 | - public function render( $violationMessage ) { |
|
48 | - if ( is_string( $violationMessage ) ) { |
|
47 | + public function render($violationMessage) { |
|
48 | + if (is_string($violationMessage)) { |
|
49 | 49 | // TODO remove this once all checkers produce ViolationMessage objects |
50 | 50 | return $violationMessage; |
51 | 51 | } |
52 | - $message = new Message( $violationMessage->getMessageKey() ); |
|
53 | - foreach ( $violationMessage->getArguments() as $argument ) { |
|
54 | - $this->renderArgument( $argument, $message ); |
|
52 | + $message = new Message($violationMessage->getMessageKey()); |
|
53 | + foreach ($violationMessage->getArguments() as $argument) { |
|
54 | + $this->renderArgument($argument, $message); |
|
55 | 55 | } |
56 | 56 | return $message->escaped(); |
57 | 57 | } |
58 | 58 | |
59 | - private function addRole( $value, $role ) { |
|
60 | - if ( $role === null ) { |
|
59 | + private function addRole($value, $role) { |
|
60 | + if ($role === null) { |
|
61 | 61 | return $value; |
62 | 62 | } |
63 | 63 | |
64 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' . |
|
65 | - $value . |
|
64 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'. |
|
65 | + $value. |
|
66 | 66 | '</span>'; |
67 | 67 | } |
68 | 68 | |
69 | - private function renderArgument( array $argument, Message $message ) { |
|
69 | + private function renderArgument(array $argument, Message $message) { |
|
70 | 70 | $type = $argument['type']; |
71 | 71 | $value = $argument['value']; |
72 | 72 | $role = $argument['role']; |
73 | - switch ( $type ) { |
|
73 | + switch ($type) { |
|
74 | 74 | case ViolationMessage::TYPE_ENTITY_ID: |
75 | - $params = $this->renderEntityId( $value, $role ); |
|
75 | + $params = $this->renderEntityId($value, $role); |
|
76 | 76 | break; |
77 | 77 | case ViolationMessage::TYPE_ENTITY_ID_LIST: |
78 | - $params = $this->renderEntityIdList( $value, $role ); |
|
78 | + $params = $this->renderEntityIdList($value, $role); |
|
79 | 79 | break; |
80 | 80 | case ViolationMessage::TYPE_ITEM_ID_SNAK_VALUE: |
81 | - $params = $this->renderItemIdSnakValue( $value, $role ); |
|
81 | + $params = $this->renderItemIdSnakValue($value, $role); |
|
82 | 82 | break; |
83 | 83 | default: |
84 | 84 | throw new InvalidArgumentException( |
85 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
85 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
86 | 86 | ); |
87 | 87 | } |
88 | - $message->params( $params ); |
|
88 | + $message->params($params); |
|
89 | 89 | } |
90 | 90 | |
91 | - private function renderEntityId( EntityId $entityId, $role ) { |
|
92 | - return Message::rawParam( $this->addRole( |
|
93 | - $this->entityIdFormatter->formatEntityId( $entityId ), |
|
91 | + private function renderEntityId(EntityId $entityId, $role) { |
|
92 | + return Message::rawParam($this->addRole( |
|
93 | + $this->entityIdFormatter->formatEntityId($entityId), |
|
94 | 94 | $role |
95 | - ) ); |
|
95 | + )); |
|
96 | 96 | } |
97 | 97 | |
98 | - private function renderEntityIdList( array $entityIdList, $role ) { |
|
99 | - if ( $entityIdList === [] ) { |
|
98 | + private function renderEntityIdList(array $entityIdList, $role) { |
|
99 | + if ($entityIdList === []) { |
|
100 | 100 | return [ |
101 | - Message::numParam( 0 ), |
|
102 | - Message::rawParam( '<ul></ul>' ), |
|
101 | + Message::numParam(0), |
|
102 | + Message::rawParam('<ul></ul>'), |
|
103 | 103 | ]; |
104 | 104 | } |
105 | 105 | |
106 | - if ( count( $entityIdList ) > $this->maxListLength ) { |
|
107 | - $entityIdList = array_slice( $entityIdList, 0, $this->maxListLength ); |
|
106 | + if (count($entityIdList) > $this->maxListLength) { |
|
107 | + $entityIdList = array_slice($entityIdList, 0, $this->maxListLength); |
|
108 | 108 | $truncated = true; |
109 | 109 | } |
110 | 110 | |
111 | 111 | $renderedParams = array_map( |
112 | - [ $this, 'renderEntityId' ], |
|
112 | + [$this, 'renderEntityId'], |
|
113 | 113 | $entityIdList, |
114 | - array_fill( 0, count( $entityIdList ), $role ) |
|
114 | + array_fill(0, count($entityIdList), $role) |
|
115 | 115 | ); |
116 | 116 | $renderedElements = array_map( |
117 | - function ( $param ) { |
|
117 | + function($param) { |
|
118 | 118 | return $param['raw']; |
119 | 119 | }, |
120 | 120 | $renderedParams |
121 | 121 | ); |
122 | - if ( isset( $truncated ) ) { |
|
123 | - $renderedElements[] = wfMessage( 'ellipsis' )->escaped(); |
|
122 | + if (isset($truncated)) { |
|
123 | + $renderedElements[] = wfMessage('ellipsis')->escaped(); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | return array_merge( |
127 | 127 | [ |
128 | - Message::numParam( count( $entityIdList ) ), |
|
128 | + Message::numParam(count($entityIdList)), |
|
129 | 129 | Message::rawParam( |
130 | - '<ul><li>' . |
|
131 | - implode( '</li><li>', $renderedElements ) . |
|
130 | + '<ul><li>'. |
|
131 | + implode('</li><li>', $renderedElements). |
|
132 | 132 | '</li></ul>' |
133 | 133 | ), |
134 | 134 | ], |
@@ -136,24 +136,24 @@ discard block |
||
136 | 136 | ); |
137 | 137 | } |
138 | 138 | |
139 | - private function renderItemIdSnakValue( ItemIdSnakValue $value, $role ) { |
|
140 | - switch ( true ) { |
|
139 | + private function renderItemIdSnakValue(ItemIdSnakValue $value, $role) { |
|
140 | + switch (true) { |
|
141 | 141 | case $value->isValue(): |
142 | - return $this->renderEntityId( $value->getItemId(), $role ); |
|
142 | + return $this->renderEntityId($value->getItemId(), $role); |
|
143 | 143 | case $value->isSomeValue(): |
144 | - return Message::rawParam( $this->addRole( |
|
145 | - '<span class="wikibase-snakview-variation-somevaluesnak">' . |
|
146 | - wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped() . |
|
144 | + return Message::rawParam($this->addRole( |
|
145 | + '<span class="wikibase-snakview-variation-somevaluesnak">'. |
|
146 | + wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped(). |
|
147 | 147 | '</span>', |
148 | 148 | $role |
149 | - ) ); |
|
149 | + )); |
|
150 | 150 | case $value->isNoValue(): |
151 | - return Message::rawParam( $this->addRole( |
|
152 | - '<span class="wikibase-snakview-variation-novaluesnak">' . |
|
153 | - wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped() . |
|
151 | + return Message::rawParam($this->addRole( |
|
152 | + '<span class="wikibase-snakview-variation-novaluesnak">'. |
|
153 | + wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped(). |
|
154 | 154 | '</span>', |
155 | 155 | $role |
156 | - ) ); |
|
156 | + )); |
|
157 | 157 | default: |
158 | 158 | // @codeCoverageIgnoreStart |
159 | 159 | throw new LogicException( |