-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoboFile.php
109 lines (97 loc) · 2.61 KB
/
RoboFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
declare(strict_types=1);
use Robo\Collection\CollectionBuilder;
use Robo\Symfony\ConsoleIO;
use Robo\Task\Base\Exec;
use Robo\Task\Composer\Install;
use Robo\Task\Testing\PHPUnit;
use Robo\Tasks;
/**
* This is project's console commands configuration for Robo task runner.
*
* @see https://robo.li/
*/
class RoboFile extends Tasks
{
public function csTest(): Exec|CollectionBuilder
{
return $this->taskPhp()
->env('PHP_CS_FIXER_IGNORE_ENV', '1')
->args([
'vendor/bin/php-cs-fixer',
'fix',
'--dry-run',
'--diff',
]
);
}
public function psalmTest(): Exec|CollectionBuilder
{
if (isset($_SERVER['TERMINAL_EMULATOR'])) {
return $this->taskPhp()
->args([
'vendor/bin/psalm',
'--show-info=true',
'--no-cache',
'--output-format=phpstorm',
]
);
}
return $this->taskPhp()
->args([
'vendor/bin/psalm',
'--show-info=true',
'--no-cache',
]
);
}
public function psalmBaseline(): Exec|CollectionBuilder
{
return $this->taskPhp()
->args([
'vendor/bin/psalm',
'--set-baseline=psalm-baseline.xml',
]);
}
public function phpunitTest(): PHPUnit|CollectionBuilder
{
return $this->taskPhpUnit();
}
public function appTest(ConsoleIO $io): CollectionBuilder
{
return $this->collectionBuilder($io)
->addTask($this->csTest())
->addTask($this->psalmTest())
->addTask($this->csSniff())
->addTask($this->phpunitTest());
}
public function csSniff(): Exec|CollectionBuilder
{
return $this->taskPhp()
->args([
'vendor/bin/phpcs',
'--standard=PSR12',
'src',
]);
}
public function csFix(): Exec|CollectionBuilder
{
return $this->taskPhp()
->env('PHP_CS_FIXER_IGNORE_ENV', '1')
->args(
[
'vendor/bin/php-cs-fixer',
'fix',
]
);
}
public function appVendor(): Install|CollectionBuilder
{
return $this->taskComposerInstall()
->optimizeAutoloader();
}
private function taskPhp(string $php = 'php'): Exec|CollectionBuilder
{
return $this->taskExec($php);
}
}