Skip to content

Commit 6de83b5

Browse files
committed
add code sniffer
Signed-off-by: rahul <[email protected]>
1 parent e9ea484 commit 6de83b5

File tree

4 files changed

+139
-48
lines changed

4 files changed

+139
-48
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"php": ">=8.1"
2020
},
2121
"require-dev": {
22-
"phpunit/phpunit": "^10.3"
22+
"phpunit/phpunit": "^10.3",
23+
"squizlabs/php_codesniffer": "^3.7"
2324
}
2425
}

composer.lock

Lines changed: 103 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHP_CodeSniffer">
3+
<description>Coding standard for file handler library</description>
4+
<file>src</file>
5+
<file>tests</file>
6+
7+
<exclude-pattern>*/migrations/*</exclude-pattern>
8+
<arg value="np"/>
9+
<arg name="basepath" value="."/>
10+
<arg name="colors"/>
11+
<arg name="parallel" value="75"/>
12+
<arg value="np"/>
13+
<rule ref="PSR12"/>
14+
<rule ref="Generic.PHP.ForbiddenFunctions">
15+
<properties>
16+
<property name="forbiddenFunctions" type="array">
17+
<element key="sizeof" value="count"/>
18+
<element key="delete" value="unset"/>
19+
<element key="print" value="echo"/>
20+
<element key="is_null" value="null"/>
21+
<element key="create_function" value="null"/>
22+
<element key="var_dump" value="null"/>
23+
<element key="dd" value="null"/>
24+
<element key="var_export" value="null"/>
25+
<element key="print_r" value="null"/>
26+
<element key="die" value="null"/>
27+
28+
</property>
29+
</properties>
30+
</rule>
31+
32+
</ruleset>

src/FileHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private function getRows(): Generator
7979
}
8080

8181

82-
private function search(string $keyword, string $column, string|null $format): bool
82+
private function search(string $keyword, string $column, string|null $format): bool|array
8383
{
8484
foreach ($this->getRows() as $row) {
8585
if ($keyword === $row[$column]) {
@@ -88,5 +88,4 @@ private function search(string $keyword, string $column, string|null $format): b
8888
}
8989
return false;
9090
}
91-
92-
}
91+
}

0 commit comments

Comments
 (0)