Skip to content

Commit c73711c

Browse files
committed
build: Cleanup and improve .phpcs.xml
Use /* at the end of exclude-pattern when excluding the whole folder, see Id95236edbd3d87f57719d235c7c9cee366180099 for explaination Fix issue in no longer excluded file Change-Id: I131713568f7c2d13372ea9e0f5f7798b9b1ca38d
1 parent 553cbcc commit c73711c

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

.phpcs.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<file>.</file>
1111
<arg name="encoding" value="UTF-8"/>
1212
<arg name="extensions" value="php"/>
13-
<exclude-pattern>LM</exclude-pattern>
14-
<exclude-pattern>coverage</exclude-pattern>
15-
<exclude-pattern>vendor</exclude-pattern>
16-
<exclude-pattern>doc/html</exclude-pattern>
13+
<exclude-pattern type="relative">^LM/*</exclude-pattern>
14+
<exclude-pattern type="relative">^doc/html/*</exclude-pattern>
1715
</ruleset>

lm2php.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
* Convert data from Perl's TextCat LM format to PHP format
44
* used by this tool.
55
*/
6-
require_once __DIR__.'/vendor/autoload.php';
6+
require_once __DIR__ . '/vendor/autoload.php';
77

8-
if($argc != 3) {
9-
die("Use $argv[0] INPUTDIR OUTPUTDIR\n");
8+
if ( $argc != 3 ) {
9+
die( "Use $argv[0] INPUTDIR OUTPUTDIR\n" );
1010
}
11-
if(!file_exists($argv[2])) {
12-
mkdir($argv[2], 0755, true);
11+
if ( !file_exists( $argv[2] ) ) {
12+
mkdir( $argv[2], 0755, true );
1313
}
14-
$cat = new TextCat($argv[2]);
14+
$cat = new TextCat( $argv[2] );
1515

16-
foreach(new DirectoryIterator($argv[1]) as $file) {
17-
if(!$file->isFile()) {
16+
foreach ( new DirectoryIterator( $argv[1] ) as $file ) {
17+
if ( !$file->isFile() ) {
1818
continue;
1919
}
20-
$ngrams = array();
21-
foreach(file($file->getPathname(), FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES) as $line) {
22-
list($word, $score) = explode("\t", $line, 2);
23-
$ngrams[$word] = intval($score);
20+
$ngrams = [];
21+
foreach ( file( $file->getPathname(), FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) as $line ) {
22+
list( $word, $score ) = explode( "\t", $line, 2 );
23+
$ngrams[$word] = intval( $score );
2424
}
25-
$cat->writeLanguageFile($ngrams, $argv[2] . "/" . $file->getBasename());
25+
$cat->writeLanguageFile( $ngrams, $argv[2] . "/" . $file->getBasename() );
2626
}
27-
exit(0);
27+
exit( 0 );

0 commit comments

Comments
 (0)