-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding some of the most common php tooling (#757)
* phpunit for running unittests * paratest for running the same unitests in parallel * php-cs-fixer for enforcing formatting. php-cs-fixer could be considered to be promoted to being a linter as soon as I work out how to parse its output and feed it through a post-processor like phpstan is. --------- Co-authored-by: Tyler Jang <[email protected]>
- Loading branch information
1 parent
b447900
commit f228f49
Showing
17 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { linterFmtTest } from "tests"; | ||
import { skipOS } from "tests/utils"; | ||
|
||
linterFmtTest({ | ||
linterName: "php-cs-fixer", | ||
skipTestIf: skipOS(["win32"]), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: 0.1 | ||
tools: | ||
definitions: | ||
- name: php-cs-fixer | ||
runtime: php | ||
package: friendsofphp/php-cs-fixer | ||
known_good_version: 3.54.0 | ||
shims: [php-cs-fixer] | ||
environment: | ||
- name: PATH | ||
list: ["${tool}/vendor/bin"] | ||
health_checks: | ||
- command: php-cs-fixer --version | ||
parse_regex: PHP CS Fixer ${semver} | ||
lint: | ||
definitions: | ||
- name: php-cs-fixer | ||
description: Keeps PHP code up to standards | ||
tools: [php-cs-fixer] | ||
known_good_version: 3.54.0 | ||
files: [php] | ||
commands: | ||
# TODO(Tyler): Do we want to define a lint command here? | ||
- name: format | ||
output: rewrite | ||
success_codes: [0] | ||
formatter: true | ||
batch: true | ||
in_place: true | ||
run: php-cs-fixer fix --using-cache=no --show-progress=none ${target} | ||
direct_configs: | ||
# uses ruleset @PSR12 when a config is not present. | ||
- .php-cs-fixer.dist.php | ||
affects_cache: | ||
- .php-cs-fixer.php | ||
suggest_if: config_present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
class HelloWorld | ||
{ | ||
private $b; | ||
|
||
private $a; | ||
|
||
|
||
public function sayHello(DateTimeImutable $date): void | ||
{ | ||
$c=(ARRAY)array(1,2); | ||
echo 'Hello, ' . $date->format('j. n. Y'); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
linters/php-cs-fixer/test_data/php_cs_fixer_v3.54.0_basic.fmt.shot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Testing formatter php-cs-fixer test basic 1`] = ` | ||
"<?php | ||
|
||
declare(strict_types=1); | ||
|
||
class HelloWorld | ||
{ | ||
private $b; | ||
|
||
private $a; | ||
|
||
|
||
public function sayHello(DateTimeImutable $date): void | ||
{ | ||
$c = (array)array(1,2); | ||
echo 'Hello, ' . $date->format('j. n. Y'); | ||
} | ||
} | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { toolInstallTest } from "tests"; | ||
import { skipOS } from "tests/utils"; | ||
|
||
toolInstallTest({ | ||
toolName: "paratest", | ||
toolVersion: "7.4.3", | ||
skipTestIf: skipOS(["win32"]), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 0.1 | ||
tools: | ||
definitions: | ||
- name: paratest | ||
runtime: php | ||
package: brianium/paratest | ||
known_good_version: 7.4.3 | ||
shims: [paratest] | ||
environment: | ||
- name: PATH | ||
list: ["${tool}/vendor/bin"] | ||
health_checks: | ||
- command: paratest --version | ||
parse_regex: ParaTest v${semver} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { toolInstallTest } from "tests"; | ||
import { skipOS } from "tests/utils"; | ||
|
||
toolInstallTest({ | ||
toolName: "phpunit", | ||
toolVersion: "11.1.3", | ||
skipTestIf: skipOS(["win32"]), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 0.1 | ||
tools: | ||
definitions: | ||
- name: phpunit | ||
runtime: php | ||
package: phpunit/phpunit | ||
known_good_version: 11.1.3 | ||
shims: [phpunit] | ||
environment: | ||
- name: PATH | ||
list: ["${tool}/vendor/bin"] | ||
health_checks: | ||
- command: phpunit --version | ||
parse_regex: PHPUnit ${semver} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters