Skip to content

Commit

Permalink
fix: install php stan (#26)
Browse files Browse the repository at this point in the history
feat: install php stan to lint code

fix: class NoReturn not exist

fix: no value in iterrable array

dev: set paths in phpstan config file

Before you had to set it by hand every time you wanted to lint the code
  • Loading branch information
Rignchen authored Jun 11, 2024
1 parent 3148fca commit b983d79
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 3 deletions.
4 changes: 3 additions & 1 deletion php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"ext-curl": "*"
},
"require-dev": {
"symfony/var-dumper": "^7.0"
"symfony/var-dumper": "^7.0",
"phpstan/phpstan": "^1.11",
"jetbrains/phpstorm-attributes": "^1.1"
},
"authors": [
{
Expand Down
102 changes: 101 additions & 1 deletion php/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion php/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@
exit;
}

/**
* @param array<string, mixed> $messages
*/
#[NoReturn] function output(array $messages, int $code = 200): void {
header('Content-Type: application/json');
http_response_code($code);
echo json_encode($messages);
exit;
}

/**
* @param array<string, mixed> $data
* @param array<string> $headers
*/
function callAPI(string $method, string $url, array $data = [], array $headers = []): bool|string {
$ch = curl_init();

Expand Down Expand Up @@ -47,4 +55,4 @@ function callAPI(string $method, string $url, array $data = [], array $headers =
curl_close($ch);

return $result;
}
}
6 changes: 6 additions & 0 deletions php/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
level: 6
paths:
- public
- private
- lib.php

0 comments on commit b983d79

Please sign in to comment.