phpstan improvements (#3092)

This commit is contained in:
Kevin Papst
2022-01-23 15:49:38 +01:00
committed by GitHub
parent 9047e9e785
commit 9e320674c1
42 changed files with 124 additions and 118 deletions

View File

@@ -51,6 +51,9 @@ jobs:
- name: Validate Composer - name: Validate Composer
run: composer validate --strict run: composer validate --strict
- name: Warmup cache for PHPStan
run: APP_ENV=dev bin/console kimai:reload -n
- name: Check codestyles - name: Check codestyles
run: vendor/bin/php-cs-fixer fix --dry-run --verbose --config=.php-cs-fixer.dist.php --using-cache=no --show-progress=none --format=checkstyle | cs2pr run: vendor/bin/php-cs-fixer fix --dry-run --verbose --config=.php-cs-fixer.dist.php --using-cache=no --show-progress=none --format=checkstyle | cs2pr

View File

@@ -79,7 +79,7 @@
"doctrine/doctrine-fixtures-bundle": "^3.2", "doctrine/doctrine-fixtures-bundle": "^3.2",
"fakerphp/faker": "^1.15", "fakerphp/faker": "^1.15",
"friendsofphp/php-cs-fixer": "3.2.*", "friendsofphp/php-cs-fixer": "3.2.*",
"phpstan/phpstan": "1.4.0", "phpstan/phpstan": "^1.0",
"phpstan/phpstan-doctrine": "^1.0", "phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0", "phpstan/phpstan-symfony": "^1.0",

34
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3e985073360a85ce7e4f13f550b1da94", "content-hash": "5dde0b8628ebb8a37360ca2726f224df",
"packages": [ "packages": [
{ {
"name": "beberlei/doctrineextensions", "name": "beberlei/doctrineextensions",
@@ -11778,16 +11778,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.4.0", "version": "1.4.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "72b04d97b5e6e60a081f17c416fef35bd521120b" "reference": "1dd8f3e40bf7aa30031a75c65cece99220a161b8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/72b04d97b5e6e60a081f17c416fef35bd521120b", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1dd8f3e40bf7aa30031a75c65cece99220a161b8",
"reference": "72b04d97b5e6e60a081f17c416fef35bd521120b", "reference": "1dd8f3e40bf7aa30031a75c65cece99220a161b8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -11818,7 +11818,7 @@
"description": "PHPStan - PHP Static Analysis Tool", "description": "PHPStan - PHP Static Analysis Tool",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan/issues", "issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.4.0" "source": "https://github.com/phpstan/phpstan/tree/1.4.2"
}, },
"funding": [ "funding": [
{ {
@@ -11838,25 +11838,25 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-01-14T15:58:47+00:00" "time": "2022-01-18T16:09:11+00:00"
}, },
{ {
"name": "phpstan/phpstan-doctrine", "name": "phpstan/phpstan-doctrine",
"version": "1.0.4", "version": "1.2.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan-doctrine.git", "url": "https://github.com/phpstan/phpstan-doctrine.git",
"reference": "251d9556737b01ec9bb01afa540550de04fa595b" "reference": "16cb23af853014620473a0c72d188cf76b9a9401"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/251d9556737b01ec9bb01afa540550de04fa595b", "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/16cb23af853014620473a0c72d188cf76b9a9401",
"reference": "251d9556737b01ec9bb01afa540550de04fa595b", "reference": "16cb23af853014620473a0c72d188cf76b9a9401",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0", "php": "^7.1 || ^8.0",
"phpstan/phpstan": "^1.3" "phpstan/phpstan": "^1.4.1"
}, },
"conflict": { "conflict": {
"doctrine/collections": "<1.0", "doctrine/collections": "<1.0",
@@ -11869,11 +11869,11 @@
"doctrine/annotations": "^1.11.0", "doctrine/annotations": "^1.11.0",
"doctrine/collections": "^1.6", "doctrine/collections": "^1.6",
"doctrine/common": "^2.7 || ^3.0", "doctrine/common": "^2.7 || ^3.0",
"doctrine/dbal": "^2.13.7", "doctrine/dbal": "^2.13.7 || ^3.0",
"doctrine/lexer": "^1.2.1", "doctrine/lexer": "^1.2.1",
"doctrine/mongodb-odm": "^1.3 || ^2.1", "doctrine/mongodb-odm": "^1.3 || ^2.1",
"doctrine/orm": "^2.11.0", "doctrine/orm": "^2.11.0",
"doctrine/persistence": "^1.1 || ^2.0", "doctrine/persistence": "^1.3.8 || ^2.2.1",
"nesbot/carbon": "^2.49", "nesbot/carbon": "^2.49",
"nikic/php-parser": "^4.13.2", "nikic/php-parser": "^4.13.2",
"php-parallel-lint/php-parallel-lint": "^1.2", "php-parallel-lint/php-parallel-lint": "^1.2",
@@ -11886,7 +11886,7 @@
"type": "phpstan-extension", "type": "phpstan-extension",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0-dev" "dev-master": "1.2-dev"
}, },
"phpstan": { "phpstan": {
"includes": [ "includes": [
@@ -11907,9 +11907,9 @@
"description": "Doctrine extensions for PHPStan", "description": "Doctrine extensions for PHPStan",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan-doctrine/issues", "issues": "https://github.com/phpstan/phpstan-doctrine/issues",
"source": "https://github.com/phpstan/phpstan-doctrine/tree/1.0.4" "source": "https://github.com/phpstan/phpstan-doctrine/tree/1.2.3"
}, },
"time": "2022-01-16T07:46:10+00:00" "time": "2022-01-23T12:35:08+00:00"
}, },
{ {
"name": "phpstan/phpstan-phpunit", "name": "phpstan/phpstan-phpunit",

View File

@@ -1,8 +1,9 @@
includes: includes:
- vendor/phpstan/phpstan-symfony/extension.neon - %rootDir%/../phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-doctrine/extension.neon - %rootDir%/../phpstan-symfony/rules.neon
- vendor/phpstan/phpstan-symfony/rules.neon - %rootDir%/../phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon - %rootDir%/../phpstan-doctrine/rules.neon
- %rootDir%/../phpstan/conf/bleedingEdge.neon
parameters: parameters:
tmpDir: %rootDir%/../../../var/cache/phpstan tmpDir: %rootDir%/../../../var/cache/phpstan
@@ -11,4 +12,8 @@ parameters:
excludePaths: excludePaths:
- %rootDir%/../../../src/Ldap/LdapDriver.php - %rootDir%/../../../src/Ldap/LdapDriver.php
treatPhpDocTypesAsCertain: false treatPhpDocTypesAsCertain: false
inferPrivatePropertyTypeFromConstructor: true inferPrivatePropertyTypeFromConstructor: true
doctrine:
objectManagerLoader: %rootDir%/../../../tests/phpstan-doctrine.php
symfony:
containerXmlPath: %rootDir%/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml

View File

@@ -100,6 +100,7 @@ class AppExtension extends Extension
$container->setParameter('kimai.i18n_domains', $localTranslations); $container->setParameter('kimai.i18n_domains', $localTranslations);
// this should happen always at the end, so bundles do not mess with the base configuration // this should happen always at the end, so bundles do not mess with the base configuration
/* @phpstan-ignore-next-line */
if ($container->hasParameter('kimai.bundles.config')) { if ($container->hasParameter('kimai.bundles.config')) {
$bundleConfig = $container->getParameter('kimai.bundles.config'); $bundleConfig = $container->getParameter('kimai.bundles.config');
if (!\is_array($bundleConfig)) { if (!\is_array($bundleConfig)) {

View File

@@ -99,7 +99,7 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
/** /**
* Description of this activity * Description of this activity
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Activity_Entity"}) * @Serializer\Groups({"Activity_Entity"})

View File

@@ -51,7 +51,7 @@ trait BudgetTrait
* - null = default / full time * - null = default / full time
* - month = monthly budget * - month = monthly budget
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Activity_Entity", "Project_Entity", "Customer_Entity"}) * @Serializer\Groups({"Activity_Entity", "Project_Entity", "Customer_Entity"})

View File

@@ -20,7 +20,7 @@ trait ColorTrait
/** /**
* The assigned color in HTML hex format, eg. #dd1d00 * The assigned color in HTML hex format, eg. #dd1d00
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})
@@ -32,9 +32,6 @@ trait ColorTrait
*/ */
private $color = null; private $color = null;
/**
* @return string
*/
public function getColor(): ?string public function getColor(): ?string
{ {
if ($this->color === Constants::DEFAULT_COLOR) { if ($this->color === Constants::DEFAULT_COLOR) {
@@ -49,9 +46,6 @@ trait ColorTrait
return null !== $this->color && $this->color !== Constants::DEFAULT_COLOR; return null !== $this->color && $this->color !== Constants::DEFAULT_COLOR;
} }
/**
* @param string $color
*/
public function setColor(?string $color = null): void public function setColor(?string $color = null): void
{ {
$this->color = $color; $this->color = $color;

View File

@@ -30,10 +30,8 @@ class Configuration
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @phpstan-ignore-next-line
*/ */
private $id; private $id;
/** /**
* @var string * @var string
* *
@@ -42,9 +40,8 @@ class Configuration
* @Assert\Length(min=2, max=100, allowEmptyString=false) * @Assert\Length(min=2, max=100, allowEmptyString=false)
*/ */
private $name; private $name;
/** /**
* @var string * @var string|null
* *
* @ORM\Column(name="value", type="string", length=1024, nullable=true) * @ORM\Column(name="value", type="string", length=1024, nullable=true)
* @Assert\Length(max=1024, allowEmptyString=true) * @Assert\Length(max=1024, allowEmptyString=true)

View File

@@ -64,7 +64,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $name; private $name;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})
@@ -76,7 +76,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $number; private $number;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -99,7 +99,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $visible = true; private $visible = true;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -111,7 +111,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $company; private $company;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -123,7 +123,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $vatId; private $vatId;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -135,7 +135,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $contact; private $contact;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -174,7 +174,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $currency = self::DEFAULT_CURRENCY; private $currency = self::DEFAULT_CURRENCY;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -186,7 +186,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $phone; private $phone;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -198,7 +198,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $fax; private $fax;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -214,7 +214,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
* *
* Limited via RFC to 254 chars * Limited via RFC to 254 chars
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -226,7 +226,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
*/ */
private $email; private $email;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})

View File

@@ -53,7 +53,6 @@ class Invoice implements EntityWithMetaFields
* @ORM\GeneratedValue(strategy="IDENTITY") * @ORM\GeneratedValue(strategy="IDENTITY")
*/ */
private $id; private $id;
/** /**
* @var string * @var string
* *
@@ -63,9 +62,8 @@ class Invoice implements EntityWithMetaFields
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $invoiceNumber; private $invoiceNumber;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Customer_Entity"}) * @Serializer\Groups({"Customer_Entity"})
@@ -75,25 +73,22 @@ class Invoice implements EntityWithMetaFields
* @ORM\Column(name="comment", type="text", nullable=true) * @ORM\Column(name="comment", type="text", nullable=true)
*/ */
private $comment; private $comment;
/** /**
* @var Customer|null * @var Customer
* *
* @ORM\ManyToOne(targetEntity="App\Entity\Customer") * @ORM\ManyToOne(targetEntity="App\Entity\Customer")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false) * @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $customer; private $customer;
/** /**
* @var User|null * @var User
* *
* @ORM\ManyToOne(targetEntity="App\Entity\User") * @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(onDelete="CASCADE", nullable=false) * @ORM\JoinColumn(onDelete="CASCADE", nullable=false)
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $user; private $user;
/** /**
* @var \DateTime * @var \DateTime
* *
@@ -103,14 +98,12 @@ class Invoice implements EntityWithMetaFields
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $createdAt; private $createdAt;
/** /**
* @var string * @var string
* *
* @ORM\Column(name="timezone", type="string", length=64, nullable=false) * @ORM\Column(name="timezone", type="string", length=64, nullable=false)
*/ */
private $timezone; private $timezone;
/** /**
* @var float * @var float
* *
@@ -120,7 +113,6 @@ class Invoice implements EntityWithMetaFields
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $total = 0.00; private $total = 0.00;
/** /**
* @var float * @var float
* *
@@ -130,7 +122,6 @@ class Invoice implements EntityWithMetaFields
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $tax = 0.00; private $tax = 0.00;
/** /**
* @var string * @var string
* *
@@ -141,7 +132,6 @@ class Invoice implements EntityWithMetaFields
* @Assert\Length(max=3) * @Assert\Length(max=3)
*/ */
private $currency; private $currency;
/** /**
* @var int * @var int
* *
@@ -152,7 +142,6 @@ class Invoice implements EntityWithMetaFields
* @Assert\Range(min = 0, max = 999) * @Assert\Range(min = 0, max = 999)
*/ */
private $dueDays = 30; private $dueDays = 30;
/** /**
* @var float * @var float
* *
@@ -163,7 +152,6 @@ class Invoice implements EntityWithMetaFields
* @Assert\Range(min = 0.0, max = 99.99) * @Assert\Range(min = 0.0, max = 99.99)
*/ */
private $vat = 0.00; private $vat = 0.00;
/** /**
* @var string * @var string
* *
@@ -173,7 +161,6 @@ class Invoice implements EntityWithMetaFields
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $status = self::STATUS_NEW; private $status = self::STATUS_NEW;
/** /**
* @var string * @var string
* *
@@ -184,19 +171,16 @@ class Invoice implements EntityWithMetaFields
* @Assert\Length(min=1, max=150, allowEmptyString=false) * @Assert\Length(min=1, max=150, allowEmptyString=false)
*/ */
private $invoiceFilename; private $invoiceFilename;
/** /**
* @var bool * @var bool
*/ */
private $localized = false; private $localized = false;
/** /**
* @var \DateTime|null * @var \DateTime|null
* *
* @ORM\Column(name="payment_date", type="date", nullable=true) * @ORM\Column(name="payment_date", type="date", nullable=true)
*/ */
private $paymentDate; private $paymentDate;
/** /**
* Meta fields * Meta fields
* *

View File

@@ -32,7 +32,6 @@ class InvoiceTemplate
* @ORM\GeneratedValue(strategy="IDENTITY") * @ORM\GeneratedValue(strategy="IDENTITY")
*/ */
private $id; private $id;
/** /**
* @var string * @var string
* *
@@ -41,7 +40,6 @@ class InvoiceTemplate
* @Assert\Length(min=1, max=60, allowEmptyString=false) * @Assert\Length(min=1, max=60, allowEmptyString=false)
*/ */
private $name; private $name;
/** /**
* @var string * @var string
* *
@@ -49,7 +47,6 @@ class InvoiceTemplate
* @Assert\NotBlank() * @Assert\NotBlank()
*/ */
private $title; private $title;
/** /**
* @var string * @var string
* *
@@ -57,29 +54,25 @@ class InvoiceTemplate
* @Assert\NotBlank() * @Assert\NotBlank()
*/ */
private $company; private $company;
/** /**
* @var string * @var string|null
* *
* @ORM\Column(name="vat_id", type="string", length=50, nullable=true) * @ORM\Column(name="vat_id", type="string", length=50, nullable=true)
* @Assert\Length(max=50) * @Assert\Length(max=50)
*/ */
private $vatId; private $vatId;
/** /**
* @var string * @var string|null
* *
* @ORM\Column(name="address", type="text", nullable=true) * @ORM\Column(name="address", type="text", nullable=true)
*/ */
private $address; private $address;
/** /**
* @var string * @var string|null
* *
* @ORM\Column(name="contact", type="text", nullable=true) * @ORM\Column(name="contact", type="text", nullable=true)
*/ */
private $contact; private $contact;
/** /**
* @var int * @var int
* *
@@ -87,7 +80,6 @@ class InvoiceTemplate
* @Assert\Range(min = 0, max = 999) * @Assert\Range(min = 0, max = 999)
*/ */
private $dueDays = 30; private $dueDays = 30;
/** /**
* @var float * @var float
* *
@@ -95,7 +87,6 @@ class InvoiceTemplate
* @Assert\Range(min = 0.0, max = 99.99) * @Assert\Range(min = 0.0, max = 99.99)
*/ */
private $vat = 0.00; private $vat = 0.00;
/** /**
* @var string * @var string
* *
@@ -112,7 +103,6 @@ class InvoiceTemplate
* @Assert\Length(max=20) * @Assert\Length(max=20)
*/ */
private $numberGenerator = 'default'; private $numberGenerator = 'default';
/** /**
* @var string * @var string
* *
@@ -121,21 +111,18 @@ class InvoiceTemplate
* @Assert\Length(max=20) * @Assert\Length(max=20)
*/ */
private $renderer = 'default'; private $renderer = 'default';
/** /**
* @var string * @var string|null
* *
* @ORM\Column(name="payment_terms", type="text", nullable=true) * @ORM\Column(name="payment_terms", type="text", nullable=true)
*/ */
private $paymentTerms; private $paymentTerms;
/** /**
* @var string * @var string|null
* *
* @ORM\Column(name="payment_details", type="text", nullable=true) * @ORM\Column(name="payment_details", type="text", nullable=true)
*/ */
private $paymentDetails; private $paymentDetails;
/** /**
* Used when rendering HTML templates. * Used when rendering HTML templates.
* *
@@ -145,11 +132,10 @@ class InvoiceTemplate
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $decimalDuration = false; private $decimalDuration = false;
/** /**
* Used for translations and locale dependent number and date formats. * Used for translations and locale dependent number and date formats.
* *
* @var string * @var string|null
* *
* @ORM\Column(name="language", type="string", length=6, nullable=true) * @ORM\Column(name="language", type="string", length=6, nullable=true)
*/ */

View File

@@ -45,7 +45,7 @@ trait MetaTableTypeTrait
/** /**
* Value of the meta (custom) field * Value of the meta (custom) field
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})

View File

@@ -104,7 +104,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
/** /**
* Project order number * Project order number
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Project_Entity"}) * @Serializer\Groups({"Project_Entity"})
@@ -116,7 +116,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
*/ */
private $orderNumber; private $orderNumber;
/** /**
* @var \DateTime * @var \DateTime|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Project_Entity"}) * @Serializer\Groups({"Project_Entity"})
@@ -131,7 +131,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
*/ */
private $orderDate; private $orderDate;
/** /**
* @var \DateTime * @var \DateTime|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Project"}) * @Serializer\Groups({"Project"})
@@ -146,7 +146,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
*/ */
private $start; private $start;
/** /**
* @var \DateTime * @var \DateTime|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Project"}) * @Serializer\Groups({"Project"})
@@ -161,7 +161,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
*/ */
private $end; private $end;
/** /**
* @var string * @var string|null
* @internal used for storing the timezone for "order", "start" and "end" date * @internal used for storing the timezone for "order", "start" and "end" date
* *
* @ORM\Column(name="timezone", type="string", length=64, nullable=true) * @ORM\Column(name="timezone", type="string", length=64, nullable=true)
@@ -173,7 +173,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
*/ */
private $localized = false; private $localized = false;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Project_Entity"}) * @Serializer\Groups({"Project_Entity"})

View File

@@ -28,7 +28,7 @@ trait Rate
*/ */
private $id; private $id;
/** /**
* @var User * @var User|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})

View File

@@ -30,7 +30,6 @@ class Role
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY") * @ORM\GeneratedValue(strategy="IDENTITY")
* @phpstan-ignore-next-line
*/ */
private $id; private $id;
/** /**

View File

@@ -30,7 +30,6 @@ class RolePermission
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY") * @ORM\GeneratedValue(strategy="IDENTITY")
* @phpstan-ignore-next-line
*/ */
private $id; private $id;
/** /**

View File

@@ -39,7 +39,6 @@ class Tag
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY") * @ORM\GeneratedValue(strategy="IDENTITY")
* @phpstan-ignore-next-line
*/ */
private $id; private $id;
/** /**

View File

@@ -59,7 +59,7 @@ class Team
/** /**
* All team member (including team leads) * All team member (including team leads)
* *
* @var TeamMember[]|Collection<TeamMember> * @var Collection<TeamMember>
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Team_Entity"}) * @Serializer\Groups({"Team_Entity"})

View File

@@ -32,7 +32,6 @@ class TeamMember
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY") * @ORM\GeneratedValue(strategy="IDENTITY")
* @phpstan-ignore-next-line
*/ */
private $id; private $id;
/** /**

View File

@@ -134,7 +134,7 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
*/ */
private $begin; private $begin;
/** /**
* @var DateTime * @var DateTime|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})
@@ -160,7 +160,7 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
*/ */
private $localized = false; private $localized = false;
/** /**
* @var int * @var int|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})
@@ -202,7 +202,7 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
*/ */
private $project; private $project;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})
@@ -240,7 +240,7 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
*/ */
private $fixedRate = null; private $fixedRate = null;
/** /**
* @var float * @var float|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Entity"}) * @Serializer\Groups({"Entity"})

View File

@@ -100,7 +100,7 @@ class User implements UserInterface, EquatableInterface, \Serializable
/** /**
* The user alias will be displayed in the frontend instead of the username * The user alias will be displayed in the frontend instead of the username
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})
@@ -114,7 +114,7 @@ class User implements UserInterface, EquatableInterface, \Serializable
/** /**
* Registration date for the user * Registration date for the user
* *
* @var DateTime * @var DateTime|null
* *
* @Exporter\Expose(label="profile.registration_date", type="datetime") * @Exporter\Expose(label="profile.registration_date", type="datetime")
* *
@@ -124,7 +124,7 @@ class User implements UserInterface, EquatableInterface, \Serializable
/** /**
* An additional title for the user, like the Job position or Department * An additional title for the user, like the Job position or Department
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"User_Entity"}) * @Serializer\Groups({"User_Entity"})
@@ -136,9 +136,9 @@ class User implements UserInterface, EquatableInterface, \Serializable
*/ */
private $title; private $title;
/** /**
* URL to the users avatar, will be auto-generated if empty * URL to the user avatar, will be auto-generated if empty
* *
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"User_Entity"}) * @Serializer\Groups({"User_Entity"})
@@ -150,7 +150,7 @@ class User implements UserInterface, EquatableInterface, \Serializable
/** /**
* API token (password) for this user * API token (password) for this user
* *
* @var string * @var string|null
* *
* @ORM\Column(name="api_token", type="string", length=255, nullable=true) * @ORM\Column(name="api_token", type="string", length=255, nullable=true)
*/ */
@@ -167,7 +167,7 @@ class User implements UserInterface, EquatableInterface, \Serializable
* *
* List of preferences for this user, required ones have dedicated fields/methods * List of preferences for this user, required ones have dedicated fields/methods
* *
* @var UserPreference[]|Collection * @var Collection<UserPreference>
* *
* @ORM\OneToMany(targetEntity="App\Entity\UserPreference", mappedBy="user", cascade={"persist"}) * @ORM\OneToMany(targetEntity="App\Entity\UserPreference", mappedBy="user", cascade={"persist"})
*/ */
@@ -175,7 +175,7 @@ class User implements UserInterface, EquatableInterface, \Serializable
/** /**
* List of all team memberships. * List of all team memberships.
* *
* @var TeamMember[]|ArrayCollection<TeamMember> * @var Collection<TeamMember>
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"User_Entity"}) * @Serializer\Groups({"User_Entity"})
@@ -187,9 +187,9 @@ class User implements UserInterface, EquatableInterface, \Serializable
*/ */
private $memberships; private $memberships;
/** /**
* The type of authentication used by the user (eg. "kimai", "ldap", "saml") * The type of authentication used by the user (e.g. "kimai", "ldap", "saml")
* *
* @var string * @var string|null
* @internal for internal usage only * @internal for internal usage only
* *
* @ORM\Column(name="auth", type="string", length=20, nullable=true) * @ORM\Column(name="auth", type="string", length=20, nullable=true)

View File

@@ -49,7 +49,7 @@ class UserPreference
* @var User * @var User
* *
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="preferences") * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="preferences")
* @ORM\JoinColumn(onDelete="CASCADE") * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $user; private $user;
@@ -65,7 +65,7 @@ class UserPreference
*/ */
private $name; private $name;
/** /**
* @var string * @var string|null
* *
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})

View File

@@ -18,6 +18,7 @@ abstract class AbstractPluginExtension extends Extension
{ {
$bundleConfig = [$this->getAlias() => $configs]; $bundleConfig = [$this->getAlias() => $configs];
/* @phpstan-ignore-next-line */
if ($container->hasParameter('kimai.bundles.config')) { if ($container->hasParameter('kimai.bundles.config')) {
$bundleConfig = array_merge( $bundleConfig = array_merge(
$container->getParameter('kimai.bundles.config'), $container->getParameter('kimai.bundles.config'),

View File

@@ -31,6 +31,7 @@ class ActivateUserCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -31,6 +31,7 @@ class ChangePasswordCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -30,6 +30,7 @@ class CreateUserCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -31,6 +31,7 @@ class DeactivateUserCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -32,6 +32,7 @@ class DemoteUserCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -27,6 +27,7 @@ class ImportCustomerCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -29,6 +29,7 @@ class ImportProjectCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -34,6 +34,7 @@ class ImportTimesheetCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);

View File

@@ -26,6 +26,7 @@ class InstallCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -61,6 +61,7 @@ class InvoiceCreateCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$this->clearInvoiceFiles(); $this->clearInvoiceFiles();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);

View File

@@ -29,6 +29,7 @@ class KimaiImporterCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);

View File

@@ -32,6 +32,7 @@ class PromoteUserCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$container = self::$kernel->getContainer(); $container = self::$kernel->getContainer();

View File

@@ -26,6 +26,7 @@ class ReloadCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);
$this->application->add(new ReloadCommand()); $this->application->add(new ReloadCommand());

View File

@@ -28,6 +28,7 @@ class VersionCommandTest extends KernelTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->application = new Application($kernel); $this->application = new Application($kernel);

View File

@@ -46,10 +46,10 @@ class UserPreferenceTest extends TestCase
$sut->setType(IntegerType::class); $sut->setType(IntegerType::class);
self::assertSame(1, $sut->getValue()); self::assertSame(1, $sut->getValue());
$sut->setType(YesNoType::class); $sut->setType(YesNoType::class);
self::assertSame(true, $sut->getValue()); self::assertTrue($sut->getValue());
$sut->setValue('0'); $sut->setValue('0');
$sut->setType(CheckboxType::class); $sut->setType(CheckboxType::class);
self::assertSame(false, $sut->getValue()); self::assertFalse($sut->getValue());
} }
public function testGetLabelWithLabelOption() public function testGetLabelWithLabelOption()

View File

@@ -31,6 +31,7 @@ abstract class AbstractRepositoryTest extends KernelTestCase
*/ */
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$kernel = self::bootKernel(); $kernel = self::bootKernel();
$this->entityManager = $kernel->getContainer() $this->entityManager = $kernel->getContainer()

View File

@@ -0,0 +1,19 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use App\Kernel;
use Symfony\Component\Dotenv\Dotenv;
require __DIR__ . '/../vendor/autoload.php';
(new Dotenv(false))->loadEnv(dirname(__DIR__) . '/.env');
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();
return $kernel->getContainer()->get('doctrine')->getManager();

View File

@@ -1,7 +1,10 @@
includes: includes:
- %rootDir%/../phpstan-symfony/extension.neon - %rootDir%/../phpstan-symfony/extension.neon
- %rootDir%/../phpstan-symfony/rules.neon
- %rootDir%/../phpstan-doctrine/extension.neon - %rootDir%/../phpstan-doctrine/extension.neon
- %rootDir%/../phpstan-doctrine/rules.neon
- %rootDir%/../phpstan-phpunit/extension.neon - %rootDir%/../phpstan-phpunit/extension.neon
- %rootDir%/../phpstan-phpunit/rules.neon
parameters: parameters:
tmpDir: %rootDir%/../../../var/cache/phpstan tmpDir: %rootDir%/../../../var/cache/phpstan
@@ -9,4 +12,6 @@ parameters:
- '#Call to static method PHPUnit\\Framework\\Assert::assertSame\(\) with App\\Entity\\[a-zA-Z0-9]+ and null will always evaluate to false.#' - '#Call to static method PHPUnit\\Framework\\Assert::assertSame\(\) with App\\Entity\\[a-zA-Z0-9]+ and null will always evaluate to false.#'
excludePaths: excludePaths:
- %rootDir%/../../../tests/Ldap/LdapDriverTest.php - %rootDir%/../../../tests/Ldap/LdapDriverTest.php
inferPrivatePropertyTypeFromConstructor: true inferPrivatePropertyTypeFromConstructor: true
doctrine:
objectManagerLoader: %rootDir%/../../../tests/phpstan-doctrine.php