mirror of
https://github.com/filegator/filegator.git
synced 2025-08-04 13:47:32 +02:00
phpstan & refactoring
This commit is contained in:
@@ -12,6 +12,7 @@ before_script:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit --coverage-clover=coverage.xml
|
- vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||||
|
- composer phpstan
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
@@ -62,9 +62,10 @@ npm run serve
|
|||||||
Once everything is ready visit: ```http://localhost:8080```
|
Once everything is ready visit: ```http://localhost:8080```
|
||||||
|
|
||||||
|
|
||||||
### Run tests
|
### Run tests & static analysis
|
||||||
```
|
```
|
||||||
vendor/bin/phpunit
|
vendor/bin/phpunit
|
||||||
|
composer phpstan
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deployment
|
### Deployment
|
||||||
|
@@ -67,6 +67,10 @@ class AuthController
|
|||||||
return $response->json($errors->firstOfAll(), 422);
|
return $response->json($errors->firstOfAll(), 422);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($auth->user() === null) {
|
||||||
|
return $response->json(['oldpassword' => 'Wrong password'], 422);
|
||||||
|
}
|
||||||
|
|
||||||
if (! $auth->authenticate($auth->user()->getUsername(), $request->input('oldpassword'))) {
|
if (! $auth->authenticate($auth->user()->getUsername(), $request->input('oldpassword'))) {
|
||||||
return $response->json(['oldpassword' => 'Wrong password'], 422);
|
return $response->json(['oldpassword' => 'Wrong password'], 422);
|
||||||
}
|
}
|
||||||
|
@@ -101,7 +101,7 @@ class Database implements Service, AuthInterface
|
|||||||
], 'WHERE username = ?', $username);
|
], 'WHERE username = ?', $username);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->find($user->getUsername());
|
return $this->find($user->getUsername()) ?: $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add(User $user, $password): User
|
public function add(User $user, $password): User
|
||||||
@@ -119,7 +119,7 @@ class Database implements Service, AuthInterface
|
|||||||
'password' => $this->hashPassword($password),
|
'password' => $this->hashPassword($password),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->find($user->getUsername());
|
return $this->find($user->getUsername()) ?: $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(User $user)
|
public function delete(User $user)
|
||||||
|
@@ -96,7 +96,7 @@ class JsonFile implements Service, AuthInterface
|
|||||||
|
|
||||||
$this->saveUsers($all_users);
|
$this->saveUsers($all_users);
|
||||||
|
|
||||||
return $this->find($user->getUsername());
|
return $this->find($user->getUsername()) ?: $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ class JsonFile implements Service, AuthInterface
|
|||||||
|
|
||||||
$this->saveUsers($all_users);
|
$this->saveUsers($all_users);
|
||||||
|
|
||||||
return $this->find($user->getUsername());
|
return $this->find($user->getUsername()) ?: $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(User $user)
|
public function delete(User $user)
|
||||||
|
@@ -55,7 +55,11 @@ class SessionStorage implements Service, SessionStorageInterface
|
|||||||
|
|
||||||
public function invalidate()
|
public function invalidate()
|
||||||
{
|
{
|
||||||
if ($this->getSession() !== null || ! $this->getSession()->isStarted()) {
|
if ($this->getSession() === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->getSession()->isStarted()) {
|
||||||
$this->getSession()->start();
|
$this->getSession()->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -282,6 +282,6 @@ class Filesystem implements Service
|
|||||||
|
|
||||||
$tmp = explode($this->separator, trim($path, $this->separator));
|
$tmp = explode($this->separator, trim($path, $this->separator));
|
||||||
|
|
||||||
return array_pop($tmp);
|
return (string) array_pop($tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,5 +36,8 @@
|
|||||||
"symfony/var-dumper": "^4.2",
|
"symfony/var-dumper": "^4.2",
|
||||||
"league/flysystem-memory": "^1.0",
|
"league/flysystem-memory": "^1.0",
|
||||||
"phpstan/phpstan": "^0.11.8"
|
"phpstan/phpstan": "^0.11.8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"phpstan": "phpstan analyse ./backend --level=7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user