Skip to content
Permalink
Browse files

Merge pull request #117 from tarlepp/type-coverage

Type coverage
  • Loading branch information...
tarlepp committed Jul 14, 2019
2 parents 6583ef4 + 87c9cc7 commit b073de12e81b7673ae3a4eb0f9f8c3adde30050f
Showing with 133 additions and 971 deletions.
  1. +1 −1 Makefile
  2. +1 −1 psalm.xml
  3. +2 −1 src/Entity/LogLogin.php
  4. +5 −4 src/Entity/Traits/LogRequestProcessRequestTrait.php
  5. +4 −11 src/Entity/Traits/UserRelations.php
  6. +1 −1 src/Entity/User.php
  7. +1 −0 src/EventSubscriber/LockedUserSubscriber.php
  8. +1 −0 src/EventSubscriber/RequestSubscriber.php
  9. +5 −1 src/EventSubscriber/ResponseSubscriber.php
  10. +0 −328 src/Maker/RestApiMaker.php
  11. +3 −3 src/Repository/BaseRepositoryInterface.php
  12. +5 −4 src/Repository/Traits/RepositoryMethodsTrait.php
  13. +1 −1 src/Repository/Traits/RepositoryWrappersTrait.php
  14. +2 −2 src/Request/ParamConverter/RestResourceConverter.php
  15. +8 −8 src/Rest/RepositoryHelper.php
  16. +1 −1 src/Rest/RepositoryInterface.php
  17. +4 −4 src/Rest/RequestHandler.php
  18. +5 −1 src/Rest/ResponseHandler.php
  19. +1 −1 src/Rest/RestResource.php
  20. +1 −1 src/Rest/RestResourceInterface.php
  21. +6 −2 src/Rest/SearchTerm.php
  22. +2 −2 src/Rest/Traits/Actions/RestActionBase.php
  23. +3 −1 src/Rest/Traits/RestResourceBaseMethods.php
  24. +6 −1 src/Serializer/Normalizer/CollectionNormalizer.php
  25. +4 −0 src/Utils/JSON.php
  26. +5 −1 src/Utils/Tests/Auth.php
  27. +10 −6 src/Utils/Tests/PhpUnitUtil.php
  28. +8 −3 src/Utils/Tests/RestIntegrationControllerTestCase.php
  29. +5 −2 src/Utils/Tests/RestTraitTestCase.php
  30. +17 −8 src/Validator/Constraints/EntityReferenceExistsValidator.php
  31. +3 −1 src/Validator/Constraints/UniqueEmailValidator.php
  32. +3 −1 src/Validator/Constraints/UniqueUsernameValidator.php
  33. +0 −52 templates/skeleton/rest-api/Controller.tpl.php
  34. +0 −38 templates/skeleton/rest-api/ControllerTestFunctional.tpl.php
  35. +0 −31 templates/skeleton/rest-api/ControllerTestIntegration.tpl.php
  36. +0 −61 templates/skeleton/rest-api/Dto.tpl.php
  37. +0 −34 templates/skeleton/rest-api/DtoTestIntegration.tpl.php
  38. +0 −66 templates/skeleton/rest-api/Entity.tpl.php
  39. +0 −24 templates/skeleton/rest-api/EntityTestIntegration.tpl.php
  40. +0 −35 templates/skeleton/rest-api/Repository.tpl.php
  41. +0 −44 templates/skeleton/rest-api/RepositoryTestIntegration.tpl.php
  42. +0 −51 templates/skeleton/rest-api/Resource.tpl.php
  43. +0 −25 templates/skeleton/rest-api/ResourceTestIntegration.tpl.php
  44. +0 −100 tests/Functional/Maker/RestApiMakerTest.php
  45. +1 −1 vendor-bin/psalm/composer.json
  46. +8 −7 vendor-bin/psalm/composer.lock
@@ -183,7 +183,7 @@ phpinsights: ## Runs PHP Insights
psalm: ## Runs Psalm static analysis tool
@echo "\033[32mRunning Psalm - A static analysis tool for PHP\033[39m"
@php ./vendor/bin/psalm --version
@php ./vendor/bin/psalm --no-cache --shepherd --stats --report=./build/psalm.json
@php ./vendor/bin/psalm --no-cache --shepherd --report=./build/psalm.json
###< psalm ###

###> phpstan ###
@@ -11,7 +11,7 @@

<ignoreFiles>
<directory name="vendor" />
<directory name="src/Utils/Tests" />

<file name="src/Kernel.php" />
</ignoreFiles>
</projectFiles>
@@ -465,8 +465,9 @@ private function processClientData(): void
*/
private function getClientData(string $method, string $attribute): string
{
/** @var string|array $value */
$value = $this->deviceDetector->{$method}($attribute);
return is_array($value) ? implode(', ', $value) : $value;
return is_array($value) ? implode(', ', $value) : (string)$value;
}
}
@@ -470,7 +470,7 @@ private function processRequestBaseInfo(Request $request): void
$this->path = $request->getPathInfo();
$this->queryString = $request->getRequestUri();
$this->uri = $request->getUri();
$this->controller = $request->get('_controller', '');
$this->controller = (string)$request->get('_controller', '');
$this->contentType = strval($request->getMimeType($request->getContentType() ?? ''));
$this->contentTypeShort = (string)$request->getContentType();
$this->xmlHttpRequest = $request->isXmlHttpRequest();
@@ -483,7 +483,7 @@ private function processRequestBaseInfo(Request $request): void
*/
private function determineAction(Request $request): string
{
$rawAction = $request->get('_controller', '');
$rawAction = (string)$request->get('_controller', '');
$rawAction = explode(strpos($rawAction, '::') ? '::' : ':', $rawAction);
return $rawAction[1] ?? '';
@@ -509,6 +509,7 @@ private function determineParameters(Request $request): array
if ($rawContent) {
// First try to convert content to array from JSON
try {
/** @var array<string, mixed> $output */
$output = JSON::decode($rawContent, true);
} /** @noinspection BadExceptionsProcessingInspection */ catch (LogicException $error) {
// Oh noes content isn't JSON so just parse it
@@ -573,11 +574,11 @@ private function cleanContent(string $inputContent): string
$inputContent = (string)preg_replace(
'/(' . $search . '":)\s*"(.*)"/',
'$1"*** REPLACED ***"',
$inputContent
(string)$inputContent
);
};
static $replacements = [
$replacements = [
'password',
'token',
'authorization',
@@ -120,18 +120,11 @@ public function setRolesService(RolesServiceInterface $rolesService): User
*/
public function getRoles(): array
{
/**
* Lambda iterator to get user group role information.
*
* @param UserGroup $userGroup
*
* @return string
*/
$iterator = static function (UserGroup $userGroup): string {
return $userGroup->getRole()->getId();
};
// Determine base roles
/** @var array<int, string> $output */
$output = $this->userGroups->map($iterator)->toArray();
// And if we have roles service present we can fetch all inherited roles
@@ -155,7 +148,7 @@ public function getUserGroups(): Collection
/**
* Getter for user request log collection.
*
* @return Collection|ArrayCollection|mixed|Collection<int, LogRequest>|ArrayCollection<int, LogRequest>
* @return Collection|ArrayCollection|Collection<int, LogRequest>|ArrayCollection<int, LogRequest>
*/
public function getLogsRequest()
{
@@ -165,7 +158,7 @@ public function getLogsRequest()
/**
* Getter for user login log collection.
*
* @return Collection|ArrayCollection|mixed|Collection<int, LogLogin>|ArrayCollection<int, LogLogin>
* @return Collection|ArrayCollection|Collection<int, LogLogin>|ArrayCollection<int, LogLogin>
*/
public function getLogsLogin()
{
@@ -175,7 +168,7 @@ public function getLogsLogin()
/**
* Getter for user login failure log collection.
*
* @return Collection|ArrayCollection|mixed|Collection<int, LogLoginFailure>|ArrayCollection<int, LogLoginFailure>
* @return Collection|ArrayCollection|Collection<int, LogLoginFailure>|ArrayCollection<int, LogLoginFailure>
*/
public function getLogsLoginFailure()
{
@@ -284,7 +284,7 @@ public function getPassword(): string
*/
public function setPassword(callable $encoder, string $plainPassword): self
{
$this->password = $encoder($plainPassword);
$this->password = (string)$encoder($plainPassword);
return $this;
}
@@ -90,6 +90,7 @@ public static function getSubscribedEvents(): array
*/
public function onAuthenticationSuccess(AuthenticationSuccessEvent $event): void
{
/** @var User|null $user */
$user = $this->getUser($event->getUser());
if ($user === null) {
@@ -116,6 +116,7 @@ private function process(FilterResponseEvent $event): void
$this->logger->setRequest($request);
$this->logger->setResponse($event->getResponse());
/** @var ApplicationUser|ApiKeyUser|null $user */
$user = $this->getUser();
if ($user instanceof ApplicationUser) {
@@ -9,6 +9,7 @@
namespace App\EventSubscriber;
use App\Utils\JSON;
use stdClass;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -70,6 +71,9 @@ public function onKernelResponse(FilterResponseEvent $event): void
*/
private function getApiVersion(): string
{
return JSON::decode((string)file_get_contents(__DIR__ . '/../../composer.json'))->version ?? 'unknown';
/** @var stdClass $data */
$data = JSON::decode((string)file_get_contents(__DIR__ . '/../../composer.json'));
return property_exists($data, 'version') ? (string)$data->version : 'unknown';
}
}

0 comments on commit b073de1

Please sign in to comment.
You can’t perform that action at this time.