Passed
Pull Request — master (#70)
by Mauro
03:48
created
src/XliffParser/XliffParserFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
      *
13 13
      * @return AbstractXliffParser
14 14
      */
15
-    public static function getInstance( $xliffVersion, $xliffProprietary = null, LoggerInterface $logger = null ) {
15
+    public static function getInstance($xliffVersion, $xliffProprietary = null, LoggerInterface $logger = null) {
16 16
         $parserClass = 'Matecat\\XliffParser\\XliffParser\\XliffParserV' . $xliffVersion;
17 17
 
18 18
         /** @var AbstractXliffParser $parser */
19
-        return new $parserClass( $xliffVersion, $xliffProprietary, $logger );
19
+        return new $parserClass($xliffVersion, $xliffProprietary, $logger);
20 20
     }
21 21
 }
Please login to merge, or discard this patch.
src/XliffParser/XliffParserV1.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
      * @inheritDoc
17 17
      * @throws Exception
18 18
      */
19
-    public function parse( DOMDocument $dom, $output = [] ) {
19
+    public function parse(DOMDocument $dom, $output = []) {
20 20
         $i = 1;
21 21
         /** @var DOMElement $file */
22
-        foreach ( $dom->getElementsByTagName( 'file' ) as $file ) {
22
+        foreach ($dom->getElementsByTagName('file') as $file) {
23 23
 
24 24
             // metadata
25
-            $output[ 'files' ][ $i ][ 'attr' ] = $this->extractMetadata( $file );
25
+            $output['files'][$i]['attr'] = $this->extractMetadata($file);
26 26
 
27 27
             // reference
28
-            if ( !empty( $this->extractReference( $file ) ) ) {
29
-                $output[ 'files' ][ $i ][ 'reference' ] = $this->extractReference( $file );
28
+            if (!empty($this->extractReference($file))) {
29
+                $output['files'][$i]['reference'] = $this->extractReference($file);
30 30
             }
31 31
 
32 32
             // trans-units
33 33
             $transUnitIdArrayForUniquenessCheck = [];
34 34
             $j                                  = 1;
35
-            foreach ( $file->childNodes as $body ) {
36
-                if ( $body->nodeName === 'body' ) {
37
-                    foreach ( $body->childNodes as $childNode ) {
38
-                        $this->extractTuFromNode( $childNode, $transUnitIdArrayForUniquenessCheck, $dom, $output, $i, $j );
35
+            foreach ($file->childNodes as $body) {
36
+                if ($body->nodeName === 'body') {
37
+                    foreach ($body->childNodes as $childNode) {
38
+                        $this->extractTuFromNode($childNode, $transUnitIdArrayForUniquenessCheck, $dom, $output, $i, $j);
39 39
                     }
40 40
 
41 41
                     // trans-unit re-count check
42
-                    $totalTransUnitsId  = count( $transUnitIdArrayForUniquenessCheck );
43
-                    $transUnitsUniqueId = count( array_unique( $transUnitIdArrayForUniquenessCheck ) );
44
-                    if ( $totalTransUnitsId != $transUnitsUniqueId ) {
45
-                        throw new DuplicateTransUnitIdInXliff( "Invalid trans-unit id, duplicate found.", 400 );
42
+                    $totalTransUnitsId  = count($transUnitIdArrayForUniquenessCheck);
43
+                    $transUnitsUniqueId = count(array_unique($transUnitIdArrayForUniquenessCheck));
44
+                    if ($totalTransUnitsId != $transUnitsUniqueId) {
45
+                        throw new DuplicateTransUnitIdInXliff("Invalid trans-unit id, duplicate found.", 400);
46 46
                     }
47 47
 
48 48
                     $i++;
@@ -58,50 +58,50 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @return array
60 60
      */
61
-    private function extractMetadata( DOMElement $file ) {
61
+    private function extractMetadata(DOMElement $file) {
62 62
         $metadata   = [];
63 63
         $customAttr = [];
64 64
 
65 65
         /** @var DOMAttr $attribute */
66
-        foreach ( $file->attributes as $attribute ) {
67
-            switch ( $attribute->localName ) {
66
+        foreach ($file->attributes as $attribute) {
67
+            switch ($attribute->localName) {
68 68
                 // original
69 69
                 case 'original':
70
-                    $metadata[ 'original' ] = $attribute->value;
70
+                    $metadata['original'] = $attribute->value;
71 71
                     break;
72 72
 
73 73
                 // source-language
74 74
                 case 'source-language':
75
-                    $metadata[ 'source-language' ] = $attribute->value;
75
+                    $metadata['source-language'] = $attribute->value;
76 76
                     break;
77 77
 
78 78
                 // data-type
79 79
                 case 'datatype':
80
-                    $metadata[ 'data-type' ] = $attribute->value;
80
+                    $metadata['data-type'] = $attribute->value;
81 81
                     break;
82 82
 
83 83
                 // target-language
84 84
                 case 'target-language':
85
-                    $metadata[ 'target-language' ] = $attribute->value;
85
+                    $metadata['target-language'] = $attribute->value;
86 86
                     break;
87 87
             }
88 88
 
89 89
             // Custom MateCat x-Attribute
90
-            preg_match( '|x-(.*?)|si', $attribute->localName, $temp );
91
-            if ( isset( $temp[ 1 ] ) ) {
92
-                $customAttr[ $attribute->localName ] = $attribute->value;
90
+            preg_match('|x-(.*?)|si', $attribute->localName, $temp);
91
+            if (isset($temp[1])) {
92
+                $customAttr[$attribute->localName] = $attribute->value;
93 93
             }
94
-            unset( $temp );
94
+            unset($temp);
95 95
 
96 96
             // Custom MateCat namespace Attribute mtc:
97
-            preg_match( '|mtc:(.*?)|si', $attribute->nodeName, $temp );
98
-            if ( isset( $temp[ 1 ] ) ) {
99
-                $customAttr[ $attribute->nodeName ] = $attribute->value;
97
+            preg_match('|mtc:(.*?)|si', $attribute->nodeName, $temp);
98
+            if (isset($temp[1])) {
99
+                $customAttr[$attribute->nodeName] = $attribute->value;
100 100
             }
101
-            unset( $temp );
101
+            unset($temp);
102 102
 
103
-            if ( !empty( $customAttr ) ) {
104
-                $metadata[ 'custom' ] = $customAttr;
103
+            if (!empty($customAttr)) {
104
+                $metadata['custom'] = $customAttr;
105 105
             }
106 106
         }
107 107
 
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @return array
115 115
      */
116
-    private function extractReference( DOMElement $file ) {
116
+    private function extractReference(DOMElement $file) {
117 117
         $reference = [];
118 118
 
119 119
         $order = 0;
120
-        foreach ( $file->getElementsByTagName( 'reference' ) as $ref ) {
120
+        foreach ($file->getElementsByTagName('reference') as $ref) {
121 121
             /** @var DOMNode $childNode */
122
-            foreach ( $ref->childNodes as $childNode ) {
123
-                if ( $childNode->nodeName === 'internal-file' ) {
124
-                    $reference[ $order ][ 'form-type' ] = $childNode->attributes->getNamedItem( 'form' )->nodeValue;
125
-                    $reference[ $order ][ 'base64' ]    = trim( $childNode->nodeValue );
122
+            foreach ($ref->childNodes as $childNode) {
123
+                if ($childNode->nodeName === 'internal-file') {
124
+                    $reference[$order]['form-type'] = $childNode->attributes->getNamedItem('form')->nodeValue;
125
+                    $reference[$order]['base64']    = trim($childNode->nodeValue);
126 126
                     $order++;
127 127
                 }
128 128
             }
@@ -143,53 +143,53 @@  discard block
 block discarded – undo
143 143
      *
144 144
      * @throws Exception
145 145
      */
146
-    protected function extractTransUnit( $transUnit, &$transUnitIdArrayForUniquenessCheck, $dom, &$output, &$i, &$j ) {
146
+    protected function extractTransUnit($transUnit, &$transUnitIdArrayForUniquenessCheck, $dom, &$output, &$i, &$j) {
147 147
         // metadata
148
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'attr' ] = $this->extractTransUnitMetadata( $transUnit, $transUnitIdArrayForUniquenessCheck );
148
+        $output['files'][$i]['trans-units'][$j]['attr'] = $this->extractTransUnitMetadata($transUnit, $transUnitIdArrayForUniquenessCheck);
149 149
 
150 150
         // notes
151
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'notes' ] = $this->extractTransUnitNotes( $dom, $transUnit );
151
+        $output['files'][$i]['trans-units'][$j]['notes'] = $this->extractTransUnitNotes($dom, $transUnit);
152 152
 
153 153
         // content
154 154
         /** @var DOMElement $childNode */
155
-        foreach ( $transUnit->childNodes as $childNode ) {
155
+        foreach ($transUnit->childNodes as $childNode) {
156 156
             // source
157
-            if ( $childNode->nodeName === 'source' ) {
158
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'source' ] = $this->extractContent( $dom, $childNode );
157
+            if ($childNode->nodeName === 'source') {
158
+                $output['files'][$i]['trans-units'][$j]['source'] = $this->extractContent($dom, $childNode);
159 159
             }
160 160
 
161 161
             // seg-source
162
-            if ( $childNode->nodeName === 'seg-source' ) {
163
-                $rawSegment                                                     = $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'source' ][ 'raw-content' ];
164
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'seg-source' ] = $this->extractContentWithMarksAndExtTags( $dom, $childNode, $rawSegment );
162
+            if ($childNode->nodeName === 'seg-source') {
163
+                $rawSegment                                                     = $output['files'][$i]['trans-units'][$j]['source']['raw-content'];
164
+                $output['files'][$i]['trans-units'][$j]['seg-source'] = $this->extractContentWithMarksAndExtTags($dom, $childNode, $rawSegment);
165 165
             }
166 166
 
167 167
             // target
168
-            if ( $childNode->nodeName === 'target' ) {
169
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'target' ] = $this->extractContent( $dom, $childNode );
168
+            if ($childNode->nodeName === 'target') {
169
+                $output['files'][$i]['trans-units'][$j]['target'] = $this->extractContent($dom, $childNode);
170 170
 
171 171
                 // seg-target
172
-                $targetRawContent = @$output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'target' ][ 'raw-content' ];
173
-                $segSource        = @$output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'seg-source' ];
174
-                if ( isset( $targetRawContent ) && !empty( $targetRawContent ) && isset( $segSource ) && count( $segSource ) > 0 ) {
175
-                    $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'seg-target' ] = $this->extractContentWithMarksAndExtTags( $dom, $childNode, $targetRawContent );
172
+                $targetRawContent = @$output['files'][$i]['trans-units'][$j]['target']['raw-content'];
173
+                $segSource        = @$output['files'][$i]['trans-units'][$j]['seg-source'];
174
+                if (isset($targetRawContent) && !empty($targetRawContent) && isset($segSource) && count($segSource) > 0) {
175
+                    $output['files'][$i]['trans-units'][$j]['seg-target'] = $this->extractContentWithMarksAndExtTags($dom, $childNode, $targetRawContent);
176 176
                 }
177 177
             }
178 178
 
179 179
             // locked
180
-            if ( $childNode->nodeName === 'sdl:seg' ) {
181
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'locked' ] = $this->extractLocked( $childNode );
180
+            if ($childNode->nodeName === 'sdl:seg') {
181
+                $output['files'][$i]['trans-units'][$j]['locked'] = $this->extractLocked($childNode);
182 182
             }
183 183
         }
184 184
 
185 185
         // context-group
186
-        foreach ( $transUnit->getElementsByTagName( 'context-group' ) as $contextGroup ) {
187
-            $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'context-group' ][] = $this->extractTransUnitContextGroup( $dom, $contextGroup );
186
+        foreach ($transUnit->getElementsByTagName('context-group') as $contextGroup) {
187
+            $output['files'][$i]['trans-units'][$j]['context-group'][] = $this->extractTransUnitContextGroup($dom, $contextGroup);
188 188
         }
189 189
 
190 190
         // alt-trans
191
-        foreach ( $transUnit->getElementsByTagName( 'alt-trans' ) as $altTrans ) {
192
-            $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'alt-trans' ][] = $this->extractTransUnitAltTrans( $altTrans );
191
+        foreach ($transUnit->getElementsByTagName('alt-trans') as $altTrans) {
192
+            $output['files'][$i]['trans-units'][$j]['alt-trans'][] = $this->extractTransUnitAltTrans($altTrans);
193 193
         }
194 194
 
195 195
         $j++;
@@ -202,41 +202,41 @@  discard block
 block discarded – undo
202 202
      * @return array
203 203
      * @throws Exception
204 204
      */
205
-    private function extractTransUnitMetadata( DOMElement $transUnit, array &$transUnitIdArrayForUniquenessCheck ) {
205
+    private function extractTransUnitMetadata(DOMElement $transUnit, array &$transUnitIdArrayForUniquenessCheck) {
206 206
         $metadata = [];
207 207
 
208 208
         // id MUST NOT be null
209
-        if ( null === $transUnit->attributes->getNamedItem( 'id' ) ) {
210
-            throw new NotFoundIdInTransUnit( 'Invalid trans-unit id found. EMPTY value', 400 );
209
+        if (null === $transUnit->attributes->getNamedItem('id')) {
210
+            throw new NotFoundIdInTransUnit('Invalid trans-unit id found. EMPTY value', 400);
211 211
         }
212 212
 
213 213
         /**
214 214
          * @var DOMAttr $element
215 215
          */
216
-        foreach ( $transUnit->attributes as $element ) {
216
+        foreach ($transUnit->attributes as $element) {
217 217
 
218
-            if ( $element->nodeName === "id" ) {
218
+            if ($element->nodeName === "id") {
219 219
 
220 220
                 $id = $element->nodeValue;
221 221
 
222
-                if ( strlen( $id ) > 100 ) {
223
-                    throw new SegmentIdTooLongException( 'Segment-id too long. Max 100 characters allowed', 400 );
222
+                if (strlen($id) > 100) {
223
+                    throw new SegmentIdTooLongException('Segment-id too long. Max 100 characters allowed', 400);
224 224
                 }
225 225
 
226 226
                 $transUnitIdArrayForUniquenessCheck[] = $id;
227
-                $metadata[ 'id' ]                     = $id;
227
+                $metadata['id']                     = $id;
228 228
 
229
-            } elseif ( $element->nodeName === "approved" ) {
229
+            } elseif ($element->nodeName === "approved") {
230 230
                 // approved as BOOLEAN
231 231
                 // http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#approved
232
-                $metadata[ $element->nodeName ] = filter_var( $element->nodeValue, FILTER_VALIDATE_BOOLEAN );
233
-            } elseif ( $element->nodeName === "maxwidth" ) {
232
+                $metadata[$element->nodeName] = filter_var($element->nodeValue, FILTER_VALIDATE_BOOLEAN);
233
+            } elseif ($element->nodeName === "maxwidth") {
234 234
                 // we ignore ( but we get ) the attribute size-unit="char" assuming that a restriction is everytime done by character
235 235
                 // we duplicate the info to allow Xliff V1 and V2 to work the same
236
-                $metadata[ 'sizeRestriction' ]  = filter_var( $element->nodeValue, FILTER_SANITIZE_NUMBER_INT );
237
-                $metadata[ $element->nodeName ] = filter_var( $element->nodeValue, FILTER_SANITIZE_NUMBER_INT );
236
+                $metadata['sizeRestriction']  = filter_var($element->nodeValue, FILTER_SANITIZE_NUMBER_INT);
237
+                $metadata[$element->nodeName] = filter_var($element->nodeValue, FILTER_SANITIZE_NUMBER_INT);
238 238
             } else {
239
-                $metadata[ $element->nodeName ] = $element->nodeValue;
239
+                $metadata[$element->nodeName] = $element->nodeValue;
240 240
             }
241 241
 
242 242
         }
@@ -250,19 +250,19 @@  discard block
 block discarded – undo
250 250
      * @return array
251 251
      * @throws Exception
252 252
      */
253
-    private function extractTransUnitNotes( DOMDocument $dom, DOMElement $transUnit ) {
253
+    private function extractTransUnitNotes(DOMDocument $dom, DOMElement $transUnit) {
254 254
         $notes = [];
255
-        foreach ( $transUnit->getElementsByTagName( 'note' ) as $note ) {
255
+        foreach ($transUnit->getElementsByTagName('note') as $note) {
256 256
 
257
-            $noteValue = $this->extractTagContent( $dom, $note );
257
+            $noteValue = $this->extractTagContent($dom, $note);
258 258
 
259
-            if ( '' !== $noteValue ) {
259
+            if ('' !== $noteValue) {
260 260
 
261
-                $extractedNote = $this->JSONOrRawContentArray( $noteValue );
261
+                $extractedNote = $this->JSONOrRawContentArray($noteValue);
262 262
 
263 263
                 // extract all the attributes
264
-                foreach ( $note->attributes as $attribute ) {
265
-                    $extractedNote[ $attribute->name ] = $attribute->value;
264
+                foreach ($note->attributes as $attribute) {
265
+                    $extractedNote[$attribute->name] = $attribute->value;
266 266
                 }
267 267
 
268 268
                 $notes[] = $extractedNote;
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
      *
278 278
      * @return array
279 279
      */
280
-    private function extractTransUnitContextGroup( DOMDocument $dom, DOMElement $contextGroup ) {
280
+    private function extractTransUnitContextGroup(DOMDocument $dom, DOMElement $contextGroup) {
281 281
         $cg           = [];
282
-        $cg[ 'attr' ] = $this->extractTagAttributes( $contextGroup );
282
+        $cg['attr'] = $this->extractTagAttributes($contextGroup);
283 283
 
284 284
         /** @var DOMNode $context */
285
-        foreach ( $contextGroup->childNodes as $context ) {
286
-            if ( $context->nodeName === 'context' ) {
287
-                $cg[ 'contexts' ][] = $this->extractContent( $dom, $context );
285
+        foreach ($contextGroup->childNodes as $context) {
286
+            if ($context->nodeName === 'context') {
287
+                $cg['contexts'][] = $this->extractContent($dom, $context);
288 288
             }
289 289
         }
290 290
 
@@ -296,16 +296,16 @@  discard block
 block discarded – undo
296 296
      *
297 297
      * @return array
298 298
      */
299
-    private function extractTransUnitAltTrans( DOMElement $altTrans ) {
299
+    private function extractTransUnitAltTrans(DOMElement $altTrans) {
300 300
         $at           = [];
301
-        $at[ 'attr' ] = $this->extractTagAttributes( $altTrans );
301
+        $at['attr'] = $this->extractTagAttributes($altTrans);
302 302
 
303
-        if ( $altTrans->getElementsByTagName( 'source' )->length > 0 ) {
304
-            $at[ 'source' ] = $altTrans->getElementsByTagName( 'source' )->item( 0 )->nodeValue;
303
+        if ($altTrans->getElementsByTagName('source')->length > 0) {
304
+            $at['source'] = $altTrans->getElementsByTagName('source')->item(0)->nodeValue;
305 305
         }
306 306
 
307
-        if ( $altTrans->getElementsByTagName( 'target' ) ) {
308
-            $at[ 'target' ] = $altTrans->getElementsByTagName( 'target' )->item( 0 )->nodeValue;
307
+        if ($altTrans->getElementsByTagName('target')) {
308
+            $at['target'] = $altTrans->getElementsByTagName('target')->item(0)->nodeValue;
309 309
         }
310 310
 
311 311
         return $at;
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      *
317 317
      * @return bool
318 318
      */
319
-    private function extractLocked( DOMElement $locked ) {
320
-        return null !== $locked->getAttribute( 'locked' );
319
+    private function extractLocked(DOMElement $locked) {
320
+        return null !== $locked->getAttribute('locked');
321 321
     }
322 322
 }
Please login to merge, or discard this patch.
src/Utils/Strings.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
      * @return string
18 18
      * @throws Exception
19 19
      */
20
-    public static function cleanCDATA( $testString ) {
21
-        $cleanXMLContent = new SimpleXMLElement( '<rootNoteNode>' . $testString . '</rootNoteNode>', LIBXML_NOCDATA );
20
+    public static function cleanCDATA($testString) {
21
+        $cleanXMLContent = new SimpleXMLElement('<rootNoteNode>' . $testString . '</rootNoteNode>', LIBXML_NOCDATA);
22 22
 
23 23
         return $cleanXMLContent->__toString();
24 24
     }
@@ -28,28 +28,28 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @return bool
30 30
      */
31
-    public static function isJSON( $string ) {
32
-        if ( is_numeric( $string ) ) {
31
+    public static function isJSON($string) {
32
+        if (is_numeric($string)) {
33 33
             return false;
34 34
         }
35 35
 
36 36
         try {
37
-            $string = Strings::cleanCDATA( $string );
38
-        } catch ( Exception $e ) {
37
+            $string = Strings::cleanCDATA($string);
38
+        } catch (Exception $e) {
39 39
             return false;
40 40
         }
41 41
 
42
-        $string = trim( $string );
43
-        if ( empty( $string ) ) {
42
+        $string = trim($string);
43
+        if (empty($string)) {
44 44
             return false;
45 45
         }
46 46
 
47 47
         // String representation in json is "quoted", but we want to accept only object or arrays.
48 48
         // exclude strings and numbers and other primitive types
49
-        if ( in_array( $string [ 0 ], [ "{", "[" ] ) ) {
50
-            json_decode( $string );
49
+        if (in_array($string [0], ["{", "["])) {
50
+            json_decode($string);
51 51
 
52
-            return empty( self::getLastJsonError()[ 0 ] );
52
+            return empty(self::getLastJsonError()[0]);
53 53
         } else {
54 54
             return false; // Not accepted: string or primitive types.
55 55
         }
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @return array
63 63
      */
64
-    public static function jsonToArray( $string ) {
65
-        $decodedJSON = json_decode( $string, true );
64
+    public static function jsonToArray($string) {
65
+        $decodedJSON = json_decode($string, true);
66 66
 
67
-        return ( is_array( $decodedJSON ) ) ? $decodedJSON : [];
67
+        return (is_array($decodedJSON)) ? $decodedJSON : [];
68 68
     }
69 69
 
70 70
     /**
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
      */
76 76
     private static function raiseLastJsonException() {
77 77
 
78
-        list( $msg, $error ) = self::getLastJsonError();
78
+        list($msg, $error) = self::getLastJsonError();
79 79
 
80
-        if ( $error != JSON_ERROR_NONE ) {
81
-            throw new NotValidJSONException( $msg, $error );
80
+        if ($error != JSON_ERROR_NONE) {
81
+            throw new NotValidJSONException($msg, $error);
82 82
         }
83 83
 
84 84
     }
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
      */
89 89
     private static function getLastJsonError() {
90 90
 
91
-        if ( function_exists( "json_last_error" ) ) {
91
+        if (function_exists("json_last_error")) {
92 92
 
93 93
             $error = json_last_error();
94 94
 
95
-            switch ( $error ) {
95
+            switch ($error) {
96 96
                 case JSON_ERROR_NONE:
97 97
                     $msg = null; # - No errors
98 98
                     break;
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
                     break;
117 117
             }
118 118
 
119
-            return [ $msg, $error ];
119
+            return [$msg, $error];
120 120
         }
121 121
 
122
-        return [ null, JSON_ERROR_NONE ];
122
+        return [null, JSON_ERROR_NONE];
123 123
 
124 124
     }
125 125
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
      *
143 143
      * @return string
144 144
      */
145
-    public static function fixNonWellFormedXml( $content, $escapeStrings = true ) {
146
-        if ( self::$find_xliff_tags_reg === null ) {
145
+    public static function fixNonWellFormedXml($content, $escapeStrings = true) {
146
+        if (self::$find_xliff_tags_reg === null) {
147 147
             // Convert the list of tags in a regexp list, for example "g|x|bx|ex"
148 148
             $xliffTags           = XliffTags::$tags;
149
-            $xliff_tags_reg_list = implode( '|', $xliffTags );
149
+            $xliff_tags_reg_list = implode('|', $xliffTags);
150 150
             // Regexp to find all the XLIFF tags:
151 151
             //   </?               -> matches the tag start, for both opening and
152 152
             //                        closure tags (see the optional slash)
@@ -167,30 +167,30 @@  discard block
 block discarded – undo
167 167
         }
168 168
 
169 169
         // Find all the XLIFF tags
170
-        preg_match_all( self::$find_xliff_tags_reg, $content, $matches );
171
-        $tags = (array)$matches[ 0 ];
170
+        preg_match_all(self::$find_xliff_tags_reg, $content, $matches);
171
+        $tags = (array)$matches[0];
172 172
 
173 173
         // Prepare placeholders
174 174
         $tags_placeholders = [];
175
-        $tagsNum           = count( $tags );
176
-        for ( $i = 0; $i < $tagsNum; $i++ ) {
177
-            $tag                       = $tags[ $i ];
178
-            $tags_placeholders[ $tag ] = "#@!XLIFF-TAG-$i!@#";
175
+        $tagsNum           = count($tags);
176
+        for ($i = 0; $i < $tagsNum; $i++) {
177
+            $tag                       = $tags[$i];
178
+            $tags_placeholders[$tag] = "#@!XLIFF-TAG-$i!@#";
179 179
         }
180 180
 
181 181
         // Replace all XLIFF tags with placeholders that will not be escaped
182
-        foreach ( $tags_placeholders as $tag => $placeholder ) {
183
-            $content = str_replace( $tag, $placeholder, $content );
182
+        foreach ($tags_placeholders as $tag => $placeholder) {
183
+            $content = str_replace($tag, $placeholder, $content);
184 184
         }
185 185
 
186 186
         // Escape the string with the remaining non-XLIFF tags
187
-        if ( $escapeStrings ) {
188
-            $content = htmlspecialchars( $content, ENT_NOQUOTES, 'UTF-8', false );
187
+        if ($escapeStrings) {
188
+            $content = htmlspecialchars($content, ENT_NOQUOTES, 'UTF-8', false);
189 189
         }
190 190
 
191 191
         // Put again in place the original XLIFF tags replacing placeholders
192
-        foreach ( $tags_placeholders as $tag => $placeholder ) {
193
-            $content = str_replace( $placeholder, $tag, $content );
192
+        foreach ($tags_placeholders as $tag => $placeholder) {
193
+            $content = str_replace($placeholder, $tag, $content);
194 194
         }
195 195
 
196 196
         return $content;
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
      *
202 202
      * @return string
203 203
      */
204
-    public static function removeDangerousChars( $string ) {
204
+    public static function removeDangerousChars($string) {
205 205
         // clean invalid xml entities ( characters with ascii < 32 and different from 0A, 0D and 09
206 206
         $regexpEntity = '/&#x(0[0-8BCEF]|1[\dA-F]|7F);/u';
207 207
 
208 208
         // remove binary chars in some xliff files
209 209
         $regexpAscii = '/[\x{00}-\x{08}\x{0B}\x{0C}\x{0E}-\x{1F}\x{7F}]/u';
210 210
 
211
-        $string = preg_replace( $regexpAscii, '', $string );
212
-        $string = preg_replace( $regexpEntity, '', $string );
211
+        $string = preg_replace($regexpAscii, '', $string);
212
+        $string = preg_replace($regexpEntity, '', $string);
213 213
 
214
-        return !empty( $string ) ? $string : "";
214
+        return !empty($string) ? $string : "";
215 215
     }
216 216
 
217 217
     /**
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
      *
221 221
      * @return bool
222 222
      */
223
-    public static function contains( $needle, $haystack ) {
224
-        return mb_strpos( $haystack, $needle ) !== false;
223
+    public static function contains($needle, $haystack) {
224
+        return mb_strpos($haystack, $needle) !== false;
225 225
     }
226 226
 
227 227
     /**
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
      *
230 230
      * @return string
231 231
      */
232
-    public static function htmlentities( $string ) {
233
-        return htmlentities( $string, ENT_NOQUOTES );
232
+    public static function htmlentities($string) {
233
+        return htmlentities($string, ENT_NOQUOTES);
234 234
     }
235 235
 
236 236
     /**
@@ -239,15 +239,15 @@  discard block
 block discarded – undo
239 239
      *
240 240
      * @return string
241 241
      */
242
-    public static function htmlspecialchars_decode( $string, $onlyEscapedEntities = false ) {
243
-        if ( false === $onlyEscapedEntities ) {
244
-            return htmlspecialchars_decode( $string, ENT_NOQUOTES );
242
+    public static function htmlspecialchars_decode($string, $onlyEscapedEntities = false) {
243
+        if (false === $onlyEscapedEntities) {
244
+            return htmlspecialchars_decode($string, ENT_NOQUOTES);
245 245
         }
246 246
 
247
-        return preg_replace_callback( self::$htmlEntityRegex,
248
-                function ( $match ) {
249
-                    return self::htmlspecialchars_decode( $match[ 0 ] );
250
-                }, $string );
247
+        return preg_replace_callback(self::$htmlEntityRegex,
248
+                function($match) {
249
+                    return self::htmlspecialchars_decode($match[0]);
250
+                }, $string);
251 251
     }
252 252
 
253 253
     /**
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
      *
263 263
      * @return bool
264 264
      */
265
-    public static function isADoubleEscapedEntity( $str ) {
266
-        return preg_match( self::$htmlEntityRegex, $str ) != 0;
265
+    public static function isADoubleEscapedEntity($str) {
266
+        return preg_match(self::$htmlEntityRegex, $str) != 0;
267 267
     }
268 268
 
269 269
     /**
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
      *
272 272
      * @return bool
273 273
      */
274
-    public static function isAnEscapedHTML( $str ) {
275
-        return preg_match( '#/[a-z]*&gt;#i', $str ) != 0;
274
+    public static function isAnEscapedHTML($str) {
275
+        return preg_match('#/[a-z]*&gt;#i', $str) != 0;
276 276
     }
277 277
 
278 278
     /**
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
      *
281 281
      * @return bool
282 282
      */
283
-    public static function isAValidUuid( $uuid ) {
284
-        return preg_match( '/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/', $uuid ) === 1;
283
+    public static function isAValidUuid($uuid) {
284
+        return preg_match('/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/', $uuid) === 1;
285 285
     }
286 286
 
287 287
     /**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
      *
291 291
      * @return array|false|string[]
292 292
      */
293
-    public static function preg_split( $pattern, $subject ) {
294
-        return preg_split( $pattern, $subject, -1, PREG_SPLIT_NO_EMPTY );
293
+    public static function preg_split($pattern, $subject) {
294
+        return preg_split($pattern, $subject, -1, PREG_SPLIT_NO_EMPTY);
295 295
     }
296 296
 
297 297
     /**
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
      *
310 310
      * @return string
311 311
      */
312
-    public static function escapeOnlyHTMLTags( $string ) {
313
-        return preg_replace( '/<(.*?)>/iu', '&lt;$1&gt;', $string );
312
+    public static function escapeOnlyHTMLTags($string) {
313
+        return preg_replace('/<(.*?)>/iu', '&lt;$1&gt;', $string);
314 314
     }
315 315
 
316 316
     /**
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
      *
321 321
      * @return string
322 322
      */
323
-    public static function lastChar( $string ) {
324
-        return mb_substr( $string, -1 );
323
+    public static function lastChar($string) {
324
+        return mb_substr($string, -1);
325 325
     }
326 326
 
327 327
     /**
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
      *
330 330
      * @return int
331 331
      */
332
-    public static function getTheNumberOfTrailingSpaces( $segment ) {
333
-        return mb_strlen( $segment ) - mb_strlen( rtrim( $segment, ' ' ) );
332
+    public static function getTheNumberOfTrailingSpaces($segment) {
333
+        return mb_strlen($segment) - mb_strlen(rtrim($segment, ' '));
334 334
     }
335 335
 
336 336
     /**
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
      *
341 341
      * @return bool
342 342
      */
343
-    public static function isHtmlString( $string ) {
344
-        $string = stripslashes( $string );
343
+    public static function isHtmlString($string) {
344
+        $string = stripslashes($string);
345 345
 
346
-        if ( $string === '<>' ) {
346
+        if ($string === '<>') {
347 347
             return false;
348 348
         }
349 349
 
350
-        preg_match( "#</?[a-zA-Z1-6-]+((\s+[a-zA-Z1-6-]+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)/?>#", $string, $matches );
350
+        preg_match("#</?[a-zA-Z1-6-]+((\s+[a-zA-Z1-6-]+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)/?>#", $string, $matches);
351 351
 
352
-        return count( $matches ) !== 0;
352
+        return count($matches) !== 0;
353 353
     }
354 354
 }
Please login to merge, or discard this patch.
src/XliffReplacer/SdlXliffSAXTranslationReplacer.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -10,22 +10,22 @@  discard block
 block discarded – undo
10 10
     /**
11 11
      * @inheritDoc
12 12
      */
13
-    protected function tagOpen( $parser, $name, $attr ) {
13
+    protected function tagOpen($parser, $name, $attr) {
14 14
         // check if we are entering into a <trans-unit> (xliff v1.*) or <unit> (xliff v2.*)
15
-        if ( $this->tuTagName === $name ) {
15
+        if ($this->tuTagName === $name) {
16 16
             $this->inTU = true;
17 17
 
18 18
             // get id
19 19
             // trim to first 100 characters because this is the limit on Matecat's DB
20
-            $this->currentTransUnitId = substr( $attr[ 'id' ], 0, 100 );
20
+            $this->currentTransUnitId = substr($attr['id'], 0, 100);
21 21
 
22 22
             // current 'translate' attribute of the current trans-unit
23
-            $this->currentTransUnitTranslate = isset( $attr[ 'translate' ] ) ? $attr[ 'translate' ] : 'yes';
23
+            $this->currentTransUnitTranslate = isset($attr['translate']) ? $attr['translate'] : 'yes';
24 24
         }
25 25
 
26 26
         // check if we are entering into a <target>
27
-        if ( 'target' == $name ) {
28
-            if ( $this->currentTransUnitTranslate === 'no' ) {
27
+        if ('target' == $name) {
28
+            if ($this->currentTransUnitTranslate === 'no') {
29 29
                 $this->inTarget = false;
30 30
             } else {
31 31
                 $this->inTarget = true;
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
         }
34 34
 
35 35
         // reset Marker positions
36
-        if ( 'sdl:seg-defs' == $name ) {
36
+        if ('sdl:seg-defs' == $name) {
37 37
             $this->markerPos = 0;
38 38
         }
39 39
 
40 40
         // check if we are inside a <target>, obviously this happen only if there are targets inside the trans-unit
41 41
         // <target> must be stripped to be replaced, so this check avoids <target> reconstruction
42
-        if ( !$this->inTarget ) {
42
+        if (!$this->inTarget) {
43 43
 
44 44
             // costruct tag
45 45
             $tag = "<$name ";
@@ -49,23 +49,23 @@  discard block
 block discarded – undo
49 49
             // so the check on it's name is not enough
50 50
             $_sdlStatus_confWritten = false;
51 51
 
52
-            foreach ( $attr as $k => $v ) {
52
+            foreach ($attr as $k => $v) {
53 53
 
54 54
                 // if tag name is file, we must replace the target-language attribute
55
-                if ( $name == 'file' && $k == 'target-language' && !empty( $this->targetLang ) ) {
55
+                if ($name == 'file' && $k == 'target-language' && !empty($this->targetLang)) {
56 56
                     //replace Target language with job language provided from constructor
57 57
                     $tag .= "$k=\"$this->targetLang\" ";
58 58
 
59
-                    if ( null !== $this->logger ) {
60
-                        $this->logger->debug( $k . " => " . $this->targetLang );
59
+                    if (null !== $this->logger) {
60
+                        $this->logger->debug($k . " => " . $this->targetLang);
61 61
                     }
62
-                } elseif ( 'sdl:seg' == $name ) {
62
+                } elseif ('sdl:seg' == $name) {
63 63
 
64 64
                     // write the confidence level for this segment ( Translated, Draft, etc. )
65
-                    if ( isset( $this->segments[ 'matecat|' . $this->currentTransUnitId ] ) && $_sdlStatus_confWritten === false ) {
65
+                    if (isset($this->segments['matecat|' . $this->currentTransUnitId]) && $_sdlStatus_confWritten === false) {
66 66
 
67 67
                         // append definition attribute
68
-                        $tag .= $this->prepareTargetStatuses( $this->lastTransUnit[ $this->markerPos ] );
68
+                        $tag .= $this->prepareTargetStatuses($this->lastTransUnit[$this->markerPos]);
69 69
 
70 70
                         //prepare for an eventual next cycle
71 71
                         $this->markerPos++;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                     }
74 74
 
75 75
                     // Warning, this is NOT an elseif
76
-                    if ( $k != 'conf' ) {
76
+                    if ($k != 'conf') {
77 77
                         //put also the current attribute in it if it is not a "conf" attribute
78 78
                         $tag .= "$k=\"$v\" ";
79 79
                     }
@@ -86,29 +86,29 @@  discard block
 block discarded – undo
86 86
             // this logic helps detecting empty tags
87 87
             // get current position of SAX pointer in all the stream of data is has read so far:
88 88
             // it points at the end of current tag
89
-            $idx = xml_get_current_byte_index( $parser );
89
+            $idx = xml_get_current_byte_index($parser);
90 90
 
91 91
             // check whether the bounds of current tag are entirely in current buffer || the end of the current tag
92 92
             // is outside current buffer (in the latter case, it's in next buffer to be read by the while loop);
93 93
             // this check is necessary because we may have truncated a tag in half with current read,
94 94
             // and the other half may be encountered in the next buffer it will be passed
95
-            if ( isset( $this->currentBuffer[ $idx - $this->offset ] ) ) {
95
+            if (isset($this->currentBuffer[$idx - $this->offset])) {
96 96
                 // if this tag entire lenght fitted in the buffer, the last char must be the last
97 97
                 // symbol before the '>'; if it's an empty tag, it is assumed that it's a '/'
98 98
                 $tmp_offset = $idx - $this->offset;
99
-                $lastChar   = $this->currentBuffer[ $tmp_offset ];
99
+                $lastChar   = $this->currentBuffer[$tmp_offset];
100 100
             } else {
101 101
                 //if it's out, simple use the last character of the chunk
102 102
                 $tmp_offset = $this->len - 1;
103
-                $lastChar   = $this->currentBuffer[ $tmp_offset ];
103
+                $lastChar   = $this->currentBuffer[$tmp_offset];
104 104
             }
105 105
 
106 106
             // trim last space
107
-            $tag = rtrim( $tag );
107
+            $tag = rtrim($tag);
108 108
 
109 109
             // detect empty tag
110
-            $this->isEmpty = ( $lastChar == '/' || $name == 'x' );
111
-            if ( $this->isEmpty ) {
110
+            $this->isEmpty = ($lastChar == '/' || $name == 'x');
111
+            if ($this->isEmpty) {
112 112
                 $tag .= '/';
113 113
             }
114 114
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             $tag .= ">";
117 117
 
118 118
             // set a a Buffer for the segSource Source tag
119
-            if ( 'source' == $name
119
+            if ('source' == $name
120 120
                     || 'seg-source' === $name
121 121
                     || $this->bufferIsActive
122 122
                     || 'value' === $name
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
                     || 'ph' === $name
126 126
                     || 'st' === $name
127 127
                     || 'note' === $name
128
-                    || 'context' === $name ) { // we are opening a critical CDATA section
128
+                    || 'context' === $name) { // we are opening a critical CDATA section
129 129
 
130 130
                 // WARNING BECAUSE SOURCE AND SEG-SOURCE TAGS CAN BE EMPTY IN SOME CASES!!!!!
131 131
                 // so check for isEmpty also in conjunction with name
132
-                if ( $this->isEmpty && ( 'source' == $name || 'seg-source' == $name ) ) {
133
-                    $this->postProcAndFlush( $this->outputFP, $tag );
132
+                if ($this->isEmpty && ('source' == $name || 'seg-source' == $name)) {
133
+                    $this->postProcAndFlush($this->outputFP, $tag);
134 134
                 } else {
135 135
                     //these are NOT source/seg-source/value empty tags, THERE IS A CONTENT, write it in buffer
136 136
                     $this->bufferIsActive = true;
137
-                    $this->CDATABuffer    .= $tag;
137
+                    $this->CDATABuffer .= $tag;
138 138
                 }
139 139
             } else {
140
-                $this->postProcAndFlush( $this->outputFP, $tag );
140
+                $this->postProcAndFlush($this->outputFP, $tag);
141 141
             }
142 142
         }
143 143
     }
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
      *
151 151
      * @return string
152 152
      */
153
-    protected function prepareTranslation( $seg, $transUnitTranslation = "" ) {
153
+    protected function prepareTranslation($seg, $transUnitTranslation = "") {
154 154
         $endTags = "";
155 155
 
156
-        $segment     = Strings::removeDangerousChars( $seg [ 'segment' ] );
157
-        $translation = Strings::removeDangerousChars( $seg [ 'translation' ] );
158
-        $dataRefMap  = ( isset( $seg[ 'data_ref_map' ] ) && $seg[ 'data_ref_map' ] !== null ) ? Strings::jsonToArray( $seg[ 'data_ref_map' ] ) : [];
156
+        $segment     = Strings::removeDangerousChars($seg ['segment']);
157
+        $translation = Strings::removeDangerousChars($seg ['translation']);
158
+        $dataRefMap  = (isset($seg['data_ref_map']) && $seg['data_ref_map'] !== null) ? Strings::jsonToArray($seg['data_ref_map']) : [];
159 159
 
160
-        if ( is_null( $seg [ 'translation' ] ) || $seg [ 'translation' ] == '' ) {
160
+        if (is_null($seg ['translation']) || $seg ['translation'] == '') {
161 161
             $translation = $segment;
162 162
         } else {
163
-            if ( $this->callback ) {
163
+            if ($this->callback) {
164 164
                 $error = (isset($seg['error'])) ? $seg['error'] : null;
165
-                if ( $this->callback->thereAreErrors( $seg[ 'sid' ], $segment, $translation, $dataRefMap, $error ) ) {
165
+                if ($this->callback->thereAreErrors($seg['sid'], $segment, $translation, $dataRefMap, $error)) {
166 166
                     $translation = '|||UNTRANSLATED_CONTENT_START|||' . $segment . '|||UNTRANSLATED_CONTENT_END|||';
167 167
                 }
168 168
             }
@@ -171,20 +171,20 @@  discard block
 block discarded – undo
171 171
         // for Trados the trailing spaces after </mrk> are meaningful
172 172
         // so we trim the translation from Matecat DB and add them after </mrk>
173 173
         $trailingSpaces = '';
174
-        for ( $s = 0; $s < Strings::getTheNumberOfTrailingSpaces( $translation ); $s++ ) {
174
+        for ($s = 0; $s < Strings::getTheNumberOfTrailingSpaces($translation); $s++) {
175 175
             $trailingSpaces .= ' ';
176 176
         }
177 177
 
178
-        if ( $seg[ 'mrk_id' ] !== null && $seg[ 'mrk_id' ] != '' ) {
179
-            if ( $this->targetLang === 'ja-JP' ) {
180
-                $seg[ 'mrk_succ_tags' ] = ltrim( $seg[ 'mrk_succ_tags' ] );
178
+        if ($seg['mrk_id'] !== null && $seg['mrk_id'] != '') {
179
+            if ($this->targetLang === 'ja-JP') {
180
+                $seg['mrk_succ_tags'] = ltrim($seg['mrk_succ_tags']);
181 181
             }
182 182
 
183
-            $translation = "<mrk mid=\"" . $seg[ 'mrk_id' ] . "\" mtype=\"seg\">" . $seg[ 'mrk_prev_tags' ] . rtrim( $translation ) . $seg[ 'mrk_succ_tags' ] . "</mrk>" . $trailingSpaces;
183
+            $translation = "<mrk mid=\"" . $seg['mrk_id'] . "\" mtype=\"seg\">" . $seg['mrk_prev_tags'] . rtrim($translation) . $seg['mrk_succ_tags'] . "</mrk>" . $trailingSpaces;
184 184
         }
185 185
 
186 186
         // we need to trim succ_tags here because we already added the trailing spaces after </mrk>
187
-        $transUnitTranslation .= $seg[ 'prev_tags' ] . $translation . $endTags . ltrim( $seg[ 'succ_tags' ] );
187
+        $transUnitTranslation .= $seg['prev_tags'] . $translation . $endTags . ltrim($seg['succ_tags']);
188 188
 
189 189
         return $transUnitTranslation;
190 190
     }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      *
195 195
      * @return string
196 196
      */
197
-    protected function prepareTargetStatuses( $segment ) {
197
+    protected function prepareTargetStatuses($segment) {
198 198
         $statusMap = [
199 199
                 'NEW'        => '',
200 200
                 'DRAFT'      => 'Draft',
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                 'REJECTED'   => 'RejectedTranslation',
204 204
         ];
205 205
 
206
-        return "conf=\"{$statusMap[ $segment[ 'status' ] ]}\" ";
206
+        return "conf=\"{$statusMap[$segment['status']]}\" ";
207 207
     }
208 208
 
209 209
     /**
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
      *
214 214
      * @return array
215 215
      */
216
-    protected function setTransUnitState( $seg, $state_prop, $lastMrkState ) {
217
-        return [ null, null ];
216
+    protected function setTransUnitState($seg, $state_prop, $lastMrkState) {
217
+        return [null, null];
218 218
     }
219 219
 
220 220
     /**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      *
224 224
      * @return string
225 225
      */
226
-    protected function getWordCountGroup( $raw_word_count, $eq_word_count ) {
226
+    protected function getWordCountGroup($raw_word_count, $eq_word_count) {
227 227
         return '';
228 228
     }
229 229
 }
Please login to merge, or discard this patch.
src/XliffReplacer/XliffSAXTranslationReplacer.php 1 patch
Spacing   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -31,17 +31,17 @@  discard block
 block discarded – undo
31 31
     ];
32 32
 
33 33
     public function replaceTranslation() {
34
-        fwrite( $this->outputFP, '<?xml version="1.0" encoding="UTF-8"?>' );
34
+        fwrite($this->outputFP, '<?xml version="1.0" encoding="UTF-8"?>');
35 35
 
36 36
         //create Sax parser
37 37
         $xmlParser = $this->initSaxParser();
38 38
 
39
-        while ( $this->currentBuffer = fread( $this->originalFP, 4096 ) ) {
39
+        while ($this->currentBuffer = fread($this->originalFP, 4096)) {
40 40
             /*
41 41
                preprocess file
42 42
              */
43 43
             // obfuscate entities because sax automatically does html_entity_decode
44
-            $temporary_check_buffer = preg_replace( "/&(.*?);/", self::$INTERNAL_TAG_PLACEHOLDER . '$1' . self::$INTERNAL_TAG_PLACEHOLDER, $this->currentBuffer );
44
+            $temporary_check_buffer = preg_replace("/&(.*?);/", self::$INTERNAL_TAG_PLACEHOLDER . '$1' . self::$INTERNAL_TAG_PLACEHOLDER, $this->currentBuffer);
45 45
 
46 46
             //avoid cutting entities in half:
47 47
             //the last fread could have truncated an entity (say, '&lt;' in '&l'), thus invalidating the escaping
@@ -53,84 +53,84 @@  discard block
 block discarded – undo
53 53
             // add 9 Bytes and substitute the entities, if the & is present, and it is not at the end
54 54
             //it can't be an entity, exit the loop
55 55
 
56
-            while ( true ) {
57
-                $_ampPos = strpos( $temporary_check_buffer, '&' );
56
+            while (true) {
57
+                $_ampPos = strpos($temporary_check_buffer, '&');
58 58
 
59 59
                 //check for real entity or escape it to safely exit from the loop!!!
60
-                if ( $_ampPos === false || strlen( substr( $temporary_check_buffer, $_ampPos ) ) > 9 ) {
60
+                if ($_ampPos === false || strlen(substr($temporary_check_buffer, $_ampPos)) > 9) {
61 61
                     $escape_AMP = true;
62 62
                     break;
63 63
                 }
64 64
 
65 65
                 //if an entity is still present, fetch some more and repeat the escaping
66
-                $this->currentBuffer    .= fread( $this->originalFP, 9 );
67
-                $temporary_check_buffer = preg_replace( "/&(.*?);/", self::$INTERNAL_TAG_PLACEHOLDER . '$1' . self::$INTERNAL_TAG_PLACEHOLDER, $this->currentBuffer );
66
+                $this->currentBuffer .= fread($this->originalFP, 9);
67
+                $temporary_check_buffer = preg_replace("/&(.*?);/", self::$INTERNAL_TAG_PLACEHOLDER . '$1' . self::$INTERNAL_TAG_PLACEHOLDER, $this->currentBuffer);
68 68
             }
69 69
 
70 70
             //free stuff outside the loop
71
-            unset( $temporary_check_buffer );
71
+            unset($temporary_check_buffer);
72 72
 
73
-            $this->currentBuffer = preg_replace( "/&(.*?);/", self::$INTERNAL_TAG_PLACEHOLDER . '$1' . self::$INTERNAL_TAG_PLACEHOLDER, $this->currentBuffer );
74
-            if ( $escape_AMP ) {
75
-                $this->currentBuffer = str_replace( "&", self::$INTERNAL_TAG_PLACEHOLDER . 'amp' . self::$INTERNAL_TAG_PLACEHOLDER, $this->currentBuffer );
73
+            $this->currentBuffer = preg_replace("/&(.*?);/", self::$INTERNAL_TAG_PLACEHOLDER . '$1' . self::$INTERNAL_TAG_PLACEHOLDER, $this->currentBuffer);
74
+            if ($escape_AMP) {
75
+                $this->currentBuffer = str_replace("&", self::$INTERNAL_TAG_PLACEHOLDER . 'amp' . self::$INTERNAL_TAG_PLACEHOLDER, $this->currentBuffer);
76 76
             }
77 77
 
78 78
             //get length of chunk
79
-            $this->len = strlen( $this->currentBuffer );
79
+            $this->len = strlen($this->currentBuffer);
80 80
 
81 81
             //parse chunk of text
82
-            if ( !xml_parse( $xmlParser, $this->currentBuffer, feof( $this->originalFP ) ) ) {
82
+            if (!xml_parse($xmlParser, $this->currentBuffer, feof($this->originalFP))) {
83 83
                 //if unable, raise an exception
84
-                throw new RuntimeException( sprintf(
84
+                throw new RuntimeException(sprintf(
85 85
                         "XML error: %s at line %d",
86
-                        xml_error_string( xml_get_error_code( $xmlParser ) ),
87
-                        xml_get_current_line_number( $xmlParser )
88
-                ) );
86
+                        xml_error_string(xml_get_error_code($xmlParser)),
87
+                        xml_get_current_line_number($xmlParser)
88
+                ));
89 89
             }
90 90
             //get accumulated this->offset in document: as long as SAX pointer advances, we keep track of total bytes it has seen so far; this way, we can translate its global pointer in an address local to the current buffer of text to retrieve last char of tag
91 91
             $this->offset += $this->len;
92 92
         }
93 93
 
94 94
         // close Sax parser
95
-        $this->closeSaxParser( $xmlParser );
95
+        $this->closeSaxParser($xmlParser);
96 96
 
97 97
     }
98 98
 
99 99
     /**
100 100
      * @inheritDoc
101 101
      */
102
-    protected function tagOpen( $parser, $name, $attr ) {
102
+    protected function tagOpen($parser, $name, $attr) {
103 103
         // check if we are entering into a <trans-unit> (xliff v1.*) or <unit> (xliff v2.*)
104
-        if ( $this->tuTagName === $name ) {
104
+        if ($this->tuTagName === $name) {
105 105
             $this->inTU = true;
106 106
 
107 107
             // get id
108 108
             // trim to first 100 characters because this is the limit on Matecat's DB
109
-            $this->currentTransUnitId = substr( $attr[ 'id' ], 0, 100 );
109
+            $this->currentTransUnitId = substr($attr['id'], 0, 100);
110 110
 
111 111
             // `translate` attribute can be only yes or no
112
-            if ( isset( $attr[ 'translate' ] ) && $attr[ 'translate' ] === 'no' ) {
113
-                $attr[ 'translate' ] = 'no';
112
+            if (isset($attr['translate']) && $attr['translate'] === 'no') {
113
+                $attr['translate'] = 'no';
114 114
             } else {
115
-                $attr[ 'translate' ] = 'yes';
115
+                $attr['translate'] = 'yes';
116 116
             }
117 117
 
118 118
             // current 'translate' attribute of the current trans-unit
119
-            $this->currentTransUnitTranslate = $attr[ 'translate' ];
119
+            $this->currentTransUnitTranslate = $attr['translate'];
120 120
         }
121 121
 
122
-        if ( 'source' === $name ) {
122
+        if ('source' === $name) {
123 123
             $this->sourceAttributes = $attr;
124 124
         }
125 125
 
126
-        if ( 'mda:metadata' === $name ) {
126
+        if ('mda:metadata' === $name) {
127 127
             $this->unitContainsMda = true;
128 128
         }
129 129
 
130 130
         // check if we are entering into a <target>
131
-        if ( 'target' === $name ) {
131
+        if ('target' === $name) {
132 132
 
133
-            if ( $this->currentTransUnitTranslate === 'no' ) {
133
+            if ($this->currentTransUnitTranslate === 'no') {
134 134
                 $this->inTarget = false;
135 135
             } else {
136 136
                 $this->inTarget = true;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         // check if we are inside a <target>, obviously this happen only if there are targets inside the trans-unit
141 141
         // <target> must be stripped to be replaced, so this check avoids <target> reconstruction
142
-        if ( !$this->inTarget ) {
142
+        if (!$this->inTarget) {
143 143
 
144 144
             $tag = '';
145 145
 
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
             //
162 162
             // http://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html#unit
163 163
             //
164
-            if ( $this->xliffVersion === 2 && ( $name === 'notes' || $name === 'originalData' || $name === 'segment' || $name === 'ignorable' ) && $this->unitContainsMda === false ) {
165
-                if ( isset( $this->transUnits[ $this->currentTransUnitId ] ) && !empty( $this->transUnits[ $this->currentTransUnitId ] ) && !$this->hasWrittenCounts ) {
164
+            if ($this->xliffVersion === 2 && ($name === 'notes' || $name === 'originalData' || $name === 'segment' || $name === 'ignorable') && $this->unitContainsMda === false) {
165
+                if (isset($this->transUnits[$this->currentTransUnitId]) && !empty($this->transUnits[$this->currentTransUnitId]) && !$this->hasWrittenCounts) {
166 166
 
167 167
                     // we need to update counts here
168 168
                     $this->updateCounts();
169 169
                     $this->hasWrittenCounts = true;
170 170
 
171
-                    $tag                   .= $this->getWordCountGroupForXliffV2( $this->counts[ 'raw_word_count' ], $this->counts[ 'eq_word_count' ] );
171
+                    $tag                   .= $this->getWordCountGroupForXliffV2($this->counts['raw_word_count'], $this->counts['eq_word_count']);
172 172
                     $this->unitContainsMda = true;
173 173
                 }
174 174
             }
@@ -179,88 +179,88 @@  discard block
 block discarded – undo
179 179
             $lastMrkState = null;
180 180
             $stateProp    = '';
181 181
 
182
-            foreach ( $attr as $k => $v ) {
182
+            foreach ($attr as $k => $v) {
183 183
 
184 184
                 //if tag name is file, we must replace the target-language attribute
185
-                if ( $name === 'file' && $k === 'target-language' && !empty( $this->targetLang ) ) {
185
+                if ($name === 'file' && $k === 'target-language' && !empty($this->targetLang)) {
186 186
                     //replace Target language with job language provided from constructor
187 187
                     $tag .= "$k=\"$this->targetLang\" ";
188 188
                 } else {
189 189
                     $pos = 0;
190
-                    if ( $this->currentTransUnitId and isset($this->transUnits[ $this->currentTransUnitId ])) {
191
-                        $pos = current( $this->transUnits[ $this->currentTransUnitId ] );
190
+                    if ($this->currentTransUnitId and isset($this->transUnits[$this->currentTransUnitId])) {
191
+                        $pos = current($this->transUnits[$this->currentTransUnitId]);
192 192
                     }
193 193
 
194
-                    if ( $name === $this->tuTagName and isset($this->segments[ $pos ]) and isset($this->segments[ $pos ][ 'sid' ]) ) {
194
+                    if ($name === $this->tuTagName and isset($this->segments[$pos]) and isset($this->segments[$pos]['sid'])) {
195 195
 
196
-                        $sid = $this->segments[ $pos ][ 'sid' ];
196
+                        $sid = $this->segments[$pos]['sid'];
197 197
 
198 198
                         // add `help-id` to xliff v.1*
199 199
                         // add `mtc:segment-id` to xliff v.2*
200
-                        if ( $this->xliffVersion === 1 && strpos( $tag, 'help-id' ) === false ) {
201
-                            if ( !empty( $sid ) ) {
200
+                        if ($this->xliffVersion === 1 && strpos($tag, 'help-id') === false) {
201
+                            if (!empty($sid)) {
202 202
                                 $tag .= "help-id=\"$sid\" ";
203 203
                             }
204
-                        } elseif ( $this->xliffVersion === 2 && strpos( $tag, 'mtc:segment-id' ) === false ) {
205
-                            if ( !empty( $sid ) ) {
204
+                        } elseif ($this->xliffVersion === 2 && strpos($tag, 'mtc:segment-id') === false) {
205
+                            if (!empty($sid)) {
206 206
                                 $tag .= "mtc:segment-id=\"$sid\" ";
207 207
                             }
208 208
                         }
209 209
 
210
-                    } elseif ( 'segment' === $name && $this->xliffVersion === 2 ) { // add state to segment in Xliff v2
211
-                        list( $stateProp, $lastMrkState ) = $this->setTransUnitState( $this->segments[ $pos ], $stateProp, $lastMrkState );
210
+                    } elseif ('segment' === $name && $this->xliffVersion === 2) { // add state to segment in Xliff v2
211
+                        list($stateProp, $lastMrkState) = $this->setTransUnitState($this->segments[$pos], $stateProp, $lastMrkState);
212 212
                     }
213 213
 
214 214
                     //normal tag flux, put attributes in it
215 215
                     $tag .= "$k=\"$v\" ";
216 216
 
217 217
                     // replace state for xliff v2
218
-                    if ( $stateProp ) {
218
+                    if ($stateProp) {
219 219
                         $pattern = '/state=\"(.*)\"/i';
220
-                        $tag     = preg_replace( $pattern, $stateProp, $tag );
220
+                        $tag     = preg_replace($pattern, $stateProp, $tag);
221 221
                     }
222 222
                 }
223 223
             }
224 224
 
225 225
             // add oasis xliff 20 namespace
226
-            if ( $this->xliffVersion === 2 && $name === 'xliff' && !array_key_exists( 'xmlns:mda', $attr ) ) {
226
+            if ($this->xliffVersion === 2 && $name === 'xliff' && !array_key_exists('xmlns:mda', $attr)) {
227 227
                 $tag .= 'xmlns:mda="urn:oasis:names:tc:xliff:metadata:2.0"';
228 228
             }
229 229
 
230 230
             // add MateCat specific namespace, we want maybe add non-XLIFF attributes
231
-            if ( $name === 'xliff' && !array_key_exists( 'xmlns:mtc', $attr ) ) {
231
+            if ($name === 'xliff' && !array_key_exists('xmlns:mtc', $attr)) {
232 232
                 $tag .= ' xmlns:mtc="https://www.matecat.com" ';
233 233
             }
234 234
 
235 235
             // trgLang
236
-            if ( $name === 'xliff' ) {
237
-                $tag = preg_replace( '/trgLang="(.*?)"/', 'trgLang="' . $this->targetLang . '"', $tag );
236
+            if ($name === 'xliff') {
237
+                $tag = preg_replace('/trgLang="(.*?)"/', 'trgLang="' . $this->targetLang . '"', $tag);
238 238
             }
239 239
 
240 240
             //this logic helps detecting empty tags
241 241
             //get current position of SAX pointer in all the stream of data is has read so far:
242 242
             //it points at the end of current tag
243
-            $idx = xml_get_current_byte_index( $parser );
243
+            $idx = xml_get_current_byte_index($parser);
244 244
 
245 245
             //check whether the bounds of current tag are entirely in current buffer or the end of the current tag
246 246
             //is outside current buffer (in the latter case, it's in next buffer to be read by the while loop);
247 247
             //this check is necessary because we may have truncated a tag in half with current read,
248 248
             //and the other half may be encountered in the next buffer it will be passed
249
-            if ( isset( $this->currentBuffer[ $idx - $this->offset ] ) ) {
249
+            if (isset($this->currentBuffer[$idx - $this->offset])) {
250 250
                 //if this tag entire lenght fitted in the buffer, the last char must be the last
251 251
                 //symbol before the '>'; if it's an empty tag, it is assumed that it's a '/'
252
-                $lastChar = $this->currentBuffer[ $idx - $this->offset ];
252
+                $lastChar = $this->currentBuffer[$idx - $this->offset];
253 253
             } else {
254 254
                 //if it's out, simple use the last character of the chunk
255
-                $lastChar = $this->currentBuffer[ $this->len - 1 ];
255
+                $lastChar = $this->currentBuffer[$this->len - 1];
256 256
             }
257 257
 
258 258
             //trim last space
259
-            $tag = rtrim( $tag );
259
+            $tag = rtrim($tag);
260 260
 
261 261
             //detect empty tag
262
-            $this->isEmpty = ( $lastChar == '/' || $name == 'x' );
263
-            if ( $this->isEmpty ) {
262
+            $this->isEmpty = ($lastChar == '/' || $name == 'x');
263
+            if ($this->isEmpty) {
264 264
                 $tag .= '/';
265 265
             }
266 266
 
@@ -268,29 +268,29 @@  discard block
 block discarded – undo
268 268
             $tag .= ">";
269 269
 
270 270
             //set a a Buffer for the segSource Source tag
271
-            if ( $this->bufferIsActive || in_array( $name, $this->nodesToCopy ) ) { // we are opening a critical CDATA section
271
+            if ($this->bufferIsActive || in_array($name, $this->nodesToCopy)) { // we are opening a critical CDATA section
272 272
 
273 273
                 //WARNING BECAUSE SOURCE AND SEG-SOURCE TAGS CAN BE EMPTY IN SOME CASES!!!!!
274 274
                 //so check for isEmpty also in conjunction with name
275
-                if ( $this->isEmpty && ( 'source' === $name || 'seg-source' === $name ) ) {
276
-                    $this->postProcAndFlush( $this->outputFP, $tag );
275
+                if ($this->isEmpty && ('source' === $name || 'seg-source' === $name)) {
276
+                    $this->postProcAndFlush($this->outputFP, $tag);
277 277
                 } else {
278 278
                     //these are NOT source/seg-source/value empty tags, THERE IS A CONTENT, write it in buffer
279 279
                     $this->bufferIsActive = true;
280
-                    $this->CDATABuffer    .= $tag;
280
+                    $this->CDATABuffer .= $tag;
281 281
                 }
282 282
             } else {
283
-                $this->postProcAndFlush( $this->outputFP, $tag );
283
+                $this->postProcAndFlush($this->outputFP, $tag);
284 284
             }
285 285
         }
286 286
 
287 287
         // update segmentPositionInTu
288 288
 
289
-        if ( $this->xliffVersion === 1 && $this->inTU && $name === 'source' ) {
289
+        if ($this->xliffVersion === 1 && $this->inTU && $name === 'source') {
290 290
             $this->segmentPositionInTu++;
291 291
         }
292 292
 
293
-        if ( $this->xliffVersion === 2 && $this->inTU && $name === 'segment' ) {
293
+        if ($this->xliffVersion === 2 && $this->inTU && $name === 'segment') {
294 294
             $this->segmentPositionInTu++;
295 295
         }
296 296
     }
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     /**
299 299
      * @inheritDoc
300 300
      */
301
-    protected function tagClose( $parser, $name ) {
301
+    protected function tagClose($parser, $name) {
302 302
         $tag = '';
303 303
 
304 304
         /**
@@ -307,26 +307,26 @@  discard block
 block discarded – undo
307 307
          *
308 308
          * self::tagOpen method
309 309
          */
310
-        if ( !$this->isEmpty && !( $this->inTarget && $name !== 'target' ) ) {
310
+        if (!$this->isEmpty && !($this->inTarget && $name !== 'target')) {
311 311
 
312
-            if ( !$this->inTarget ) {
312
+            if (!$this->inTarget) {
313 313
                 $tag = "</$name>";
314 314
             }
315 315
 
316
-            if ( 'target' == $name ) {
316
+            if ('target' == $name) {
317 317
 
318
-                if ( $this->currentTransUnitTranslate === 'no' ) {
318
+                if ($this->currentTransUnitTranslate === 'no') {
319 319
                     // do nothing
320
-                } elseif ( isset( $this->transUnits[ $this->currentTransUnitId ] ) ) {
320
+                } elseif (isset($this->transUnits[$this->currentTransUnitId])) {
321 321
 
322 322
                     // get translation of current segment, by indirect indexing: id -> positional index -> segment
323 323
                     // actually there may be more that one segment to that ID if there are two mrk of the same source segment
324 324
 
325
-                    $listOfSegmentsIds = $this->transUnits[ $this->currentTransUnitId ];
325
+                    $listOfSegmentsIds = $this->transUnits[$this->currentTransUnitId];
326 326
 
327 327
                     // $currentSegmentId
328
-                    if ( !empty( $listOfSegmentsIds ) ) {
329
-                        $this->setCurrentSegmentArray( $listOfSegmentsIds );
328
+                    if (!empty($listOfSegmentsIds)) {
329
+                        $this->setCurrentSegmentArray($listOfSegmentsIds);
330 330
                     }
331 331
 
332 332
                     /*
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
                     $this->lastTransUnit = [];
344 344
 
345 345
                     $last_value    = null;
346
-                    $segmentsCount = count( $listOfSegmentsIds );
347
-                    for ( $i = 0; $i < $segmentsCount; $i++ ) {
348
-                        $id = $listOfSegmentsIds[ $i ];
349
-                        if ( isset( $this->segments[ $id ] ) && ( $i == 0 || $last_value + 1 == $listOfSegmentsIds[ $i ] ) ) {
350
-                            $last_value            = $listOfSegmentsIds[ $i ];
351
-                            $this->lastTransUnit[] = $this->segments[ $id ];
346
+                    $segmentsCount = count($listOfSegmentsIds);
347
+                    for ($i = 0; $i < $segmentsCount; $i++) {
348
+                        $id = $listOfSegmentsIds[$i];
349
+                        if (isset($this->segments[$id]) && ($i == 0 || $last_value + 1 == $listOfSegmentsIds[$i])) {
350
+                            $last_value            = $listOfSegmentsIds[$i];
351
+                            $this->lastTransUnit[] = $this->segments[$id];
352 352
                         }
353 353
                     }
354 354
 
@@ -360,27 +360,27 @@  discard block
 block discarded – undo
360 360
                     // we must reset the lastMrkId found because this is a new segment.
361 361
                     $lastMrkId = -1;
362 362
 
363
-                    if ( $this->xliffVersion === 2 ) {
364
-                        $seg = $this->segments[ $this->currentSegmentArray[ 'sid' ] ];
363
+                    if ($this->xliffVersion === 2) {
364
+                        $seg = $this->segments[$this->currentSegmentArray['sid']];
365 365
 
366 366
                         // update counts
367
-                        if ( !$this->hasWrittenCounts && !empty( $seg ) ) {
368
-                            $this->updateSegmentCounts( $seg );
367
+                        if (!$this->hasWrittenCounts && !empty($seg)) {
368
+                            $this->updateSegmentCounts($seg);
369 369
                         }
370 370
 
371 371
                         // delete translations so the prepareSegment
372 372
                         // will put source content in target tag
373
-                        if ( $this->sourceInTarget ) {
374
-                            $seg[ 'translation' ] = '';
373
+                        if ($this->sourceInTarget) {
374
+                            $seg['translation'] = '';
375 375
                             $this->resetCounts();
376 376
                         }
377 377
 
378 378
                         // append $translation
379
-                        $translation = $this->prepareTranslation( $seg, $translation );
379
+                        $translation = $this->prepareTranslation($seg, $translation);
380 380
 
381
-                        list( $stateProp, $lastMrkState ) = $this->setTransUnitState( $seg, $stateProp, $lastMrkState );
381
+                        list($stateProp, $lastMrkState) = $this->setTransUnitState($seg, $stateProp, $lastMrkState);
382 382
                     } else {
383
-                        foreach ( $listOfSegmentsIds as $pos => $id ) {
383
+                        foreach ($listOfSegmentsIds as $pos => $id) {
384 384
 
385 385
                             /*
386 386
                              * This routine works to respect the positional orders of markers.
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
                              * pre-assign zero to the new mrk if this is the first one ( in this segment )
394 394
                              * If it is null leave it NULL
395 395
                              */
396
-                            if ( (int)$this->segments[ $id ][ "mrk_id" ] < 0 && $this->segments[ $id ][ "mrk_id" ] !== null ) {
397
-                                $this->segments[ $id ][ "mrk_id" ] = 0;
396
+                            if ((int)$this->segments[$id]["mrk_id"] < 0 && $this->segments[$id]["mrk_id"] !== null) {
397
+                                $this->segments[$id]["mrk_id"] = 0;
398 398
                             }
399 399
 
400 400
                             /*
@@ -403,65 +403,65 @@  discard block
 block discarded – undo
403 403
                              * ( null <= -1 ) === true
404 404
                              * so, cast to int
405 405
                              */
406
-                            if ( (int)$this->segments[ $id ][ "mrk_id" ] <= $lastMrkId ) {
406
+                            if ((int)$this->segments[$id]["mrk_id"] <= $lastMrkId) {
407 407
                                 break;
408 408
                             }
409 409
 
410 410
                             // set $this->currentSegment
411
-                            $seg = $this->segments[ $id ];
411
+                            $seg = $this->segments[$id];
412 412
 
413 413
                             // update counts
414
-                            if ( !empty( $seg ) ) {
415
-                                $this->updateSegmentCounts( $seg );
414
+                            if (!empty($seg)) {
415
+                                $this->updateSegmentCounts($seg);
416 416
                             }
417 417
 
418 418
                             // delete translations so the prepareSegment
419 419
                             // will put source content in target tag
420
-                            if ( $this->sourceInTarget ) {
421
-                                $seg[ 'translation' ] = '';
420
+                            if ($this->sourceInTarget) {
421
+                                $seg['translation'] = '';
422 422
                                 $this->resetCounts();
423 423
                             }
424 424
 
425 425
                             // append $translation
426
-                            $translation = $this->prepareTranslation( $seg, $translation );
426
+                            $translation = $this->prepareTranslation($seg, $translation);
427 427
 
428 428
                             // for xliff 2 we need $this->transUnits[ $this->currentId ] [ $pos ] for populating metadata
429 429
 
430
-                            unset( $this->transUnits[ $this->currentTransUnitId ] [ $pos ] );
430
+                            unset($this->transUnits[$this->currentTransUnitId] [$pos]);
431 431
 
432
-                            $lastMrkId = $this->segments[ $id ][ "mrk_id" ];
432
+                            $lastMrkId = $this->segments[$id]["mrk_id"];
433 433
 
434
-                            list( $stateProp, $lastMrkState ) = $this->setTransUnitState( $seg, $stateProp, $lastMrkState );
434
+                            list($stateProp, $lastMrkState) = $this->setTransUnitState($seg, $stateProp, $lastMrkState);
435 435
                         }
436 436
                     }
437 437
 
438 438
                     //append translation
439 439
                     $targetLang = '';
440
-                    if ( $this->xliffVersion === 1 ) {
440
+                    if ($this->xliffVersion === 1) {
441 441
                         $targetLang = ' xml:lang="' . $this->targetLang . '"';
442 442
                     }
443 443
 
444
-                    $tag = $this->buildTranslateTag( $targetLang, $stateProp, $translation, $this->counts[ 'raw_word_count' ], $this->counts[ 'eq_word_count' ] );
444
+                    $tag = $this->buildTranslateTag($targetLang, $stateProp, $translation, $this->counts['raw_word_count'], $this->counts['eq_word_count']);
445 445
                 }
446 446
 
447 447
                 // signal we are leaving a target
448 448
                 $this->targetWasWritten = true;
449 449
                 $this->inTarget         = false;
450
-                $this->postProcAndFlush( $this->outputFP, $tag, $treatAsCDATA = true );
451
-            } elseif ( in_array( $name, $this->nodesToCopy ) ) { // we are closing a critical CDATA section
450
+                $this->postProcAndFlush($this->outputFP, $tag, $treatAsCDATA = true);
451
+            } elseif (in_array($name, $this->nodesToCopy)) { // we are closing a critical CDATA section
452 452
 
453 453
                 $this->bufferIsActive = false;
454 454
 
455 455
                 // only for Xliff 2.*
456 456
                 // write here <mda:metaGroup> and <mda:meta> if already present in the <unit>
457
-                if ( 'mda:metadata' === $name && $this->unitContainsMda && $this->xliffVersion === 2 && !$this->hasWrittenCounts ) {
457
+                if ('mda:metadata' === $name && $this->unitContainsMda && $this->xliffVersion === 2 && !$this->hasWrittenCounts) {
458 458
 
459 459
                     // we need to update counts here
460 460
                     $this->updateCounts();
461 461
                     $this->hasWrittenCounts = true;
462 462
 
463 463
                     $tag = $this->CDATABuffer;
464
-                    $tag .= $this->getWordCountGroupForXliffV2( $this->counts[ 'raw_word_count' ], $this->counts[ 'eq_word_count' ], false );
464
+                    $tag .= $this->getWordCountGroupForXliffV2($this->counts['raw_word_count'], $this->counts['eq_word_count'], false);
465 465
                     $tag .= "    </mda:metadata>";
466 466
 
467 467
                 } else {
@@ -471,59 +471,59 @@  discard block
 block discarded – undo
471 471
                 $this->CDATABuffer = "";
472 472
 
473 473
                 //flush to pointer
474
-                $this->postProcAndFlush( $this->outputFP, $tag );
475
-            } elseif ( 'segment' === $name ) {
474
+                $this->postProcAndFlush($this->outputFP, $tag);
475
+            } elseif ('segment' === $name) {
476 476
 
477 477
                 // only for Xliff 2.*
478 478
                 // if segment has no <target> add it BEFORE </segment>
479
-                if ( $this->xliffVersion === 2 && !$this->targetWasWritten ) {
479
+                if ($this->xliffVersion === 2 && !$this->targetWasWritten) {
480 480
 
481 481
                     $seg = $this->getCurrentSegment();
482 482
 
483 483
                     // copy attr from <source>
484 484
                     $tag = '<target';
485
-                    foreach ( $this->sourceAttributes as $k => $v ) {
485
+                    foreach ($this->sourceAttributes as $k => $v) {
486 486
                         $tag .= " $k=\"$v\"";
487 487
                     }
488 488
 
489
-                    $tag .= '>' . $seg[ 'translation' ] . '</target></segment>';
489
+                    $tag .= '>' . $seg['translation'] . '</target></segment>';
490 490
                 }
491 491
 
492
-                $this->postProcAndFlush( $this->outputFP, $tag );
492
+                $this->postProcAndFlush($this->outputFP, $tag);
493 493
 
494 494
                 // we are leaving <segment>, reset $segmentHasTarget
495 495
                 $this->targetWasWritten = false;
496 496
 
497
-            } elseif ( $name === 'trans-unit' ) {
497
+            } elseif ($name === 'trans-unit') {
498 498
 
499 499
                 // only for Xliff 1.*
500 500
                 // handling </trans-unit> closure
501
-                if ( !$this->targetWasWritten ) {
501
+                if (!$this->targetWasWritten) {
502 502
                     $seg          = $this->getCurrentSegment();
503 503
                     $lastMrkState = null;
504 504
                     $stateProp    = '';
505 505
                     $tag          = '';
506 506
 
507 507
                     // if there is translation available insert <target> BEFORE </trans-unit>
508
-                    if ( isset( $seg[ 'translation' ] ) ) {
509
-                        list( $stateProp, $lastMrkState ) = $this->setTransUnitState( $seg, $stateProp, $lastMrkState );
510
-                        $tag .= $this->createTargetTag( $seg[ 'translation' ], $stateProp );
508
+                    if (isset($seg['translation'])) {
509
+                        list($stateProp, $lastMrkState) = $this->setTransUnitState($seg, $stateProp, $lastMrkState);
510
+                        $tag .= $this->createTargetTag($seg['translation'], $stateProp);
511 511
                     }
512 512
 
513 513
                     $tag .= '</trans-unit>';
514
-                    $this->postProcAndFlush( $this->outputFP, $tag );
514
+                    $this->postProcAndFlush($this->outputFP, $tag);
515 515
                 } else {
516
-                    $this->postProcAndFlush( $this->outputFP, '</trans-unit>' );
516
+                    $this->postProcAndFlush($this->outputFP, '</trans-unit>');
517 517
                 }
518
-            } elseif ( $this->bufferIsActive ) { // this is a tag ( <g | <mrk ) inside a seg or seg-source tag
518
+            } elseif ($this->bufferIsActive) { // this is a tag ( <g | <mrk ) inside a seg or seg-source tag
519 519
                 $this->CDATABuffer .= "</$name>";
520 520
                 // Do NOT Flush
521 521
             } else { //generic tag closure do Nothing
522 522
                 // flush to pointer
523
-                $this->postProcAndFlush( $this->outputFP, $tag );
523
+                $this->postProcAndFlush($this->outputFP, $tag);
524 524
             }
525
-        } elseif ( $this->CDATABuffer === '<note/>' && $this->bufferIsActive === true ) {
526
-            $this->postProcAndFlush( $this->outputFP, '<note/>' );
525
+        } elseif ($this->CDATABuffer === '<note/>' && $this->bufferIsActive === true) {
526
+            $this->postProcAndFlush($this->outputFP, '<note/>');
527 527
             $this->bufferIsActive = false;
528 528
             $this->CDATABuffer    = '';
529 529
             $this->isEmpty        = false;
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         }
534 534
 
535 535
         // check if we are leaving a <trans-unit> (xliff v1.*) or <unit> (xliff v2.*)
536
-        if ( $this->tuTagName === $name ) {
536
+        if ($this->tuTagName === $name) {
537 537
             $this->currentTransUnitTranslate = null;
538 538
             $this->inTU                      = false;
539 539
             $this->segmentPositionInTu       = -1;
@@ -548,21 +548,21 @@  discard block
 block discarded – undo
548 548
      *
549 549
      * @param array $listOfSegmentsIds
550 550
      */
551
-    private function setCurrentSegmentArray( array $listOfSegmentsIds = [] ) {
551
+    private function setCurrentSegmentArray(array $listOfSegmentsIds = []) {
552 552
         // $currentSegmentId
553
-        if ( empty( $this->currentSegmentArray ) ) {
553
+        if (empty($this->currentSegmentArray)) {
554 554
             $this->currentSegmentArray = [
555
-                    'sid' => $listOfSegmentsIds[ 0 ],
555
+                    'sid' => $listOfSegmentsIds[0],
556 556
                     'tid' => $this->currentTransUnitId,
557 557
             ];
558 558
         } else {
559
-            if ( $this->currentSegmentArray[ 'tid' ] === $this->currentTransUnitId ) {
560
-                $key                                = array_search( $this->currentSegmentArray[ 'sid' ], $listOfSegmentsIds );
561
-                $this->currentSegmentArray[ 'sid' ] = $listOfSegmentsIds[ $key + 1 ];
562
-                $this->currentSegmentArray[ 'tid' ] = $this->currentTransUnitId;
559
+            if ($this->currentSegmentArray['tid'] === $this->currentTransUnitId) {
560
+                $key                                = array_search($this->currentSegmentArray['sid'], $listOfSegmentsIds);
561
+                $this->currentSegmentArray['sid'] = $listOfSegmentsIds[$key + 1];
562
+                $this->currentSegmentArray['tid'] = $this->currentTransUnitId;
563 563
             } else {
564 564
                 $this->currentSegmentArray = [
565
-                        'sid' => $listOfSegmentsIds[ 0 ],
565
+                        'sid' => $listOfSegmentsIds[0],
566 566
                         'tid' => $this->currentTransUnitId,
567 567
                 ];
568 568
             }
@@ -574,23 +574,23 @@  discard block
 block discarded – undo
574 574
      */
575 575
     private function updateCounts() {
576 576
         // populate counts
577
-        $listOfSegmentsIds = $this->transUnits[ $this->currentTransUnitId ];
577
+        $listOfSegmentsIds = $this->transUnits[$this->currentTransUnitId];
578 578
 
579 579
         // $currentSegmentId
580
-        if ( !empty( $listOfSegmentsIds ) ) {
581
-            $this->setCurrentSegmentArray( $listOfSegmentsIds );
580
+        if (!empty($listOfSegmentsIds)) {
581
+            $this->setCurrentSegmentArray($listOfSegmentsIds);
582 582
         }
583 583
 
584
-        if ( $this->xliffVersion === 2 ) {
585
-            $seg = $this->segments[ $this->currentSegmentArray[ 'sid' ] ];
586
-            if ( !empty( $seg ) ) {
587
-                $this->updateSegmentCounts( $seg );
584
+        if ($this->xliffVersion === 2) {
585
+            $seg = $this->segments[$this->currentSegmentArray['sid']];
586
+            if (!empty($seg)) {
587
+                $this->updateSegmentCounts($seg);
588 588
             }
589 589
         } else {
590
-            foreach ( $listOfSegmentsIds as $pos => $id ) {
591
-                $seg = $this->segments[ $id ];
592
-                if ( !empty( $seg ) ) {
593
-                    $this->updateSegmentCounts( $seg );
590
+            foreach ($listOfSegmentsIds as $pos => $id) {
591
+                $seg = $this->segments[$id];
592
+                if (!empty($seg)) {
593
+                    $this->updateSegmentCounts($seg);
594 594
                 }
595 595
             }
596 596
         }
@@ -601,14 +601,14 @@  discard block
 block discarded – undo
601 601
     /**
602 602
      * @param array $seg
603 603
      */
604
-    private function updateSegmentCounts( array $seg = [] ) {
605
-        $this->counts[ 'raw_word_count' ] += $seg[ 'raw_word_count' ];
606
-        $this->counts[ 'eq_word_count' ]  += ( floor( $seg[ 'eq_word_count' ] * 100 ) / 100 );
604
+    private function updateSegmentCounts(array $seg = []) {
605
+        $this->counts['raw_word_count'] += $seg['raw_word_count'];
606
+        $this->counts['eq_word_count']  += (floor($seg['eq_word_count'] * 100) / 100);
607 607
     }
608 608
 
609 609
     private function resetCounts() {
610
-        $this->counts[ 'raw_word_count' ] = 0;
611
-        $this->counts[ 'eq_word_count' ]  = 0;
610
+        $this->counts['raw_word_count'] = 0;
611
+        $this->counts['eq_word_count']  = 0;
612 612
     }
613 613
 
614 614
     /**
@@ -619,38 +619,38 @@  discard block
 block discarded – undo
619 619
      *
620 620
      * @return string
621 621
      */
622
-    protected function prepareTranslation( $seg, $transUnitTranslation = "" ) {
622
+    protected function prepareTranslation($seg, $transUnitTranslation = "") {
623 623
         $endTags = "";
624 624
 
625
-        $segment     = Strings::removeDangerousChars( $seg [ 'segment' ] );
626
-        $translation = Strings::removeDangerousChars( $seg [ 'translation' ] );
627
-        $dataRefMap  = ( isset( $seg[ 'data_ref_map' ] ) && $seg[ 'data_ref_map' ] !== null ) ? Strings::jsonToArray( $seg[ 'data_ref_map' ] ) : [];
625
+        $segment     = Strings::removeDangerousChars($seg ['segment']);
626
+        $translation = Strings::removeDangerousChars($seg ['translation']);
627
+        $dataRefMap  = (isset($seg['data_ref_map']) && $seg['data_ref_map'] !== null) ? Strings::jsonToArray($seg['data_ref_map']) : [];
628 628
 
629
-        if ( is_null( $seg [ 'translation' ] ) || $seg [ 'translation' ] == '' ) {
629
+        if (is_null($seg ['translation']) || $seg ['translation'] == '') {
630 630
             $translation = $segment;
631 631
         } else {
632
-            if ( $this->callback ) {
632
+            if ($this->callback) {
633 633
                 $error = (isset($seg['error'])) ? $seg['error'] : null;
634
-                if ( $this->callback->thereAreErrors( $seg[ 'sid' ], $segment, $translation, $dataRefMap, $error ) ) {
634
+                if ($this->callback->thereAreErrors($seg['sid'], $segment, $translation, $dataRefMap, $error)) {
635 635
                     $translation = '|||UNTRANSLATED_CONTENT_START|||' . $segment . '|||UNTRANSLATED_CONTENT_END|||';
636 636
                 }
637 637
             }
638 638
         }
639 639
 
640 640
         // for xliff v2 we ignore the marks on purpose
641
-        if ( $this->xliffVersion === 2 ) {
641
+        if ($this->xliffVersion === 2) {
642 642
             return $translation;
643 643
         }
644 644
 
645
-        if ( $seg[ 'mrk_id' ] !== null && $seg[ 'mrk_id' ] != '' ) {
646
-            if ( $this->targetLang === 'ja-JP' ) {
647
-                $seg[ 'mrk_succ_tags' ] = ltrim( $seg[ 'mrk_succ_tags' ] );
645
+        if ($seg['mrk_id'] !== null && $seg['mrk_id'] != '') {
646
+            if ($this->targetLang === 'ja-JP') {
647
+                $seg['mrk_succ_tags'] = ltrim($seg['mrk_succ_tags']);
648 648
             }
649 649
 
650
-            $translation = "<mrk mid=\"" . $seg[ 'mrk_id' ] . "\" mtype=\"seg\">" . $seg[ 'mrk_prev_tags' ] . $translation . $seg[ 'mrk_succ_tags' ] . "</mrk>";
650
+            $translation = "<mrk mid=\"" . $seg['mrk_id'] . "\" mtype=\"seg\">" . $seg['mrk_prev_tags'] . $translation . $seg['mrk_succ_tags'] . "</mrk>";
651 651
         }
652 652
 
653
-        $transUnitTranslation .= $seg[ 'prev_tags' ] . $translation . $endTags . $seg[ 'succ_tags' ];
653
+        $transUnitTranslation .= $seg['prev_tags'] . $translation . $endTags . $seg['succ_tags'];
654 654
 
655 655
         return $transUnitTranslation;
656 656
     }
@@ -664,15 +664,15 @@  discard block
 block discarded – undo
664 664
      *
665 665
      * @return string
666 666
      */
667
-    private function buildTranslateTag( $targetLang, $stateProp, $translation, $rawWordCount, $eqWordCount ) {
668
-        switch ( $this->xliffVersion ) {
667
+    private function buildTranslateTag($targetLang, $stateProp, $translation, $rawWordCount, $eqWordCount) {
668
+        switch ($this->xliffVersion) {
669 669
             case 1:
670 670
             default:
671 671
                 $tag = "<target $targetLang $stateProp>$translation</target>";
672 672
 
673 673
                 // if it's a Trados file don't append count group
674
-                if ( get_class( $this ) !== SdlXliffSAXTranslationReplacer::class ) {
675
-                    $tag .= $this->getWordCountGroup( $rawWordCount, $eqWordCount );
674
+                if (get_class($this) !== SdlXliffSAXTranslationReplacer::class) {
675
+                    $tag .= $this->getWordCountGroup($rawWordCount, $eqWordCount);
676 676
                 }
677 677
 
678 678
                 return $tag;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
      *
689 689
      * @return string
690 690
      */
691
-    private function getWordCountGroup( $raw_word_count, $eq_word_count ) {
691
+    private function getWordCountGroup($raw_word_count, $eq_word_count) {
692 692
         return "\n<count-group name=\"$this->currentTransUnitId\"><count count-type=\"x-matecat-raw\">$raw_word_count</count><count count-type=\"x-matecat-weighted\">$eq_word_count</count></count-group>";
693 693
     }
694 694
 
@@ -696,11 +696,11 @@  discard block
 block discarded – undo
696 696
      * @return array
697 697
      */
698 698
     private function getCurrentSegment() {
699
-        if ( $this->currentTransUnitTranslate === 'yes' && isset( $this->transUnits[ $this->currentTransUnitId ] ) ) {
700
-            $index = $this->transUnits[ $this->currentTransUnitId ][ $this->segmentPositionInTu ];
699
+        if ($this->currentTransUnitTranslate === 'yes' && isset($this->transUnits[$this->currentTransUnitId])) {
700
+            $index = $this->transUnits[$this->currentTransUnitId][$this->segmentPositionInTu];
701 701
 
702
-            if ( isset( $this->segments[ $index ] ) ) {
703
-                return $this->segments[ $index ];
702
+            if (isset($this->segments[$index])) {
703
+                return $this->segments[$index];
704 704
             }
705 705
         }
706 706
 
@@ -715,10 +715,10 @@  discard block
 block discarded – undo
715 715
      *
716 716
      * @return string
717 717
      */
718
-    private function createTargetTag( $translation, $stateProp ) {
718
+    private function createTargetTag($translation, $stateProp) {
719 719
         $targetLang = 'xml:lang="' . $this->targetLang . '"';
720 720
 
721
-        return $this->buildTranslateTag( $targetLang, $stateProp, $translation, $this->counts[ 'raw_word_count' ], $this->counts[ 'eq_word_count' ] );
721
+        return $this->buildTranslateTag($targetLang, $stateProp, $translation, $this->counts['raw_word_count'], $this->counts['eq_word_count']);
722 722
     }
723 723
 
724 724
     /**
@@ -728,11 +728,11 @@  discard block
 block discarded – undo
728 728
      *
729 729
      * @return string
730 730
      */
731
-    private function getWordCountGroupForXliffV2( $raw_word_count, $eq_word_count, $withMetadataTag = true ) {
731
+    private function getWordCountGroupForXliffV2($raw_word_count, $eq_word_count, $withMetadataTag = true) {
732 732
         $this->mdaGroupCounter++;
733 733
         $id = 'word_count_tu_' . $this->mdaGroupCounter;
734 734
 
735
-        if ( $withMetadataTag === false ) {
735
+        if ($withMetadataTag === false) {
736 736
             return "    <mda:metaGroup id=\"" . $id . "\" category=\"row_xml_attribute\">
737 737
                                 <mda:meta type=\"x-matecat-raw\">$raw_word_count</mda:meta>
738 738
                                 <mda:meta type=\"x-matecat-weighted\">$eq_word_count</mda:meta>
@@ -755,19 +755,19 @@  discard block
 block discarded – undo
755 755
      *
756 756
      * @return array
757 757
      */
758
-    private function setTransUnitState( $seg, $state_prop, $lastMrkState ) {
759
-        switch ( $seg[ 'status' ] ) {
758
+    private function setTransUnitState($seg, $state_prop, $lastMrkState) {
759
+        switch ($seg['status']) {
760 760
 
761 761
             case TranslationStatus::STATUS_FIXED:
762 762
             case TranslationStatus::STATUS_APPROVED:
763
-                if ( $lastMrkState == null || $lastMrkState == TranslationStatus::STATUS_APPROVED ) {
764
-                    $state_prop   = ( $this->xliffVersion === 2 ) ? "state=\"reviewed\"" : "state=\"signed-off\"";
763
+                if ($lastMrkState == null || $lastMrkState == TranslationStatus::STATUS_APPROVED) {
764
+                    $state_prop   = ($this->xliffVersion === 2) ? "state=\"reviewed\"" : "state=\"signed-off\"";
765 765
                     $lastMrkState = TranslationStatus::STATUS_APPROVED;
766 766
                 }
767 767
                 break;
768 768
 
769 769
             case TranslationStatus::STATUS_TRANSLATED:
770
-                if ( $lastMrkState == null || $lastMrkState == TranslationStatus::STATUS_TRANSLATED || $lastMrkState == TranslationStatus::STATUS_APPROVED ) {
770
+                if ($lastMrkState == null || $lastMrkState == TranslationStatus::STATUS_TRANSLATED || $lastMrkState == TranslationStatus::STATUS_APPROVED) {
771 771
                     $state_prop   = "state=\"translated\"";
772 772
                     $lastMrkState = TranslationStatus::STATUS_TRANSLATED;
773 773
                 }
@@ -775,15 +775,15 @@  discard block
 block discarded – undo
775 775
 
776 776
             case TranslationStatus::STATUS_REJECTED:  // if there is a mark REJECTED and there is not a DRAFT, all the trans-unit is REJECTED. In V2 there is no way to mark
777 777
             case TranslationStatus::STATUS_REBUTTED:
778
-                if ( ( $lastMrkState == null ) || ( $lastMrkState != TranslationStatus::STATUS_NEW || $lastMrkState != TranslationStatus::STATUS_DRAFT ) ) {
779
-                    $state_prop   = ( $this->xliffVersion === 2 ) ? "state=\"initial\"" : "state=\"needs-review-translation\"";
778
+                if (($lastMrkState == null) || ($lastMrkState != TranslationStatus::STATUS_NEW || $lastMrkState != TranslationStatus::STATUS_DRAFT)) {
779
+                    $state_prop   = ($this->xliffVersion === 2) ? "state=\"initial\"" : "state=\"needs-review-translation\"";
780 780
                     $lastMrkState = TranslationStatus::STATUS_REJECTED;
781 781
                 }
782 782
                 break;
783 783
 
784 784
             case TranslationStatus::STATUS_NEW:
785
-                if ( ( $lastMrkState == null ) || $lastMrkState != TranslationStatus::STATUS_DRAFT ) {
786
-                    $state_prop   = ( $this->xliffVersion === 2 ) ? "state=\"initial\"" : "state=\"new\"";
785
+                if (($lastMrkState == null) || $lastMrkState != TranslationStatus::STATUS_DRAFT) {
786
+                    $state_prop   = ($this->xliffVersion === 2) ? "state=\"initial\"" : "state=\"new\"";
787 787
                     $lastMrkState = TranslationStatus::STATUS_NEW;
788 788
                 }
789 789
                 break;
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
                 // this is the case when a segment is not showed in cattool, so the row in
797 797
                 // segment_translations does not exists and
798 798
                 // ---> $seg[ 'status' ] is NULL
799
-                if ( $lastMrkState == null ) { //this is the first MRK ID
799
+                if ($lastMrkState == null) { //this is the first MRK ID
800 800
                     $state_prop   = "state=\"translated\"";
801 801
                     $lastMrkState = TranslationStatus::STATUS_TRANSLATED;
802 802
                 } else {
@@ -805,17 +805,17 @@  discard block
 block discarded – undo
805 805
                 break;
806 806
         }
807 807
 
808
-        return [ $state_prop, $lastMrkState ];
808
+        return [$state_prop, $lastMrkState];
809 809
     }
810 810
 
811 811
     /**
812 812
      * @inheritDoc
813 813
      */
814
-    protected function characterData( $parser, $data ) {
814
+    protected function characterData($parser, $data) {
815 815
         // don't write <target> data
816
-        if ( !$this->inTarget && !$this->bufferIsActive ) {
817
-            $this->postProcAndFlush( $this->outputFP, $data );
818
-        } elseif ( $this->bufferIsActive ) {
816
+        if (!$this->inTarget && !$this->bufferIsActive) {
817
+            $this->postProcAndFlush($this->outputFP, $data);
818
+        } elseif ($this->bufferIsActive) {
819 819
             $this->CDATABuffer .= $data;
820 820
         }
821 821
     }
Please login to merge, or discard this patch.
src/XliffReplacer/XliffReplacerCallbackInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,5 +11,5 @@
 block discarded – undo
11 11
      * @param null $error
12 12
      * @return bool
13 13
      */
14
-    public function thereAreErrors( $segmentId, $segment, $translation, array $dataRefMap = [], $error = null );
14
+    public function thereAreErrors($segmentId, $segment, $translation, array $dataRefMap = [], $error = null);
15 15
 }
Please login to merge, or discard this patch.
src/Utils/Emoji.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7401,7 +7401,7 @@
 block discarded – undo
7401 7401
             '
Please login to merge, or discard this patch.