Add format and type checker tools #13

Merged
maxime.batista merged 3 commits from quality into master 1 year ago

This pull request adds and configures phpstan and php-cs-fixer to type check and format php code, and tsc and prettier to type check and format the typescript code.

please use :

  • ./verify.sh to verify if your code is typed correctly
  • ./format.sh to verify if your code is formatted correctly.
This pull request adds and configures phpstan and php-cs-fixer to type check and format php code, and tsc and prettier to type check and format the typescript code. please use : - `./verify.sh` to verify if your code is typed correctly - `./format.sh` to verify if your code is formatted correctly.
maxime.batista requested review from clement.freville2 1 year ago
maxime.batista requested review from yanis.dahmane-bounoua 1 year ago
maxime.batista requested review from vivien.dufour 1 year ago
maxime.batista requested review from mael.daim 1 year ago
maxime.batista requested review from samuel.berion 1 year ago
vivien.dufour approved these changes 1 year ago
clement.freville2 requested changes 1 year ago
return (new PhpCsFixer\Config())
->setRules([
'@PER-CS' => true,
'@PHP82Migration' => true,
-         '@PHP82Migration' => true,
+         '@PHP74Migration' => true,
```diff - '@PHP82Migration' => true, + '@PHP74Migration' => true, ```
maxime.batista marked this conversation as resolved
ci/.drone.yml Outdated
- image: composer:latest
name: "php CI"
commands:
- composer install && composer update
-       - composer install && composer update
+       - composer install

Since there is no lock file committed, there is no need update it.

```diff - - composer install && composer update + - composer install ``` Since there is no lock file committed, there is no need update it.
maxime.batista marked this conversation as resolved
package.json Outdated
"test": "vite test"
"test": "vite test",
"format": "prettier --config .prettierrc 'front' --write",
"tsc": "node_modules/.bin/tsc"
-    "tsc": "node_modules/.bin/tsc" 
+    "tsc": "tsc" 

The binary is already in the PATH.

```diff - "tsc": "node_modules/.bin/tsc" + "tsc": "tsc" ``` The binary is already in the `PATH`.
maxime.batista marked this conversation as resolved
phpstan.neon Outdated
paths:
- src
- public
- sql
-         - sql

SQL files are not read and you ignore errors in the only PHP file.

```diff - - sql ``` SQL files are not read and you ignore errors in the only PHP file.
maxime.batista marked this conversation as resolved
phpstan.neon Outdated
ignoreErrors:
-
message: '#.*#'
path: sql/database.php
-         -
-            message: '#.*#'
-            path: sql/database.php
+    scanFiles:
+      - config.php
+      - profiles/dev-config-profile.php
```diff - - - message: '#.*#' - path: sql/database.php + scanFiles: + - config.php + - profiles/dev-config-profile.php ```
maxime.batista marked this conversation as resolved
phpstan.neon Outdated
path: sql/database.php
-
message: '#.*#'
path: src/react-display-file.php
-         -
-             message: '#.*#'
-             path: src/react-display-file.php
+    excludePaths:
+      - src/react-display-file.php
```diff - - - message: '#.*#' - path: src/react-display-file.php + excludePaths: + - src/react-display-file.php ```
maxime.batista marked this conversation as resolved
* execute a request
* @param string $query
* @param array $args
* @param array<string, array<mixed, int>> $args
-      * @param array<string, array<mixed, int>> $args 
+      * @param array<string, array{mixed, int}> $args 

It is a tuple, not a array with mixed keys and numeric values.

```diff - * @param array<string, array<mixed, int>> $args + * @param array<string, array{mixed, int}> $args ``` It is a tuple, not a array with mixed keys and numeric values.
maxime.batista marked this conversation as resolved
* @param string $query the SQL request
* @param array $args an array containing the arguments label, value and type: ex: `[":label" => [$value, PDO::PARAM_TYPE]`
* @return array the returned rows of the request
* @param array<string, array<mixed, int>> $args an array containing the arguments label, value and type: ex: `[":label" => [$value, PDO::PARAM_TYPE]`
-      * @param array<string, array<mixed, int>> $args an array containing the arguments label, value and type: ex: `[":label" => [$value, PDO::PARAM_TYPE]` 
+      * @param array<string, array{mixed, int}> $args an array containing the arguments label, value and type: ex: `[":label" => [$value, PDO::PARAM_TYPE]` 
```diff - * @param array<string, array<mixed, int>> $args an array containing the arguments label, value and type: ex: `[":label" => [$value, PDO::PARAM_TYPE]` + * @param array<string, array{mixed, int}> $args an array containing the arguments label, value and type: ex: `[":label" => [$value, PDO::PARAM_TYPE]` ```
maxime.batista marked this conversation as resolved
* @param string $email
* @param string $phoneNumber
* @param AccountUser $user
* @param array<int, Team> $teams
-      * @param array<int, Team> $teams
+      * @param Team[] $teams
```diff - * @param array<int, Team> $teams + * @param Team[] $teams ```
maxime.batista marked this conversation as resolved
/**
* @var array maps users with their role
* @var array<int, Member> maps users with their role
-      * @var array<int, Member> maps users with their role 
+      * @var Member[] maps users with their role 
```diff - * @var array<int, Member> maps users with their role + * @var Member[] maps users with their role ```
maxime.batista marked this conversation as resolved
function listResults(): array {
/**
* @return array<string, mixed>
-     * @return array<string, mixed>
+     * @return array{'name': string, 'description': string}[]

The gateway return an array of arrays. The inner array shape is described here.

```diff - * @return array<string, mixed> + * @return array{'name': string, 'description': string}[] ``` The gateway return an array of arrays. The inner array shape is described here.
maxime.batista marked this conversation as resolved
/**
* @param $offset
* @param $value
* @return mixed
-     * @return mixed
+     * @return never
```diff - * @return mixed + * @return never ```
maxime.batista marked this conversation as resolved
}
/**
* @param $offset
+     * @return never
```diff + * @return never ```
maxime.batista marked this conversation as resolved
class FunctionValidator extends Validator {
/**
* @var callable
-     * @var callable
+     * @var callable(string, mixed): ValidationFail[]
```diff - * @var callable + * @var callable(string, mixed): ValidationFail[] ```
maxime.batista marked this conversation as resolved
class SimpleFunctionValidator extends Validator {
/**
* @var callable
-     * @var callable
+     * @var callable(string): bool

Some code below also use the generic callable type in the docs.

```diff - * @var callable + * @var callable(string): bool ``` Some code below also use the generic `callable` type in the docs.
maxime.batista marked this conversation as resolved
* @return Validator a validator that validates strings that only contains numbers, letters, accents letters, `-` and `_`.
*/
public static function name($msg = null): Validator {
public static function name(string $msg = null): Validator {
-    public static function regex(string $regex, string $msg = null): Validator {
+    public static function regex(string $regex, ?string $msg = null): Validator {
```diff - public static function regex(string $regex, string $msg = null): Validator { + public static function regex(string $regex, ?string $msg = null): Validator { ```
maxime.batista marked this conversation as resolved
maxime.batista force-pushed quality from 085136e9ed to bb53114d78 1 year ago
maxime.batista merged commit e22cb91ba2 into master 1 year ago
maxime.batista deleted branch quality 1 year ago

Reviewers

samuel.berion was requested for review 1 year ago
yanis.dahmane-bounoua was requested for review 1 year ago
mael.daim was requested for review 1 year ago
vivien.dufour approved these changes 1 year ago
clement.freville2 requested changes 1 year ago
continuous-integration/drone/push Build is passing
The pull request has been merged as e22cb91ba2.
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: IQBall/Application-Web#13
Loading…
There is no content yet.