Skip to content

Commit a404521

Browse files
committed
add cs rule for Entity
1 parent a0222e0 commit a404521

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/code-checker.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* This file is part of the Nette Framework (https://nette.org)
77
*/
88

9-
use Nette\Utils\Strings;
109
use Nette\CommandLine\Parser;
10+
use Nette\Utils\Strings;
1111

1212
if (@!include __DIR__ . '/../vendor/autoload.php') {
1313
echo('Install packages using `composer update`');
@@ -374,6 +374,23 @@ public function is($extensions)
374374
}
375375
};
376376

377+
// cs, entity
378+
$checker->tasks[] = function (CodeChecker $checker, $s) {
379+
if ($checker->is('php')) {
380+
if (Strings::contains($s, '@ORM\Entity') && !Strings::contains($s, '@ORM\Entity(')) {
381+
$checker->fix('Missing Entity`()`');
382+
$s = str_replace('@ORM\Entity', '@ORM\Entity()', $s);
383+
}
384+
385+
if (Strings::contains($s, '@ORM\Table()')) {
386+
$checker->fix('Missing `name="table_name"`');
387+
$s = str_replace('@ORM\Table()', '@ORM\Table(name="")', $s);
388+
}
389+
390+
return $s;
391+
}
392+
};
393+
377394
$ok = $checker->run($options['-d']);
378395

379396
exit($ok ? 0 : 1);

0 commit comments

Comments
 (0)