diff --git a/composer.json b/composer.json index 0d134cbf8..7b356f698 100644 --- a/composer.json +++ b/composer.json @@ -54,6 +54,9 @@ "doctrine/doctrine-fixtures-bundle": "^3.3", "fakerphp/faker": "^1.13", "nelmio/alice": "^3.8", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^7.0", "symfony/debug-bundle": "^5.1", "symfony/dotenv": "^5.1", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 000000000..e578c1d45 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,1542 @@ +parameters: + ignoreErrors: + - + message: "#^Variable \\$activities might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Controller/ActivityController.php + + - + message: "#^Variable \\$view might not be defined\\.$#" + count: 4 + path: src/Bundle/ChillActivityBundle/Controller/ActivityController.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php + + - + message: "#^Variable \\$activity might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivitytACL.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Entity/Activity.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Entity/ActivityReason.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php + + - + message: "#^Variable property access on \\$this\\(Chill\\\\ActivityBundle\\\\Entity\\\\ActivityType\\)\\.$#" + count: 3 + path: src/Bundle/ChillActivityBundle/Entity/ActivityType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php + + - + message: "#^Method Chill\\\\ActivityBundle\\\\Export\\\\Export\\\\StatActivityDuration\\:\\:getDescription\\(\\) should return string but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php + + - + message: "#^Method Chill\\\\ActivityBundle\\\\Export\\\\Export\\\\StatActivityDuration\\:\\:getTitle\\(\\) should return string but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php + + - + message: "#^Variable \\$header might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php + + - + message: "#^Variable \\$select might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Form/ActivityType.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Form/ActivityType.php + + - + message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#" + count: 3 + path: src/Bundle/ChillActivityBundle/Form/ActivityType.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillActivityBundle/Form/ActivityType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php + + - + message: "#^Undefined variable\\: \\$person$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStatsVoter.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php + + - + message: "#^Method Chill\\\\ActivityBundle\\\\Timeline\\\\TimelineActivityProvider\\:\\:getFromClausePerson\\(\\) invoked with 1 parameter, 0 required\\.$#" + count: 1 + path: src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php + + - + message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:buildQueryEntities\\(\\) invoked with 3 parameters, 2 required\\.$#" + count: 1 + path: src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php + + - + message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Entity\\\\AsideActivityCategory\\:\\:\\$oldParent\\.$#" + count: 2 + path: src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php + + - + message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityCategoryType\\:\\:\\$categoryRender\\.$#" + count: 2 + path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityCategoryType.php + + - + message: "#^Access to an undefined property Chill\\\\AsideActivityBundle\\\\Form\\\\AsideActivityFormType\\:\\:\\$translatableStringHelper\\.$#" + count: 1 + path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillAsideActivityBundle/src/Menu/AdminMenuBuilder.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 3 + path: src/Bundle/ChillBudgetBundle/Form/ChargeType.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillBudgetBundle/Form/ResourceType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php + + - + message: "#^Variable \\$view might not be defined\\.$#" + count: 4 + path: src/Bundle/ChillCalendarBundle/Controller/CalendarController.php + + - + message: "#^Access to an undefined property Chill\\\\CalendarBundle\\\\DataFixtures\\\\ORM\\\\LoadCalendarRange\\:\\:\\$userRepository\\.$#" + count: 2 + path: src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillCalendarBundle/Entity/Calendar.php + + - + message: "#^Class RuntimeException referenced with incorrect case\\: RunTimeException\\.$#" + count: 5 + path: src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php + + - + message: "#^Foreach overwrites \\$key with its key variable\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/AbstractCustomField.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 3 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 4 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php + + - + message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldChoice\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php + + - + message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldDate\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php + + - + message: "#^Anonymous function has an unused use \\$entries\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php + + - + message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldLongChoice\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php + + - + message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldNumber\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php + + - + message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldText\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php + + - + message: "#^Method Chill\\\\CustomFieldsBundle\\\\CustomFields\\\\CustomFieldTitle\\:\\:buildForm\\(\\) should return Symfony\\\\Component\\\\Form\\\\FormTypeInterface but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php + + - + message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldType.php + + - + message: "#^Variable \\$optionBuilder might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Form/CustomFieldsGroupType.php + + - + message: "#^Call to sprintf contains 0 placeholders, 1 value given\\.$#" + count: 1 + path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php + + - + message: "#^Access to an undefined property Chill\\\\CustomFieldsBundle\\\\Form\\\\DataTransformer\\\\JsonCustomFieldToArrayTransformer\\:\\:\\$customField\\.$#" + count: 3 + path: src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php + + - + message: "#^Instantiated class PhpOffice\\\\PhpWord\\\\TemplateProcessor not found\\.$#" + count: 1 + path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorController.php + + - + message: "#^Instantiated class PhpOffice\\\\PhpWord\\\\TemplateProcessor not found\\.$#" + count: 1 + path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php + + - + message: "#^Class Chill\\\\DocStoreBundle\\\\Entity\\\\DocumentCategory constructor invoked with 0 parameters, 2 required\\.$#" + count: 1 + path: src/Bundle/ChillDocStoreBundle/Controller/DocumentCategoryController.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillDocStoreBundle/DataFixtures/ORM/LoadDocumentACL.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillDocStoreBundle/Entity/DocumentCategory.php + + - + message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" + count: 1 + path: src/Bundle/ChillDocStoreBundle/EntityRepository/DocumentCategoryRepository.php + + - + message: "#^Variable \\$participation might not be defined\\.$#" + count: 3 + path: src/Bundle/ChillEventBundle/Controller/ParticipationController.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/DataFixtures/ORM/LoadRolesACL.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Entity/Participation.php + + - + message: "#^Method Chill\\\\EventBundle\\\\Entity\\\\Participation\\:\\:offsetGet\\(\\) should return mixed but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Entity/Participation.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php + + - + message: "#^Foreach overwrites \\$value with its value variable\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php + + - + message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\EventTypeType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Form/EventTypeType.php + + - + message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\RoleType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Form/RoleType.php + + - + message: "#^Parameter \\$resolver of method Chill\\\\EventBundle\\\\Form\\\\StatusType\\:\\:setDefaultOptions\\(\\) has invalid type Symfony\\\\Component\\\\OptionsResolver\\\\OptionsResolverInterface\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Form/StatusType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Form/Type/PickEventType.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 2 + path: src/Bundle/ChillEventBundle/Search/EventSearch.php + + - + message: "#^Method Chill\\\\EventBundle\\\\Search\\\\EventSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillEventBundle/Search/EventSearch.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillEventBundle/Security/Authorization/EventVoter.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillEventBundle/Security/Authorization/ParticipationVoter.php + + - + message: "#^Undefined variable\\: \\$id$#" + count: 1 + path: src/Bundle/ChillFamilyMembersBundle/Controller/FamilyMemberController.php + + - + message: "#^Casting to string something that's already string\\.$#" + count: 5 + path: src/Bundle/ChillFamilyMembersBundle/Entity/AbstractFamilyMember.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillFamilyMembersBundle/Form/FamilyMemberType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillFamilyMembersBundle/Security/Voter/FamilyMemberVoter.php + + - + message: "#^Call to an undefined method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getRoleFor\\(\\)\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php + + - + message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getEntity\\(\\) invoked with 4 parameters, 3 required\\.$#" + count: 3 + path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php + + - + message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\ApiController\\:\\:entityPostAction\\(\\) invoked with 4 parameters, 3 required\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php + + - + message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php + + - + message: "#^Variable method call on object\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php + + - + message: "#^Call to sprintf contains 2 placeholders, 0 values given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:buildQueryEntities\\(\\) invoked with 3 parameters, 2 required\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:onPreDelete\\(\\) invoked with 3 parameters, 2 required\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: "#^Method Symfony\\\\Bundle\\\\FrameworkBundle\\\\Controller\\\\AbstractController\\:\\:createNotFoundException\\(\\) invoked with 3 parameters, 0\\-2 required\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: "#^Parameter \\$scope of method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\CRUDController\\:\\:getReachableCenters\\(\\) has invalid type Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\Scope\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: "#^Variable \\$entity in isset\\(\\) is never defined\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php + + - + message: "#^Method Chill\\\\MainBundle\\\\CRUD\\\\Resolver\\\\Resolver\\:\\:getConfigValue\\(\\) should return string but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Resolver/Resolver.php + + - + message: "#^Access to an undefined property Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:\\$apiConfig\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php + + - + message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php + + - + message: "#^Chill\\\\MainBundle\\\\CRUD\\\\Routing\\\\CRUDRoutesLoader\\:\\:__construct\\(\\) does not call parent constructor from Symfony\\\\Component\\\\Config\\\\Loader\\\\Loader\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php + + - + message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:tempOutput\\(\\)\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Command\\\\ChillImportUsersCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/ChillImportUsersCommand.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Command\\\\ChillUserSendRenewPasswordCodeCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/ChillUserSendRenewPasswordCodeCommand.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadAndUpdateLanguagesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php + + - + message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Command/LoadAndUpdateLanguagesCommand.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadCountriesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Command\\\\LoadPostalCodesCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php + + - + message: "#^Variable \\$csv might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/LoadPostalCodesCommand.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Command\\\\SetPasswordCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Command/SetPasswordCommand.php + + - + message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Controller\\\\AdminCountryCRUDController\\:\\:\\$paginatorFactory\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Controller/AdminCountryCRUDController.php + + - + message: "#^Cannot unset offset '_token' on array\\{formatter\\: mixed, export\\: mixed, centers\\: mixed, alias\\: string\\}\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Controller/ExportController.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Controller/PasswordController.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Controller/PostalCodeController.php + + - + message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditForm\\(\\)\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Controller/UserController.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createAddLinkGroupCenterForm\\(\\) invoked with 1 parameter, 2 required\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Controller/UserController.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditPasswordForm\\(\\) invoked with 2 parameters, 1 required\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Controller/UserController.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:getDeleteLinkGroupCenterByUser\\(\\) invoked with 1 parameter, 2 required\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Controller/UserController.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php + + - + message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#" + count: 5 + path: src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php + + - + message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/SearchableServicesCompilerPass.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php + + - + message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php + + - + message: "#^Variable \\$p might not be defined\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Doctrine/DQL/OverlapsI.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Doctrine\\\\Type\\\\PointType\\:\\:getSqlDeclaration\\(\\) does not match parent method name\\: Doctrine\\\\DBAL\\\\Types\\\\Type\\:\\:getSQLDeclaration\\(\\)\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Doctrine/Type/PointType.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Entity/Address.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Entity/Embeddable/CommentEmbeddable.php + + - + message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Entity\\\\RoleScope\\:\\:\\$new\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Entity/RoleScope.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Entity/User.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Entity/User.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 6 + path: src/Bundle/ChillMainBundle/Export/ExportManager.php + + - + message: "#^Function findColumnPosition not found\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php + + - + message: "#^Inner named functions are not supported by PHPStan\\. Consider refactoring to an anonymous function, class method, or a top\\-level\\-defined function\\. See issue \\#165 \\(https\\://github\\.com/phpstan/phpstan/issues/165\\) for more details\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Export\\\\Formatter\\\\CSVFormatter\\:\\:orderingHeaders\\(\\) should return Chill\\\\MainBundle\\\\Export\\\\Formatter\\\\type but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php + + - + message: "#^Variable \\$line might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php + + - + message: "#^Call to method Chill\\\\MainBundle\\\\Export\\\\Formatter\\\\SpreadSheetFormatter\\:\\:generateContent\\(\\) with incorrect case\\: generatecontent$#" + count: 1 + path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php + + - + message: "#^Foreach overwrites \\$key with its key variable\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php + + - + message: "#^Foreach overwrites \\$key with its value variable\\.$#" + count: 3 + path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php + + - + message: "#^Only booleans are allowed in a ternary operator condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php + + - + message: "#^Foreach overwrites \\$value with its value variable\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/ChoiceLoader/PostalCodeChoiceLoader.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/DataMapper/AddressDataMapper.php + + - + message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Form/Type/AddressType.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Form/Type/AddressType.php + + - + message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/Type/ChillTextareaType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/Type/ComposedRoleScopeType.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 3 + path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php + + - + message: "#^Variable \\$value in empty\\(\\) always exists and is not falsy\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/DateIntervalTransformer.php + + - + message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/Type/DataTransformer/ObjectToIdTransformer.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Form/Type/TranslatableStringFormType.php + + - + message: "#^Undefined variable\\: \\$current$#" + count: 1 + path: src/Bundle/ChillMainBundle/Pagination/PageGenerator.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php + + - + message: "#^Chill\\\\MainBundle\\\\Routing\\\\Loader\\\\ChillRoutesLoader\\:\\:__construct\\(\\) does not call parent constructor from Symfony\\\\Component\\\\Config\\\\Loader\\\\Loader\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php + + - + message: "#^Foreach overwrites \\$resource with its value variable\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Routing/Loader/ChillRoutesLoader.php + + - + message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Routing\\\\MenuComposer\\:\\:\\$routeCollection\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Routing/MenuComposer.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Search/Entity/SearchUserApiProvider.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Search\\\\SearchApi\\:\\:buildUnionQuery\\(\\) invoked with 4 parameters, 3 required\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Search/SearchApi.php + + - + message: "#^Access to an undefined property Chill\\\\MainBundle\\\\Search\\\\SearchApiResult\\:\\:\\$relevance\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Search/SearchApiResult.php + + - + message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedAttributes\\(\\)\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php + + - + message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedClasses\\(\\)\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php + + - + message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:isGranted\\(\\)\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AuthorizationHelper\\:\\:userCanReachCenter\\(\\) invoked with 3 parameters, 2 required\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/PasswordRecover/TokenManager.php + + - + message: "#^Call to sprintf contains 0 placeholders, 1 value given\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Security/UserProvider/UserProvider.php + + - + message: "#^Variable \\$message on left side of \\?\\? always exists and is not nullable\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Templating/ChillTwigHelper.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 3 + path: src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php + + - + message: "#^Method Chill\\\\MainBundle\\\\Timeline\\\\TimelineBuilder\\:\\:getTemplateData\\(\\) should return array but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php + + - + message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Util/DateRangeCovering.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillMainBundle/Validation/Validator/RoleScopeScopePresence.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillMainBundle/Validation/Validator/ValidPhonenumber.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php + + - + message: "#^Variable \\$sqls on left side of \\?\\? always exists and is not nullable\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php + + - + message: "#^Method Chill\\\\PersonBundle\\\\Command\\\\ChillPersonMoveCommand\\:\\:execute\\(\\) should return int but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Command/ChillPersonMoveCommand.php + + - + message: "#^Call to function array_search\\(\\) requires parameter \\#3 to be set\\.$#" + count: 3 + path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 3 + path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php + + - + message: "#^Class Chill\\\\PersonBundle\\\\Entity\\\\Person constructor invoked with 1 parameter, 0 required\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 6 + path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php + + - + message: "#^Variable \\$headers might not be defined\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php + + - + message: "#^Variable \\$rawHeaders might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php + + - + message: "#^Variable \\$street1Value might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php + + - + message: "#^Instantiated class Chill\\\\PersonBundle\\\\Controller\\\\BadRequestExceptions not found\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Controller/HouseholdMemberController.php + + - + message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\PersonController\\:\\:\\$security\\.$#" + count: 3 + path: src/Bundle/ChillPersonBundle/Controller/PersonController.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Controller/PersonController.php + + - + message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\TimelinePersonController\\:\\:\\$authorizationHelper\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Controller/TimelinePersonController.php + + - + message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\LoadHousehold\\:\\:\\$personIds\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php + + - + message: "#^Variable method call on mixed\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php + + - + message: "#^Caught class Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\Throwable not found\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php + + - + message: "#^Instantiated class Chill\\\\PersonBundle\\\\DataFixtures\\\\ORM\\\\Exception not found\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadSocialWorkMetadata.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/DependencyInjection/CompilerPass/AccompanyingPeriodTimelineCompilerPass.php + + - + message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:\\$work\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php + + - + message: "#^Call to method Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:getOpenParticipations\\(\\) with incorrect case\\: getOPenParticipations$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php + + - + message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php + + - + message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Household\\\\PersonHouseholdAddress\\:\\:\\$relation\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/Household/PersonHouseholdAddress.php + + - + message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\Person\\:\\:\\$currentHouseholdParticipationAt\\.$#" + count: 3 + path: src/Bundle/ChillPersonBundle/Entity/Person.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/Person.php + + - + message: "#^Method Chill\\\\PersonBundle\\\\Entity\\\\Person\\:\\:getCurrentPersonAddress\\(\\) invoked with 1 parameter, 0 required\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Entity/Person.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Entity/PersonPhone.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php + + - + message: "#^Anonymous function has an unused use \\$key\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 3 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'address_country_name' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'address_isnoaddress' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'birthdate' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'countryOfBirth' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'gender' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Switch condition type \\(Chill\\\\PersonBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'nationality' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Undefined variable\\: \\$choiceSlug$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Export/Filter/GenderFilter.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php + + - + message: "#^Foreach overwrites \\$value with its value variable\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/ChoiceLoader/PersonChoiceLoader.php + + - + message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Form\\\\CreationPersonType\\:\\:\\$centerTransformer\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/CreationPersonType.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/DataMapper/PersonAltNameDataMapper.php + + - + message: "#^Only booleans are allowed in a ternary operator condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/Type/PersonAltNameType.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Household/MembersEditor.php + + - + message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Household\\\\MembersEditorFactory\\:\\:\\$validator\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Household/MembersEditorFactory.php + + - + message: "#^Foreach overwrites \\$action with its value variable\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php + + - + message: "#^Method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid return type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\QueryBuilder\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php + + - + message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:buildQueryBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php + + - + message: "#^Parameter \\$action of method Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkRepository\\:\\:countBySocialActionWithDescendants\\(\\) has invalid type Chill\\\\PersonBundle\\\\Repository\\\\AccompanyingPeriod\\\\SocialAction\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php + + - + message: "#^Undefined variable\\: \\$action$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php + + - + message: "#^Undefined variable\\: \\$limit$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php + + - + message: "#^Undefined variable\\: \\$offset$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php + + - + message: "#^Undefined variable\\: \\$orderBy$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Repository/PersonRepository.php + + - + message: "#^Foreach overwrites \\$action with its value variable\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php + + - + message: "#^Foreach overwrites \\$action with its value variable\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 3 + path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php + + - + message: "#^Method Chill\\\\PersonBundle\\\\Search\\\\PersonSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php + + - + message: "#^Variable variables are not allowed\\.$#" + count: 4 + path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Search/SearchPersonApiProvider.php + + - + message: "#^Method Chill\\\\PersonBundle\\\\Search\\\\SimilarityPersonSearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Search/SimilarityPersonSearch.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/AccompanyingPeriodWorkDenormalizer.php + + - + message: "#^Function Chill\\\\PersonBundle\\\\Serializer\\\\Normalizer\\\\·\\\\is_array not found\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php + + - + message: "#^Variable method call on object\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php + + - + message: "#^Variable \\$entity might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 2 + path: src/Bundle/ChillPersonBundle/Templating/Entity/ClosingMotiveRender.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Timeline/AbstractTimelineAccompanyingPeriod.php + + - + message: "#^Undefined variable\\: \\$value$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidityValidator.php + + - + message: "#^Parameter \\$personRepostory of method Chill\\\\PersonBundle\\\\Widget\\\\PersonListWidget\\:\\:__construct\\(\\) has invalid type Chill\\\\PersonBundle\\\\Widget\\\\PersonRepository\\.$#" + count: 1 + path: src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReportACL.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php + + - + message: "#^Method Chill\\\\ReportBundle\\\\DataFixtures\\\\ORM\\\\LoadReports\\:\\:getRandomChoice\\(\\) should return array\\\\|string but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 4 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 2 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_address_country_name' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_birthdate' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_countryOfBirth' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_gender' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'person_nationality' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'report_date' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'report_scope' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Switch condition type \\(Chill\\\\ReportBundle\\\\Export\\\\Export\\\\type\\) does not match case condition 'report_user' \\(string\\)\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Undefined variable\\: \\$choiceSlug$#" + count: 1 + path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php + + - + message: "#^Method Chill\\\\ReportBundle\\\\Security\\\\Authorization\\\\ReportVoter\\:\\:supports\\(\\) should return bool but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillReportBundle/Security/Authorization/ReportVoter.php + + - + message: "#^Access to an undefined property Chill\\\\ReportBundle\\\\Timeline\\\\TimelineReportProvider\\:\\:\\$security\\.$#" + count: 4 + path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 4 + path: src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php + + - + message: "#^Variable \\$course might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php + + - + message: "#^Undefined variable\\: \\$type$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Controller/TaskController.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/DataFixtures/ORM/LoadTaskACL.php + + - + message: "#^Casting to string something that's already string\\.$#" + count: 3 + path: src/Bundle/ChillTaskBundle/Entity/AbstractTask.php + + - + message: "#^Chill\\\\TaskBundle\\\\Entity\\\\RecurringTask\\:\\:__construct\\(\\) does not call parent constructor from Chill\\\\TaskBundle\\\\Entity\\\\AbstractTask\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Entity/RecurringTask.php + + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 2 + path: src/Bundle/ChillTaskBundle/Form/SingleTaskListType.php + + - + message: "#^Variable \\$center might not be defined\\.$#" + count: 2 + path: src/Bundle/ChillTaskBundle/Form/SingleTaskType.php + + - + message: "#^Variable \\$isScopeConcerned might not be defined\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Form/SingleTaskType.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 5 + path: src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php + + - + message: "#^Constructor of class Chill\\\\TaskBundle\\\\Security\\\\Authorization\\\\TaskVoter has an unused parameter \\$voterHelperFactory\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php + + - + message: "#^Method Chill\\\\TaskBundle\\\\Timeline\\\\SingleTaskTaskLifeCycleEventTimelineProvider\\:\\:getTransitionByName\\(\\) should return Symfony\\\\Component\\\\Workflow\\\\Transition but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Timeline/SingleTaskTaskLifeCycleEventTimelineProvider.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php + + - + message: "#^Method Chill\\\\TaskBundle\\\\Timeline\\\\TaskLifeCycleEventTimelineProvider\\:\\:getTransitionByName\\(\\) should return Symfony\\\\Component\\\\Workflow\\\\Transition but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/DependencyInjection/CompilerPass/ThirdPartyTypeCompilerPass.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 4 + path: src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php + + - + message: "#^Foreach overwrites \\$value with its value variable\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Form/ChoiceLoader/ThirdPartyChoiceLoader.php + + - + message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyRepository.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php + + - + message: "#^Method Chill\\\\ThirdPartyBundle\\\\Search\\\\ThirdPartySearch\\:\\:renderResult\\(\\) should return string but return statement is missing\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php + + - + message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php + + - + message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" + count: 1 + path: src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 000000000..242e35626 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,21 @@ +parameters: + level: 1 + paths: + - src/ + excludePaths: + - src/Bundle/*/Tests/* + - src/Bundle/*/Test/* + - src/Bundle/*/config/* + - src/Bundle/*/migrations/* + - src/Bundle/*/translations/* + - src/Bundle/*/Resources/* + - src/Bundle/*/src/Tests/* + - src/Bundle/*/src/Test/* + - src/Bundle/*/src/config/* + - src/Bundle/*/src/migrations/* + - src/Bundle/*/src/translations/* + - src/Bundle/*/src/Resources/* + +includes: + - phpstan-baseline.neon + diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 3dec544ba..a0e6d3966 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -29,27 +29,27 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\Query\Expr\Join; /** - * + * * * @author Julien Fastré */ class ActivityTypeAggregator implements AggregatorInterface { - + /** * * @var EntityRepository */ protected $typeRepository; - + /** * * @var TranslatableStringHelper */ protected $stringHelper; - + const KEY = 'activity_type_aggregator'; - + public function __construct( EntityRepository $typeRepository, TranslatableStringHelper $stringHelper @@ -57,19 +57,19 @@ class ActivityTypeAggregator implements AggregatorInterface $this->typeRepository = $typeRepository; $this->stringHelper = $stringHelper; } - + public function alterQuery(QueryBuilder $qb, $data) { - // add select element + // add select element $qb->addSelect(sprintf('IDENTITY(activity.type) AS %s', self::KEY)); - + // add the "group by" part $groupBy = $qb->addGroupBy(self::KEY); } - + /** * Check if a join between Activity and another alias - * + * * @param Join[] $joins * @param string $alias the alias to search for * @return boolean @@ -81,7 +81,7 @@ class ActivityTypeAggregator implements AggregatorInterface return true; } } - + return false; } @@ -99,18 +99,18 @@ class ActivityTypeAggregator implements AggregatorInterface { return "Aggregate by activity type"; } - + public function addRole() { return new Role(ActivityStatsVoter::STATS); } - public function getLabels($key, array $values, $data) + public function getLabels($key, array $values, $data): \Closure { // for performance reason, we load data from db only once $this->typeRepository->findBy(array('id' => $values)); - - return function($value) use ($data) { + + return function($value): string { if ($value === '_header') { return 'Activity type'; } @@ -120,12 +120,11 @@ class ActivityTypeAggregator implements AggregatorInterface return $this->stringHelper->localize($t->getName()); }; - } - public function getQueryKeys($data) + public function getQueryKeys($data): array { - return array(self::KEY); + return [self::KEY]; } } diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php index 59e77c3e9..5a63c2e7a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php @@ -19,8 +19,6 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte { /** * {@inheritdoc} - * - * @phpstan-ignore-next-line */ public function load(array $configs, ContainerBuilder $container): void { @@ -111,4 +109,4 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte ] ]); } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php index 902ed7a68..668c95f0f 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php @@ -30,7 +30,9 @@ final class CategoryRender implements ChillEntityRenderInterface { $options = array_merge(self::DEFAULT_ARGS, $options); - $titles[] = $this->translatableStringHelper->localize($asideActivityCategory->getTitle()); + $titles = [ + $this->translatableStringHelper->localize($asideActivityCategory->getTitle()), + ]; while ($asideActivityCategory->hasParent()) { $asideActivityCategory = $asideActivityCategory->getParent(); diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index a62963e07..03a6188a1 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -97,9 +97,9 @@ class CalendarController extends AbstractController 'calendarItems' => $calendarItems, 'user' => $user ]); + } - } elseif ($accompanyingPeriod instanceof AccompanyingPeriod) { - + if ($accompanyingPeriod instanceof AccompanyingPeriod) { $total = $this->calendarRepository->countByAccompanyingPeriod($accompanyingPeriod); $paginator = $this->paginator->create($total); $calendarItems = $this->calendarRepository->findBy( @@ -117,6 +117,8 @@ class CalendarController extends AbstractController 'paginator' => $paginator ]); } + + throw new \Exception('Unable to list actions.'); } /** diff --git a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/ChillCustomFieldsExtension.php b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/ChillCustomFieldsExtension.php index f6aabc0f1..44af7a6fe 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/ChillCustomFieldsExtension.php +++ b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/ChillCustomFieldsExtension.php @@ -28,27 +28,31 @@ class ChillCustomFieldsExtension extends Extension implements PrependExtensionIn $loader->load('services/fixtures.yaml'); $loader->load('services/controller.yaml'); $loader->load('services/command.yaml'); - + //add at least a blank array at 'customizable_entities' options - //$customizable_entities = (isset($config['customizables_entities']) - // && $config['customizables_entities'] !== FALSE) + //$customizable_entities = (isset($config['customizables_entities']) + // && $config['customizables_entities'] !== FALSE) // ? $config['customizables_entities'] : array(); - - $container->setParameter('chill_custom_fields.customizables_entities', + + $container->setParameter('chill_custom_fields.customizables_entities', $config['customizables_entities']); - $container->setParameter('chill_custom_fields.show_empty_values', + $container->setParameter('chill_custom_fields.show_empty_values', $config['show_empty_values_in_views']); } - + /* (non-PHPdoc) * @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend() */ - public function prepend(ContainerBuilder $container) + public function prepend(ContainerBuilder $container) { // add form layout to twig resources - $twigConfig['form_themes'][] = 'ChillCustomFieldsBundle:Form:fields.html.twig'; + $twigConfig = [ + 'form_themes' => [ + 'ChillCustomFieldsBundle:Form:fields.html.twig', + ], + ]; $container->prependExtensionConfig('twig', $twigConfig); - + //add routes for custom bundle $container->prependExtensionConfig('chill_main', array( 'routing' => array( diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index 93068de3f..d82d8a0a7 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -145,5 +145,7 @@ class DocGeneratorTemplateController extends AbstractController } catch (TransferException $e) { throw $e; } + + throw new \Exception('Unable to generate document.'); } } diff --git a/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php index 383529f52..7b7f1c1b1 100644 --- a/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php +++ b/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php @@ -1,8 +1,10 @@ logger = $logger; } - + /** * Show a form to add a participation - * + * * This function parse the person_id / persons_ids query argument * and decide if it should process a single or multiple participation. Depending * on this, the appropriate layout and form. @@ -67,46 +67,46 @@ class ParticipationController extends AbstractController */ public function newAction(Request $request) { - + // test the request is correct try { $this->testRequest($request); } catch (\RuntimeException $ex) { $this->logger->warning($ex->getMessage()); - + return (new Response()) ->setStatusCode(Response::HTTP_BAD_REQUEST) ->setContent($ex->getMessage()); } - + // forward to other action $single = $request->query->has('person_id'); $multiple = $request->query->has('persons_ids'); - + if ($single === true) { return $this->newSingle($request); } - + if ($multiple === true) { - + return $this->newMultiple($request); } - + // at this point, we miss the required fields. Throw an error return (new Response()) ->setStatusCode(Response::HTTP_BAD_REQUEST) ->setContent("You must provide either 'person_id' or " . "'persons_ids' argument in query"); } - + /** - * + * * Test that the query parameters are valid : - * + * * - an `event_id` is existing ; * - `person_id` and `persons_ids` are **not** both present ; * - `persons_id` is correct (contains only numbers and a ','. - * + * * @param Request $request * @throws \RuntimeException if an error is detected */ @@ -114,64 +114,64 @@ class ParticipationController extends AbstractController { $single = $request->query->has('person_id'); $multiple = $request->query->has('persons_ids'); - + if ($single === true AND $multiple === true) { // we are not allowed to have both person_id and persons_ids throw new \RuntimeException("You are not allow to provide both 'person_id' and " . "'persons_ids' simulaneously"); } - + if ($multiple === true) { $persons_ids = $request->query->get('persons_ids'); - + if (!preg_match('/^([0-9]{1,},{0,1}){1,}[0-9]{0,}$/', $persons_ids)) { throw new \RuntimeException("The persons_ids value should " . "contains int separated by ','"); } } - + // check for event_id - this could be removed later if ($request->query->has('event_id') === FALSE) { throw new \RuntimeException("You must provide an event_id"); } - + } - + /** * Show a form with single participation. - * + * * @param Request $request * @return Response */ protected function newSingle(Request $request) { - + $returnPath = $request->query->get('return_path') ? $request->query->get('return_path') : null; - + $participation = $this->handleRequest($request, new Participation(), false); - - $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, + + $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); - + $form = $this->createCreateForm($participation, $returnPath); - + return $this->render('ChillEventBundle:Participation:new.html.twig', array( 'form' => $form->createView(), 'participation' => $participation, 'ignored_participations' => array() // this is required, see self::newMultiple )); } - + /** * Show a form with multiple participation. - * + * * If a person is already participating on the event (if a participation with * the same person is associated with the event), the participation is ignored. - * + * * If all but one participation is ignored, the page show the same response - * than the newSingle function. - * + * than the newSingle function. + * * If all participations must be ignored, an error is shown and the method redirects * to the event 'show' view with an appropriate flash message. * @@ -181,24 +181,24 @@ class ParticipationController extends AbstractController protected function newMultiple(Request $request) { $participations = $this->handleRequest($request, new Participation(), true); - - + $ignoredParticipations = $newParticipations = []; + foreach ($participations as $i => $participation) { // check for authorization - $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, + $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); - + // create a collection of person's id participating to the event /* @var $peopleParticipating \Doctrine\Common\Collections\ArrayCollection */ $peopleParticipating = isset($peopleParticipating) ? $peopleParticipating : $participation->getEvent()->getParticipations()->map( function(Participation $p) { return $p->getPerson()->getId(); } ); - // check that the user is not already in the event + // check that the user is not already in the event if ($peopleParticipating->contains($participation->getPerson()->getId())) { $ignoredParticipations[] = $participation ->getEvent()->getParticipations()->filter( - function (Participation $p) use ($participation) { + function (Participation $p) use ($participation) { return $p->getPerson()->getId() === $participation->getPerson()->getId(); } )->first(); @@ -206,15 +206,15 @@ class ParticipationController extends AbstractController $newParticipations[] = $participation; } } - + // this is where the function redirect depending on valid participation - - if (!isset($newParticipations)) { + + if ([] === $newParticipations) { // if we do not have nay participants, redirect to event view $this->addFlash('error', $this->get('translator')->trans( 'None of the requested people may participate ' . 'the event: they are maybe already participating.')); - + return $this->redirectToRoute('chill_event__event_show', array( 'event_id' => $request->query->getInt('event_id', 0) )); @@ -222,24 +222,29 @@ class ParticipationController extends AbstractController // if we have multiple participations, show a form with multiple participations $form = $this->createCreateFormMultiple($newParticipations); - return $this->render('ChillEventBundle:Participation:new-multiple.html.twig', array( + return $this->render( + 'ChillEventBundle:Participation:new-multiple.html.twig', + [ 'form' => $form->createView(), 'participations' => $newParticipations, - 'ignored_participations' => isset($ignoredParticipations) ? $ignoredParticipations : array() - )); - } else { - // if we have only one participation, show the same form than for single participation - $form = $this->createCreateForm($participation); - - return $this->render('ChillEventBundle:Participation:new.html.twig', array( + 'ignored_participations' => $ignoredParticipations + ] + ); + } + + // if we have only one participation, show the same form than for single participation + $form = $this->createCreateForm($participation); + + return $this->render( + 'ChillEventBundle:Participation:new.html.twig', + [ 'form' => $form->createView(), 'participation' => $participation, - 'ignored_participations' => isset($ignoredParticipations) ? $ignoredParticipations : array() - )); - - } + 'ignored_participations' => $ignoredParticipations, + ] + ); } - + /** * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response @@ -251,32 +256,32 @@ class ParticipationController extends AbstractController $this->testRequest($request); } catch (\RuntimeException $ex) { $this->logger->warning($ex->getMessage()); - + return (new Response()) ->setStatusCode(Response::HTTP_BAD_REQUEST) ->setContent($ex->getMessage()); } - + // forward to other action $single = $request->query->has('person_id'); $multiple = $request->query->has('persons_ids'); - + if ($single === true) { return $this->createSingle($request); } - + if ($multiple === true) { - + return $this->createMultiple($request); } - + // at this point, we miss the required fields. Throw an error return (new Response()) ->setStatusCode(Response::HTTP_BAD_REQUEST) ->setContent("You must provide either 'person_id' or " . "'persons_ids' argument in query"); } - + /** * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response @@ -284,41 +289,41 @@ class ParticipationController extends AbstractController public function createSingle(Request $request) { $participation = $this->handleRequest($request, new Participation(), false); - - $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, + + $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); - + $form = $this->createCreateForm($participation); $form->handleRequest($request); - + if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); - + $em->persist($participation); $em->flush(); - + $this->addFlash('success', $this->get('translator')->trans( 'The participation was created' )); - + if ($request->query->get('return_path')) { return $this->redirect($request->query->get('return_path')); - + } else { return $this->redirectToRoute('chill_event__event_show', array( 'event_id' => $participation->getEvent()->getId() )); } - + } - + return $this->render('ChillEventBundle:Participation:new.html.twig', array( 'form' => $form->createView(), 'participation' => $participation )); } - + /** * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response @@ -326,56 +331,56 @@ class ParticipationController extends AbstractController public function createMultiple(Request $request) { $participations = $this->handleRequest($request, new Participation(), true); - + foreach($participations as $participation) { - $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, + $this->denyAccessUnlessGranted(ParticipationVoter::CREATE, $participation, 'The user is not allowed to create this participation'); } - + $form = $this->createCreateFormMultiple($participations); $form->handleRequest($request); - + if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $data = $form->getData(); - + foreach($data['participations'] as $participation) { $em->persist($participation); } - + $em->flush(); - + $this->addFlash('success', $this->get('translator')->trans( 'The participations were created' )); - + return $this->redirectToRoute('chill_event__event_show', array( 'event_id' => $participations[0]->getEvent()->getId() )); } - + return $this->render('ChillEventBundle:Participation:new.html.twig', array( 'form' => $form->createView(), 'participation' => $participation )); } - + /** - * + * * Handle the request to adapt $participation. - * - * If the request is multiple, the $participation object is cloned. + * + * If the request is multiple, the $participation object is cloned. * Limitations: the $participation should not be persisted. - * + * * @param Request $request * @param Participation $participation - * @param boolean $multiple (default false) + * @param boolean $multiple (default false) * @return Participation|Participations[] return one single participation if $multiple == false * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the event/person is not found * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException if the user does not have access to event/person */ protected function handleRequest( - Request $request, + Request $request, Participation $participation, $multiple = false) { @@ -384,37 +389,37 @@ class ParticipationController extends AbstractController throw new \LogicException("The participation object should not be managed by " . "the object manager using the method ".__METHOD__); } - + $event_id = $request->query->getInt('event_id', 0); // sf4 check: // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` - + if ($event_id !== NULL) { $event = $em->getRepository('ChillEventBundle:Event') ->find($event_id); - + if ($event === NULL) { throw $this->createNotFoundException('The event with id '.$event_id.' is not found'); } - - $this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, + + $this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, 'The user is not allowed to see the event'); - + $participation->setEvent($event); } - - // this script should be able to handle multiple, so we translate + + // this script should be able to handle multiple, so we translate // single person_id in an array $persons_ids = $request->query->has('person_id') ? [$request->query->getInt('person_id', 0)] // sf4 check: // prevent error: `Argument 2 passed to ::getInt() must be of the type int, null given` : explode(',', $request->query->get('persons_ids')); $participations = array(); - + foreach($persons_ids as $person_id) { - + // clone if we have to reuse the $participation $participation = count($persons_ids) > 1 ? clone $participation : $participation; - + if ($person_id !== NULL) { $person = $em->getRepository('ChillPersonBundle:Person') ->find($person_id); @@ -428,13 +433,13 @@ class ParticipationController extends AbstractController $participation->setPerson($person); } - + $participations[] = $participation; } - + return $multiple ? $participations : $participations[0]; } - + /** * @param Participation $participation * @param null $return_path @@ -442,7 +447,7 @@ class ParticipationController extends AbstractController */ public function createCreateForm(Participation $participation, $return_path = null) { - + $form = $this->createForm(ParticipationType::class, $participation, array( 'event_type' => $participation->getEvent()->getType(), 'action' => $this->generateUrl('chill_event_participation_create', array( @@ -451,14 +456,14 @@ class ParticipationController extends AbstractController 'person_id' => $participation->getPerson()->getId() )) )); - + $form->add('submit', SubmitType::class, array( 'label' => 'Create' )); - + return $form; } - + /** * @param array $participations * @return \Symfony\Component\Form\FormInterface @@ -470,7 +475,7 @@ class ParticipationController extends AbstractController 'action' => $this->generateUrl('chill_event_participation_create', array( 'event_id' => current($participations)->getEvent()->getId(), 'persons_ids' => implode(',', array_map( - function(Participation $p) { return $p->getPerson()->getId(); }, + function(Participation $p) { return $p->getPerson()->getId(); }, $participations)) ) ))); @@ -481,90 +486,90 @@ class ParticipationController extends AbstractController ), ) ); - + $form->add('submit', SubmitType::class, array( 'label' => 'Create' )); - + return $form; } - + /** * show an edit form for the participation with the given id. - * + * * @param int $participation_id * @return \Symfony\Component\HttpFoundation\Response * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the participation is not found * @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException if the user is not allowed to edit the participation */ - public function editAction($participation_id) + public function editAction($participation_id) { /* @var $participation Participation */ $participation = $this->getDoctrine()->getManager() ->getRepository('ChillEventBundle:Participation') ->find($participation_id); - + if ($participation === NULL) { throw $this->createNotFoundException('The participation is not found'); } - - $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, + + $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, 'You are not allowed to edit this participation'); - + $form = $this->createEditForm($participation); - + return $this->render('ChillEventBundle:Participation:edit.html.twig', array( 'form' => $form->createView(), 'participation' => $participation )); } - + /** * @param $participation_id * @param Request $request * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response */ - public function updateAction($participation_id, Request $request) + public function updateAction($participation_id, Request $request) { /* @var $participation Participation */ $participation = $this->getDoctrine()->getManager() ->getRepository('ChillEventBundle:Participation') ->find($participation_id); - + if ($participation === NULL) { throw $this->createNotFoundException('The participation is not found'); } - - $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, + + $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, 'You are not allowed to edit this participation'); - + $form = $this->createEditForm($participation); - + $form->handleRequest($request); - + if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); - + $em->flush(); - + $this->addFlash('success', $this->get('translator')->trans( 'The participation was updated' )); - + return $this->redirectToRoute('chill_event__event_show', array( 'event_id' => $participation->getEvent()->getId() )); - + } - + return $this->render('ChillEventBundle:Participation:edit.html.twig', array( 'form' => $form->createView(), 'participation' => $participation )); } - + /** - * + * * @param Participation $participation * @return \Symfony\Component\Form\FormInterface */ @@ -576,14 +581,14 @@ class ParticipationController extends AbstractController 'participation_id' => $participation->getId() )) )); - + $form->add('submit', SubmitType::class, array( 'label' => 'Edit' )); - + return $form; } - + /** * show a form to edit multiple participation for the same event. * @@ -594,84 +599,84 @@ class ParticipationController extends AbstractController { $event = $this->getDoctrine()->getRepository('ChillEventBundle:Event') ->find($event_id); - + if ($event === null) { throw $this->createNotFoundException("The event with id $event_id is not found"); } - + // check for ACL, on Event level and on Participation Level $this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, "You are not allowed " . "to see this event"); foreach ($event->getParticipations() as $participation) { - $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, + $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, "You are not allowed to update participation with id ".$participation->getId()); } - - + + switch ($event->getParticipations()->count()) { - + case 0: // if there aren't any participation, redirect to the 'show' view with an add flash $this->addFlash('warning', $this->get('translator') ->trans( "There are no participation to edit for this event")); - return $this->redirectToRoute('chill_event__event_show', + return $this->redirectToRoute('chill_event__event_show', array('event_id' => $event->getId())); - + case 1: // redirect to the form for a single participation return $this->redirectToRoute('chill_event_participation_edit', array( 'participation_id' => $event->getParticipations()->current()->getId() )); - } - + } + $form = $this->createEditFormMultiple($event->getParticipations(), $event); - + return $this->render('ChillEventBundle:Participation:edit-multiple.html.twig', array( 'event' => $event, 'participations' => $event->getParticipations(), 'form' => $form->createView() )); } - + public function updateMultipleAction($event_id, Request $request) { /* @var $event \Chill\EventBundle\Entity\Event */ $event = $this->getDoctrine()->getRepository('ChillEventBundle:Event') ->find($event_id); - + if ($event === null) { throw $this->createNotFoundException("The event with id $event_id is not found"); } - + $this->denyAccessUnlessGranted('CHILL_EVENT_SEE', $event, "You are not allowed " . "to see this event"); foreach ($event->getParticipations() as $participation) { - $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, + $this->denyAccessUnlessGranted(ParticipationVoter::UPDATE, $participation, "You are not allowed to update participation with id ".$participation->getId()); } - + $form = $this->createEditFormMultiple($event->getParticipations(), $event); - + $form->handleRequest($request); - + if ($form->isSubmitted() && $form->isValid()) { $this->getDoctrine()->getManager()->flush(); - + $this->addFlash('success', $this->get('translator')->trans("The participations " . "have been successfully updated.")); - - return $this->redirectToRoute('chill_event__event_show', + + return $this->redirectToRoute('chill_event__event_show', array('event_id' => $event->getId())); } - + return $this->render('ChillEventBundle:Participation:edit-multiple.html.twig', array( 'event' => $event, 'participations' => $event->getParticipations(), 'form' => $form->createView() )); } - + /** * @param ArrayIterator $participations * @param Event $event @@ -679,14 +684,14 @@ class ParticipationController extends AbstractController */ protected function createEditFormMultiple(ArrayIterator $participations, Event $event) { - $form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class, + $form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class, array('participations' => $participations), array( 'method' => 'POST', 'action' => $this->generateUrl('chill_event_participation_update_multiple', array( 'event_id' => $event->getId() )) )); - + $form->add('participations', CollectionType::class, array( 'entry_type' => ParticipationType::class, 'entry_options' => array( @@ -694,14 +699,14 @@ class ParticipationController extends AbstractController ), ) ); - + $form->add('submit', SubmitType::class, array( 'label' => 'Update' )); - + return $form; } - + /** * @param integer $participation_id * @param Request $request @@ -713,28 +718,28 @@ class ParticipationController extends AbstractController $participation = $em->getRepository('ChillEventBundle:Participation')->findOneBy([ 'id' => $participation_id ]); - + if (! $participation) { throw $this->createNotFoundException('Unable to find participation.'); } - + /** @var Event $event */ $event = $participation->getEvent(); - + $form = $this->createDeleteForm($participation_id); - + if ($request->getMethod() === Request::METHOD_DELETE) { $form->handleRequest($request); - + if ($form->isValid()) { - + $em->remove($participation); $em->flush(); - + $this->addFlash('success', $this->get('translator') ->trans("The participation has been sucessfully removed") ); - + return $this->redirectToRoute('chill_event__event_show', [ 'event_id' => $event->getId() ]); @@ -744,9 +749,9 @@ class ParticipationController extends AbstractController 'event_id' => $event->getId(), 'delete_form' => $form->createView() ]); - + } - + /** * @param $participation_id * @return \Symfony\Component\Form\FormInterface @@ -762,5 +767,5 @@ class ParticipationController extends AbstractController ->getForm() ; } - + } diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php index 359ff0384..e3717f654 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php @@ -504,6 +504,8 @@ class ApiController extends AbstractCRUDController $this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData]) ); } + + throw new \Exception('Unable to handle such request method.'); } /** diff --git a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php index 036ad1de7..443f4b52f 100644 --- a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php +++ b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php @@ -10,18 +10,18 @@ use Symfony\Component\Console\Output\OutputInterface; /** * * @author Julien Fastré availableLanguages=$availableLanguages; parent::__construct(); } - + /* * (non-PHPdoc) * @see \Symfony\Component\Console\Command\Command::configure() @@ -45,7 +45,7 @@ class LoadCountriesCommand extends Command ->setDescription('Load or update countries in db. This command does not delete existing countries, '. 'but will update names according to available languages'); } - + /* * (non-PHPdoc) * @see \Symfony\Component\Console\Command\Command::execute() @@ -54,43 +54,44 @@ class LoadCountriesCommand extends Command { $countries = static::prepareCountryList($this->availableLanguages); $em = $this->entityManager; - + foreach($countries as $country) { $countryStored = $em->getRepository('ChillMainBundle:Country') ->findOneBy(array('countryCode' => $country->getCountryCode())); - + if (NULL === $countryStored) { $em->persist($country); } else { $countryStored->setName($country->getName()); } } - + $em->flush(); } public static function prepareCountryList($languages) { $regionBundle = Intl::getRegionBundle(); - + $countries = []; + foreach ($languages as $language) { $countries[$language] = $regionBundle->getCountryNames($language); } - + $countryEntities = array(); - + foreach ($countries[$languages[0]] as $countryCode => $name) { $names = array(); - + foreach ($languages as $language) { $names[$language] = $countries[$language][$countryCode]; } - + $country = new \Chill\MainBundle\Entity\Country(); $country->setName($names)->setCountryCode($countryCode); $countryEntities[] = $country; } - + return $countryEntities; } } diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php index a048b6b9f..e9e679392 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php @@ -24,26 +24,26 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface, // Array of ancien languages (to exclude) private $ancientToExclude = ["ang", "egy", "fro", "goh", "grc", "la", "non", "peo", "pro", "sga", "dum", "enm", "frm", "gmh", "mga", "akk", "phn", "zxx", "got", "und"]; - + /** - * + * * @var ContainerInterface */ private $container; - + public function setContainer(ContainerInterface $container = null) { $this->container = $container; } - + public function getOrder() { return 10; } - + public function load(ObjectManager $manager) { - + echo "loading languages... \n"; - + foreach (Intl::getLanguageBundle()->getLanguageNames() as $code => $language) { if ( !in_array($code, $this->regionalVersionToInclude) @@ -58,23 +58,24 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface, $manager->persist($lang); } } - + $manager->flush(); } - + /** - * prepare names for languages - * - * @param string $languageCode + * Prepare names for languages. + * * @return string[] languages name indexed by available language code */ - private function prepareName($languageCode) { + private function prepareName(string $languageCode): array { + $names = []; + foreach ($this->container->getParameter('chill_main.available_languages') as $lang) { $names[$lang] = Intl::getLanguageBundle()->getLanguageName($languageCode); } - + return $names; } - + } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ACLFlagsCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ACLFlagsCompilerPass.php index 9197ddb83..91dff76ad 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ACLFlagsCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ACLFlagsCompilerPass.php @@ -1,35 +1,32 @@ - */ class ACLFlagsCompilerPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { $permissionGroupType = $container->getDefinition(PermissionsGroupType::class); - + foreach($container->findTaggedServiceIds('chill_main.flags') as $id => $tags) { $reference = new Reference($id); - + foreach ($tags as $tag) { switch($tag['scope']) { case PermissionsGroupType::FLAG_SCOPE: - + $permissionGroupType->addMethodCall('addFlagProvider', [ $reference ]); break; default: - throw new \LogicalException(sprintf( + throw new LogicException(sprintf( "This tag 'scope' is not implemented: %s, on service with id %s", $tag['scope'], $id) ); } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index e75488ba6..be1281ee6 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -19,14 +19,11 @@ class Configuration implements ConfigurationInterface use AddWidgetConfigurationTrait; - /** - * - * @var ContainerBuilder - */ - private $containerBuilder; + private ContainerBuilder $containerBuilder; - public function __construct(array $widgetFactories = array(), + public function __construct( + array $widgetFactories, ContainerBuilder $containerBuilder) { $this->setWidgetFactories($widgetFactories); diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php index d26e09293..e0dffdb21 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php @@ -30,27 +30,27 @@ use Chill\MainBundle\DependencyInjection\Widget\HasWidgetFactoriesExtensionInter /** * Compile the configurations and inject required service into container. - * + * * The widgets are services tagged with : - * + * * ``` * { name: chill_widget, alias: my_alias, place: my_place } * ``` - * - * Or, if the tag does not exist or if you need to add some config to your + * + * Or, if the tag does not exist or if you need to add some config to your * service depending on the config, you should use a `WidgetFactory` (see * `WidgetFactoryInterface`. - * - * To reuse this compiler pass, simple execute the doProcess metho in your + * + * To reuse this compiler pass, simple execute the doProcess metho in your * compiler. Example : - * + * * ``` * namespace Chill\MainBundle\DependencyInjection\CompilerPass; - * + * * use Symfony\Component\DependencyInjection\ContainerBuilder; * use Chill\MainBundle\DependencyInjection\Widget\AbstractWidgetsCompilerPass; * class WidgetsCompilerPass extends AbstractWidgetsCompilerPass { - * + * * public function process(ContainerBuilder $container) * { * $this->doProcess($container, 'chill_main', 'chill_main.widgets'); @@ -58,58 +58,58 @@ use Chill\MainBundle\DependencyInjection\Widget\HasWidgetFactoriesExtensionInter * } * ``` * - * + * */ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface { private $widgetServices = array(); - + /** * * @var WidgetFactoryInterface[] */ private $widgetFactories; - + /** * The service which will manage the widgets - * + * * @var string */ const WIDGET_MANAGER = 'chill.main.twig.widget'; - + /** * the method wich register the widget into give service. */ const WIDGET_MANAGER_METHOD_REGISTER = 'addWidget'; - + /** * the value of the `name` key in service definitions's tag - * + * * @var string */ const WIDGET_SERVICE_TAG_NAME = 'chill_widget'; - + /** - * the key used to collect the alias in the service definition's tag. - * the alias must be + * the key used to collect the alias in the service definition's tag. + * the alias must be * injected into the configuration under 'alias' key. - * + * * @var string */ const WIDGET_SERVICE_TAG_ALIAS = 'alias'; - + /** * the key used to collect the authorized place in the service definition's tag - * + * * @var string */ const WIDGET_SERVICE_TAG_PLACES = 'place'; - + /** * the key to use to order widget for a given place */ const WIDGET_CONFIG_ORDER = 'order'; - + /** * the key to use to identify widget for a given place */ @@ -118,24 +118,25 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface /** * process the configuration and the container to add the widget available - * + * * @param ContainerBuilder $container * @param string $extension the extension of your bundle * @param string $containerWidgetConfigParameterName the key under which we can use the widget configuration * @throws \LogicException * @throws \UnexpectedValueException if the given extension does not implement HasWidgetExtensionInterface - * @throws \InvalidConfigurationException if there are errors in the config */ - public function doProcess(ContainerBuilder $container, $extension, - $containerWidgetConfigParameterName) - { + public function doProcess( + ContainerBuilder $container, + $extension, + $containerWidgetConfigParameterName + ) { if (!$container->hasDefinition(self::WIDGET_MANAGER)) { throw new \LogicException("the service ".self::WIDGET_MANAGER." should". " be present. It is required by ".self::class); } - + $managerDefinition = $container->getDefinition(self::WIDGET_MANAGER); - + // collect the widget factories /* @var $extensionClass HasWidgetFactoriesExtensionInterface */ $extensionClass = $container->getExtension($extension); @@ -148,19 +149,19 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface HasWidgetFactoriesExtensionInterface::class, get_class($extensionClass))); } - - + + $this->widgetFactories = $extensionClass->getWidgetFactories(); - + // collect the availabled tagged services $this->collectTaggedServices($container); - + // collect the widgets and their config : $widgetParameters = $container->getParameter($containerWidgetConfigParameterName); - + // and add them to the delegated_block foreach($widgetParameters as $place => $widgets) { - + foreach ($widgets as $param) { $alias = $param[self::WIDGET_CONFIG_ALIAS]; // check that the service exists @@ -168,43 +169,43 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface throw new InvalidConfigurationException(sprintf("The alias %s". " is not defined.", $alias)); } - + // check that the widget is allowed at this place if (!$this->isPlaceAllowedForWidget($place, $alias, $container)) { - throw new \InvalidConfigurationException(sprintf( + throw new InvalidConfigurationException(sprintf( "The widget with alias %s is not allowed at place %s", - $alias, + $alias, $place )); } - + // get the order, eventually corrected - $order = $this->cacheAndGetOrdering($place, $param[self::WIDGET_CONFIG_ORDER]); - + $order = $this->cacheAndGetOrdering($place, $param[self::WIDGET_CONFIG_ORDER]); + // register the widget with config to the service, using the method // `addWidget` if ($this->widgetServices[$alias] instanceof WidgetFactoryInterface) { /* @var $factory WidgetFactoryInterface */ $factory = $this->widgetServices[$alias]; // get the config (under the key which equals to widget_alias - $config = isset($param[$factory->getWidgetAlias()]) ? + $config = isset($param[$factory->getWidgetAlias()]) ? $param[$factory->getWidgetAlias()] : array(); // register the service into the container - $serviceId =$this->registerServiceIntoContainer($container, + $serviceId =$this->registerServiceIntoContainer($container, $factory, $place, $order, $config); - + $managerDefinition->addMethodCall(self::WIDGET_MANAGER_METHOD_REGISTER, array( - $place, - $order, - new Reference($serviceId), + $place, + $order, + new Reference($serviceId), $config )); } else { $managerDefinition->addMethodCall(self::WIDGET_MANAGER_METHOD_REGISTER, array( - $place, - $order, + $place, + $order, new Reference($this->widgetServices[$alias]), array() // the config is alway an empty array )); @@ -212,10 +213,10 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface } } } - + /** * register the service into container. - * + * * @param ContainerBuilder $container * @param WidgetFactoryInterface $factory * @param string $place @@ -231,28 +232,28 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface array $config ) { $serviceId = $factory->getServiceId($container, $place, $order, $config); - $definition = $factory->createDefinition($container, $place, + $definition = $factory->createDefinition($container, $place, $order, $config); $container->setDefinition($serviceId, $definition); - + return $serviceId; } - + /** * cache of ordering by place. - * + * * @internal used by function cacheAndGetOrdering * @var array */ private $cacheOrdering = array(); - + /** * check if the ordering has already be used for the given $place and, * if yes, correct the ordering by incrementation of 1 until the ordering * has not be used. - * + * * recursive method. - * + * * @param string $place * @param float $ordering * @return float @@ -262,7 +263,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface if (!array_key_exists($place, $this->cacheOrdering)) { $this->cacheOrdering[$place] = array(); } - + // check if the order exists if (array_search($ordering, $this->cacheOrdering[$place])) { // if the order exists, increment of 1 and try again @@ -270,14 +271,14 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface } else { // cache the ordering $this->cacheOrdering[$place][] = $ordering; - + return $ordering; } } - + /** * get the places where the service is allowed - * + * * @param Definition $definition * @return unknown */ @@ -288,7 +289,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface ->getAllowedPlaces())) { return true; } - + } else { $definition = $container->findDefinition($this->widgetServices[$widgetAlias]); @@ -300,17 +301,17 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface } } } - + return false; } - + /** * This method collect all service tagged with `self::WIDGET_SERVICE_TAG`, and * add also the widget defined by factories - * + * * This method also check that the service is correctly tagged with `alias` and * `places`, or the factory give a correct alias and more than one place. - * + * * @param ContainerBuilder $container * @throws InvalidConfigurationException * @throws InvalidArgumentException @@ -320,13 +321,13 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface // first, check the service tagged in service definition foreach ($container->findTaggedServiceIds(self::WIDGET_SERVICE_TAG_NAME) as $id => $attrs) { foreach ($attrs as $attr) { - + // check the alias is set if (!isset($attr[self::WIDGET_SERVICE_TAG_ALIAS])) { throw new InvalidConfigurationException("you should add an ".self::WIDGET_SERVICE_TAG_ALIAS. " key on the service ".$id); } - + // check the place is set if (!isset($attr[self::WIDGET_SERVICE_TAG_PLACES])) { throw new InvalidConfigurationException(sprintf( @@ -335,54 +336,54 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface $id )); } - + // check the alias does not exists yet if (array_key_exists($attr[self::WIDGET_SERVICE_TAG_ALIAS], $this->widgetServices)) { throw new InvalidArgumentException("a service has already be defined with the ". self::WIDGET_SERVICE_TAG_ALIAS." ".$attr[self::WIDGET_SERVICE_TAG_ALIAS]); } - + // register the service as available $this->widgetServices[$attr[self::WIDGET_SERVICE_TAG_ALIAS]] = $id; } } - + // add the services defined by factories foreach($this->widgetFactories as $factory) { /* @var $factory WidgetFactoryInterface */ $alias = $factory->getWidgetAlias(); - + // check the alias is not empty if (empty($alias)) { throw new \LogicException(sprintf( "the widget factory %s returns an empty alias", get_class($factory))); } - + // check the places are not empty if (!is_array($factory->getAllowedPlaces())) { throw new \UnexpectedValueException("the method 'getAllowedPlaces' " . "should return a non-empty array. Unexpected value on ". get_class($factory)); } - + if (count($factory->getAllowedPlaces()) == 0) { throw new \LengthException("The method 'getAllowedPlaces' should " . "return a non-empty array, but returned 0 elements on ". get_class($factory).'::getAllowedPlaces()'); } - + // check the alias does not exists yet if (array_key_exists($alias, $this->widgetServices)) { throw new InvalidArgumentException("a service has already be defined with the ". self::WIDGET_SERVICE_TAG_ALIAS." ".$alias); } - + // register the factory as available $this->widgetServices[$factory->getWidgetAlias()] = $factory; - + } } - - -} \ No newline at end of file + + +} diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php index 2e6f83a69..20b59fbb7 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php @@ -4,13 +4,9 @@ namespace Chill\MainBundle\Doctrine\Model; use \JsonSerializable; -/** - * Description of Point - * - */ class Point implements JsonSerializable { - private ?float $lat = null; - private ?float $lon = null; + private ?float $lat; + private ?float $lon; public static string $SRID = '4326'; private function __construct(?float $lon, ?float $lat) @@ -22,6 +18,7 @@ class Point implements JsonSerializable { public function toGeoJson(): string { $array = $this->toArrayGeoJson(); + return \json_encode($array); } @@ -33,60 +30,53 @@ class Point implements JsonSerializable { public function toArrayGeoJson(): array { return [ - "type" => "Point", - "coordinates" => [ $this->lon, $this->lat ] + 'type' => 'Point', + 'coordinates' => [$this->lon, $this->lat], ]; } - /** - * - * @return string - */ public function toWKT(): string { - return 'SRID='.self::$SRID.';POINT('.$this->lon.' '.$this->lat.')'; + return sprintf("SRID=%s;POINT(%s %s)", self::$SRID, $this->lon, $this->lat); } - /** - * - * @param type $geojson - * @return Point - */ - public static function fromGeoJson(string $geojson): Point + public static function fromGeoJson(string $geojson): self { $a = json_decode($geojson); - //check if the geojson string is correct - if (NULL === $a or !isset($a->type) or !isset($a->coordinates)){ + + if (null === $a) { throw PointException::badJsonString($geojson); } - if ($a->type != 'Point'){ + if (null === $a->type || null === $a->coordinates) { + throw PointException::badJsonString($geojson); + } + + if ($a->type !== 'Point'){ throw PointException::badGeoType(); } - $lat = $a->coordinates[1]; - $lon = $a->coordinates[0]; + [$lon, $lat] = $a->coordinates; return Point::fromLonLat($lon, $lat); } - public static function fromLonLat(float $lon, float $lat): Point + public static function fromLonLat(float $lon, float $lat): self { - if (($lon > -180 && $lon < 180) && ($lat > -90 && $lat < 90)) - { + if (($lon > -180 && $lon < 180) && ($lat > -90 && $lat < 90)) { return new Point($lon, $lat); - } else { - throw PointException::badCoordinates($lon, $lat); } + + throw PointException::badCoordinates($lon, $lat); } - public static function fromArrayGeoJson(array $array): Point + public static function fromArrayGeoJson(array $array): self { - if ($array['type'] == 'Point' && - isset($array['coordinates'])) - { + if ($array['type'] === 'Point' && isset($array['coordinates'])) { return self::fromLonLat($array['coordinates'][0], $array['coordinates'][1]); } + + throw new \Exception('Unable to build a point from input data.'); } public function getLat(): float diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php index c088edeba..581a40bcc 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/CenterTransformer.php @@ -51,8 +51,10 @@ class CenterTransformer implements DataTransformerInterface } } + $ids = []; + if ($this->multiple) { - $ids = \explode(',', $id); + $ids = explode(',', $id); } else { $ids[] = (int) $id; } @@ -68,9 +70,9 @@ class CenterTransformer implements DataTransformerInterface if ($this->multiple) { return new ArrayCollection($centers); - } else { - return $centers[0]; } + + return $centers[0]; } public function transform($center) diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php index 825a1600e..80a9a08a5 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Repository; +use Chill\MainBundle\Entity\GroupCenter; use Chill\MainBundle\Entity\User; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; diff --git a/src/Bundle/ChillMainBundle/Search/SearchApi.php b/src/Bundle/ChillMainBundle/Search/SearchApi.php index d59193114..0a7aa1737 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchApi.php +++ b/src/Bundle/ChillMainBundle/Search/SearchApi.php @@ -139,7 +139,7 @@ class SearchApi return $nq->getResult(); } - private function prepareProviders($rawResults) + private function prepareProviders(array $rawResults) { $metadatas = []; foreach ($rawResults as $r) { @@ -156,8 +156,10 @@ class SearchApi } } - private function buildResults($rawResults) + private function buildResults(array $rawResults): array { + $items = []; + foreach ($rawResults as $r) { foreach ($this->providers as $k => $p) { if ($p->supportsResult($r['key'], $r['metadata'])) { @@ -170,6 +172,6 @@ class SearchApi } } - return $items ?? []; + return $items; } } diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php index 324f76b02..b6ba03621 100644 --- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php +++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverVoter.php @@ -98,5 +98,7 @@ class PasswordRecoverVoter extends Voter return true; } + + return false; } } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php index ee628e014..cd37ea989 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php @@ -1,5 +1,7 @@ getId(); - $data['text'] = $address->isNoAddress() ? '' : $address->getStreetNumber().', '.$address->getStreet(); - $data['street'] = $address->getStreet(); - $data['streetNumber'] = $address->getStreetNumber(); - $data['postcode']['id'] = $address->getPostCode()->getId(); - $data['postcode']['name'] = $address->getPostCode()->getName(); - $data['postcode']['code'] = $address->getPostCode()->getCode(); - $data['country']['id'] = $address->getPostCode()->getCountry()->getId(); - $data['country']['name'] = $address->getPostCode()->getCountry()->getName(); - $data['country']['code'] = $address->getPostCode()->getCountry()->getCountryCode(); - $data['floor'] = $address->getFloor(); - $data['corridor'] = $address->getCorridor(); - $data['steps'] = $address->getSteps(); - $data['flat'] = $address->getFlat(); - $data['buildingName'] = $address->getBuildingName(); - $data['distribution'] = $address->getDistribution(); - $data['extra'] = $address->getExtra(); - $data['validFrom'] = $address->getValidFrom(); - $data['validTo'] = $address->getValidTo(); - $data['addressReference'] = $this->normalizer->normalize($address->getAddressReference(), $format, [ - AbstractNormalizer::GROUPS => ['read'] - ]); + $data = [ + 'address_id' => $address->getId(), + 'text' => $address->isNoAddress() ? '' : $address->getStreetNumber().', '.$address->getStreet(), + 'street' => $address->getStreet(), + 'streetNumber' => $address->getStreetNumber(), + 'postcode' => [ + 'id' => $address->getPostCode()->getId(), + 'name' => $address->getPostCode()->getName(), + 'code' => $address->getPostCode()->getCode(), + ], + 'country' => [ + 'id' => $address->getPostCode()->getCountry()->getId(), + 'name' => $address->getPostCode()->getCountry()->getName(), + 'code' => $address->getPostCode()->getCountry()->getCountryCode(), + ], + 'floor' => $address->getFloor(), + 'corridor' => $address->getCorridor(), + 'steps' => $address->getSteps(), + 'flat' => $address->getFlat(), + 'buildingName' => $address->getBuildingName(), + 'distribution' => $address->getDistribution(), + 'extra' => $address->getExtra(), + 'validFrom' => $address->getValidFrom(), + 'validTo' => $address->getValidTo(), + 'addressReference' => $this->normalizer->normalize( + $address->getAddressReference(), + $format, + [AbstractNormalizer::GROUPS => ['read']] + ), + ]; return $data; } diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CollectionNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CollectionNormalizer.php index d3f513c54..a763a5675 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CollectionNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CollectionNormalizer.php @@ -9,32 +9,30 @@ use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; class CollectionNormalizer implements NormalizerInterface, NormalizerAwareInterface { - use NormalizerAwareTrait; + use NormalizerAwareTrait; + + /** + * @param Collection $collection + */ + public function normalize($collection, string $format = null, array $context = []) + { + $paginator = $collection->getPaginator(); + + return [ + 'count' => $paginator->getTotalItems(), + 'pagination' => [ + 'first' => $paginator->getCurrentPageFirstItemNumber(), + 'items_per_page' => $paginator->getItemsPerPage(), + 'next' => $paginator->hasNextPage() ? $paginator->getNextPage()->generateUrl() : null, + 'previous' => $paginator->hasPreviousPage() ? $paginator->getPreviousPage()->generateUrl() : null, + 'more' => $paginator->hasNextPage(), + ], + 'results' => $this->normalizer->normalize($collection->getItems(), $format, $context), + ]; + } public function supportsNormalization($data, string $format = null): bool { return $data instanceof Collection; } - - public function normalize($collection, string $format = null, array $context = []) - { - /** @var $collection Collection */ - $paginator = $collection->getPaginator(); - - $data['count'] = $paginator->getTotalItems(); - $pagination['first'] = $paginator->getCurrentPageFirstItemNumber(); - $pagination['items_per_page'] = $paginator->getItemsPerPage(); - $pagination['next'] = $paginator->hasNextPage() ? - $paginator->getNextPage()->generateUrl() : null; - $pagination['previous'] = $paginator->hasPreviousPage() ? - $paginator->getPreviousPage()->generateUrl() : null; - $pagination['more'] = $paginator->hasNextPage(); - $data['pagination'] = $pagination; - - // normalize results - $data['results'] = $this->normalizer->normalize($collection->getItems(), - $format, $context); - - return $data; - } } diff --git a/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php b/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php index e2e266a70..48afde21b 100644 --- a/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php +++ b/src/Bundle/ChillMainBundle/Timeline/TimelineBuilder.php @@ -291,11 +291,12 @@ class TimelineBuilder implements ContainerAwareInterface $entitiesByType[$result['type']][$result['id']], //the entity $context, $args); - $timelineEntry['date'] = new \DateTime($result['date']); - $timelineEntry['template'] = $data['template']; - $timelineEntry['template_data'] = $data['template_data']; - $timelineEntries[] = $timelineEntry; + $timelineEntries[] = [ + 'date' => new \DateTime($result['date']), + 'template' => $data['template'], + 'template_data' => $data['template_data'] + ]; } return $this->container->get('templating') diff --git a/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php b/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php index 2b168f18b..a10ebb883 100644 --- a/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php +++ b/src/Bundle/ChillMainBundle/Util/DateRangeCovering.php @@ -5,15 +5,15 @@ namespace Chill\MainBundle\Util; /** * Utilities to compare date periods * - * This class allow to compare periods when there are period covering. The + * This class allow to compare periods when there are period covering. The * argument `minCovers` allow to find also when there are more than 2 period - * which intersects. + * which intersects. * - * Example: a team may have maximum 2 leaders on a same period: you will + * Example: a team may have maximum 2 leaders on a same period: you will * find here all periods where there are more than 2 leaders. * * Usage: - * + * * ```php * $cover = new DateRangeCovering(2); // 2 means we will have periods * // when there are 2+ periods intersecting @@ -73,7 +73,7 @@ class DateRangeCovering $this->addToSequence($start->getTimestamp(), $k, null); $this->addToSequence( NULL === $end ? PHP_INT_MAX : $end->getTimestamp(), null, $k - ); + ); return $this; } @@ -182,7 +182,7 @@ class DateRangeCovering $foundExisting = false; list($nStart, $nEnd, $nMetadata) = $intersection; - \array_walk($intersections, + \array_walk($intersections, function(&$i, $key) use ($nStart, $nEnd, $nMetadata, $foundExisting) { if ($foundExisting) { return; @@ -205,7 +205,7 @@ class DateRangeCovering { if (!$this->computed) { throw new \LogicException(sprintf("You cannot call the method %s before ". - "'process'", __METHOD)); + "'process'", __METHOD__)); } return count($this->intersections) > 0; @@ -215,7 +215,7 @@ class DateRangeCovering { if (!$this->computed) { throw new \LogicException(sprintf("You cannot call the method %s before ". - "'process'", __METHOD)); + "'process'", __METHOD__)); } return $this->intersections; diff --git a/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php b/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php index 720de560c..7a1379434 100644 --- a/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php +++ b/src/Bundle/ChillPersonBundle/CRUD/Controller/OneToOneEntityPersonCRUDController.php @@ -1,20 +1,7 @@ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ + +declare(strict_types=1); + namespace Chill\PersonBundle\CRUD\Controller; use Chill\MainBundle\CRUD\Controller\CRUDController; @@ -23,11 +10,8 @@ use Chill\PersonBundle\Entity\Person; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\RedirectResponse; +use BadMethodCallException; -/** - * Controller for entities attached as one-to-on to a person - * - */ class OneToOneEntityPersonCRUDController extends CRUDController { protected function getTemplateFor($action, $entity, Request $request) @@ -35,11 +19,11 @@ class OneToOneEntityPersonCRUDController extends CRUDController if (!empty($this->crudConfig[$action]['template'])) { return $this->crudConfig[$action]['template']; } - + switch ($action) { case 'new': return '@ChillPerson/CRUD/new.html.twig'; - case 'edit': + case 'edit': return '@ChillPerson/CRUD/edit.html.twig'; case 'index': return '@ChillPerson/CRUD/index.html.twig'; @@ -49,41 +33,41 @@ class OneToOneEntityPersonCRUDController extends CRUDController . "action"); } } - + protected function getEntity($action, $id, Request $request): ?object { $entity = parent::getEntity($action, $id, $request); - + if (NULL === $entity) { $entity = $this->createEntity($action, $request); $person = $this->getDoctrine() ->getManager() ->getRepository(Person::class) ->find($id); - + $entity->setPerson($person); } - + return $entity; } - + protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request) { $this->getDoctrine()->getManager()->persist($entity); } - + protected function onPostFetchEntity($action, Request $request, $entity): ?Response { if (FALSE === $this->getDoctrine()->getManager()->contains($entity)) { return new RedirectResponse($this->generateRedirectOnCreateRoute($action, $request, $entity)); } - + return null; } - + protected function generateRedirectOnCreateRoute($action, Request $request, $entity) { - throw new BadMethodCallException("not implemtented yet"); + throw new BadMethodCallException('Not implemented yet.'); } } diff --git a/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php b/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php index 35f596295..8922a9bb8 100644 --- a/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php +++ b/src/Bundle/ChillPersonBundle/Command/ImportPeopleFromCSVCommand.php @@ -959,6 +959,8 @@ EOF $table->setHeaders(array('#', 'label', 'value')); $i = 0; + $matchingTableRowAnswer = []; + foreach($answers as $key => $answer) { $table->addRow(array( $i, $answer, $key diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php index 24a5bbb7f..14420ed88 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php @@ -161,8 +161,10 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface \shuffle($this->personIds); } - private function getRandomPersons(int $min, int $max) + private function getRandomPersons(int $min, int $max): array { + $persons = []; + $nb = \random_int($min, $max); for ($i=0; $i < $nb; $i++) { @@ -172,7 +174,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface ; } - return $persons ?? []; + return $persons; } public function getDependencies() diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php index 1deefe993..aa2e56121 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/CountryOfBirthAggregator.php @@ -143,6 +143,8 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme public function getLabels($key, array $values, $data) { + $labels = []; + if ($data['group_by_level'] === 'country') { $qb = $this->countriesRepository->createQueryBuilder('c'); @@ -153,15 +155,17 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme ->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR); // initialize array and add blank key for null values - $labels[''] = $this->translator->trans('without data'); - $labels['_header'] = $this->translator->trans('Country of birth'); + $labels = [ + '' => $this->translator->trans('without data'), + '_header' => $this->translator->trans('Country of birth'), + ]; + foreach($countries as $row) { $labels[$row['c_countryCode']] = $this->translatableStringHelper->localize($row['c_name']); } + } - - } elseif ($data['group_by_level'] === 'continent') { - + if ($data['group_by_level'] === 'continent') { $labels = array( 'EU' => $this->translator->trans('Europe'), 'AS' => $this->translator->trans('Asia'), @@ -170,13 +174,12 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme 'SA' => $this->translator->trans('South America'), 'NA' => $this->translator->trans('North America'), 'OC' => $this->translator->trans('Oceania'), - '' => $this->translator->trans('without data'), + '' => $this->translator->trans('without data'), '_header' => $this->translator->trans('Continent of birth') ); } - - return function($value) use ($labels) { + return function(string $value) use ($labels): string { return $labels[$value]; }; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php index e856bedc6..97e7d4e4a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/NationalityAggregator.php @@ -144,6 +144,8 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV public function getLabels($key, array $values, $data) { + $labels = []; + if ($data['group_by_level'] === 'country') { $qb = $this->countriesRepository->createQueryBuilder('c'); @@ -154,15 +156,17 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR); // initialize array and add blank key for null values - $labels[''] = $this->translator->trans('without data'); - $labels['_header'] = $this->translator->trans('Nationality'); + $labels = [ + '' => $this->translator->trans('without data'), + '_header' => $this->translator->trans('Nationality'), + ]; + foreach($countries as $row) { $labels[$row['c_countryCode']] = $this->translatableStringHelper->localize($row['c_name']); } + } - - } elseif ($data['group_by_level'] === 'continent') { - + if ($data['group_by_level'] === 'continent') { $labels = array( 'EU' => $this->translator->trans('Europe'), 'AS' => $this->translator->trans('Asia'), @@ -176,8 +180,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ); } - - return function($value) use ($labels) { + return function(string $value) use ($labels): string { return $labels[$value]; }; diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php index 1a634f451..8fe6f2873 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php @@ -1,8 +1,10 @@ repository = $entityManager->getRepository(HouseholdMembers::class); + $this->repository = $entityManager->getRepository(HouseholdMember::class); } } diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index f62b90006..7fff34d7d 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -263,8 +263,9 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf public function convertTermsToFormData(array $terms) { - foreach(['firstname', 'lastname', 'gender', '_default'] - as $key) { + $data = []; + + foreach(['firstname', 'lastname', 'gender', '_default'] as $key) { $data[$key] = $terms[$key] ?? null; } diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php index 7da1a8cad..c68e300cf 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialActionRender.php @@ -38,7 +38,7 @@ class SocialActionRender implements ChillEntityRenderInterface { /** @var $socialAction SocialAction */ $options = \array_merge(self::DEFAULT_ARGS, $options); - $titles[] = $this->translatableStringHelper->localize($socialAction->getTitle()); + $titles = [$this->translatableStringHelper->localize($socialAction->getTitle())]; while ($socialAction->hasParent()) { $socialAction = $socialAction->getParent(); diff --git a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php index 5ed80182c..80254d989 100644 --- a/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php +++ b/src/Bundle/ChillPersonBundle/Templating/Entity/SocialIssueRender.php @@ -38,8 +38,7 @@ final class SocialIssueRender implements ChillEntityRenderInterface /** @var $socialIssue SocialIssue */ $options = array_merge(self::DEFAULT_ARGS, $options); - $titles[] = $this->translatableStringHelper - ->localize($socialIssue->getTitle()); + $titles = [$this->translatableStringHelper->localize($socialIssue->getTitle())]; // loop to parent, until root while ($socialIssue->hasParent()) { diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 583db8f4b..9524f860a 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -1,6 +1,6 @@ */ @@ -38,27 +38,27 @@ class ReportList implements ListInterface, ExportElementValidatedInterface * @var CustomFieldsGroup */ protected $customfieldsGroup; - + /** * * @var TranslatableStringHelper */ protected $translatableStringHelper; - + /** * * @var TranslatorInterface */ protected $translator; - + /** * * @var CustomFieldProvider */ protected $customFieldProvider; - + protected $em; - + protected $fields = array( 'person_id', 'person_firstName', 'person_lastName', 'person_birthdate', 'person_placeOfBirth', 'person_gender', 'person_memo', 'person_email', 'person_phonenumber', @@ -67,11 +67,11 @@ class ReportList implements ListInterface, ExportElementValidatedInterface 'person_address_postcode_code', 'person_address_country_name', 'person_address_country_code', 'report_id', 'report_user', 'report_date', 'report_scope' ); - + protected $slugs = []; - + function __construct( - CustomFieldsGroup $customfieldsGroup, + CustomFieldsGroup $customfieldsGroup, TranslatableStringHelper $translatableStringHelper, TranslatorInterface $translator, CustomFieldProvider $customFieldProvider, @@ -84,18 +84,18 @@ class ReportList implements ListInterface, ExportElementValidatedInterface $this->em = $em; } - + public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder) { $choices = array_combine($this->fields, $this->fields); - + foreach ($this->getCustomFields() as $cf) { $choices - [$this->translatableStringHelper->localize($cf->getName())] - = + [$this->translatableStringHelper->localize($cf->getName())] + = $cf->getSlug(); } - + // Add a checkbox to select fields $builder->add('fields', ChoiceType::class, array( 'multiple' => true, @@ -133,7 +133,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface } ))] )); - + // add a date field for addresses $builder->add('address_date', ChillDateType::class, array( 'label' => "Address valid at this date", @@ -142,14 +142,14 @@ class ReportList implements ListInterface, ExportElementValidatedInterface 'block_name' => 'list_export_form_address_date' )); } - + public function validateForm($data, ExecutionContextInterface $context) { // get the field starting with address_ $addressFields = array_filter(function($el) { return substr($el, 0, 8) === 'address_'; }, $this->fields); - + // check if there is one field starting with address in data if (count(array_intersect($data['fields'], $addressFields)) > 0) { // if a field address is checked, the date must not be empty @@ -161,10 +161,10 @@ class ReportList implements ListInterface, ExportElementValidatedInterface } } } - + /** * Get custom fields associated with person - * + * * @return CustomField[] */ private function getCustomFields() @@ -184,7 +184,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface { return $this->translator->trans( "Generate list of report '%type%'", - [ + [ '%type%' => $this->translatableStringHelper->localize($this->customfieldsGroup->getName()) ] ); @@ -192,13 +192,12 @@ class ReportList implements ListInterface, ExportElementValidatedInterface /** * {@inheritDoc} - * + * * @param type $key * @param array $values * @param type $data - * @return type */ - public function getLabels($key, array $values, $data) + public function getLabels($key, array $values, $data): \Closure { switch ($key) { case 'person_birthdate': @@ -206,27 +205,27 @@ class ReportList implements ListInterface, ExportElementValidatedInterface // for birthdate or report date, we have to transform the string into a date // to format the date correctly. return function($value) use ($key) { - if ($value === '_header') { - return $key === 'person_birthdate' ? 'birthdate' : 'report_date'; + if ($value === '_header') { + return $key === 'person_birthdate' ? 'birthdate' : 'report_date'; } - + if (empty($value)) { return ""; } - + if ($key === 'person_birthdate') { $date = \DateTime::createFromFormat('Y-m-d', $value); } else { $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); } // check that the creation could occurs. - if ($date === false) { + if ($date === false) { throw new \Exception(sprintf("The value %s could " . "not be converted to %s", $value, \DateTime::class)); } - - return $date->format('d-m-Y'); + + return $date->format('d-m-Y'); }; case 'report_scope': $qb = $this->em->getRepository(Scope::class) @@ -236,17 +235,18 @@ class ReportList implements ListInterface, ExportElementValidatedInterface ->where($qb->expr()->in('s.id', $values)) ; $rows = $qb->getQuery()->getResult(Query::HYDRATE_ARRAY); - + + $scopes = []; + foreach($rows as $row) { - $scopes[$row['id']] = $this->translatableStringHelper - ->localize($row['name']); + $scopes[$row['id']] = $this->translatableStringHelper->localize($row['name']); } - - return function($value) use ($scopes) { + + return function($value) use ($scopes): string { if ($value === '_header') { return 'circle'; } - + return $scopes[$value]; }; case 'report_user': @@ -257,71 +257,73 @@ class ReportList implements ListInterface, ExportElementValidatedInterface ->where($qb->expr()->in('u.id', $values)) ; $rows = $qb->getQuery()->getResult(Query::HYDRATE_ARRAY); - + + $users = []; + foreach($rows as $row) { $users[$row['id']] = $row['username']; } - - return function($value) use ($users) { + + return function($value) use ($users): string { if ($value === '_header') { return 'user'; } - + return $users[$value]; }; case 'person_gender' : // for gender, we have to translate men/women statement return function($value) { if ($value === '_header') { return 'gender'; } - + return $this->translator->trans($value); }; case 'person_countryOfBirth': case 'person_nationality': $countryRepository = $this->em ->getRepository('ChillMainBundle:Country'); - + // load all countries in a single query $countryRepository->findBy(array('countryCode' => $values)); - + return function($value) use ($key, $countryRepository) { if ($value === '_header') { return \strtolower($key); } - - if ($value === NULL) { + + if ($value === NULL) { return $this->translator->trans('no data'); } - + $country = $countryRepository->find($value); - + return $this->translatableStringHelper->localize( $country->getName()); }; case 'person_address_country_name': return function($value) use ($key) { if ($value === '_header') { return \strtolower($key); } - + if ($value === NULL) { return ''; } - + return $this->translatableStringHelper->localize(json_decode($value, true)); }; default: // for fields which are associated with person if (in_array($key, $this->fields)) { return function($value) use ($key) { - if ($value === '_header') { return \strtolower($key); } + if ($value === '_header') { return \strtolower($key); } - return $value; + return $value; }; } else { return $this->getLabelForCustomField($key, $values, $data); } } - + } - + private function getLabelForCustomField($key, array $values, $data) { // for fields which are custom fields @@ -329,38 +331,38 @@ class ReportList implements ListInterface, ExportElementValidatedInterface $cf = $this->em ->getRepository(CustomField::class) ->findOneBy(array('slug' => $this->DQLToSlug($key))); - + $cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType()); $defaultFunction = function($value) use ($cf) { if ($value === '_header') { - return $this->translatableStringHelper->localize($cf->getName()); + return $this->translatableStringHelper->localize($cf->getName()); } return $this->customFieldProvider ->getCustomFieldByType($cf->getType()) ->render(json_decode($value, true), $cf, 'csv'); }; - + if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) { return function($value) use ($cf, $cfType, $key) { $slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug']; $decoded = \json_decode($value, true); - + if ($value === '_header') { - + $label = $cfType->getChoices($cf)[$slugChoice]; - + return $this->translatableStringHelper->localize($cf->getName()) .' | '.$label; } - + if ($slugChoice === '_other' and $cfType->isChecked($cf, $choiceSlug, $decoded)) { return $cfType->extractOtherValue($cf, $decoded); } else { return $cfType->isChecked($cf, $slugChoice, $decoded); } }; - + } else { return $defaultFunction; } @@ -369,44 +371,44 @@ class ReportList implements ListInterface, ExportElementValidatedInterface public function getQueryKeys($data) { $fields = array(); - + foreach ($data['fields'] as $key) { if (in_array($key, $this->fields)) { $fields[] = $key; } } - + // add the key from slugs and return return \array_merge($fields, \array_keys($this->slugs)); } - + /** * clean a slug to be usable by DQL - * - * @param string $slugsanitize + * + * @param string $slugsanitize * @param string $type the type of the customfield, if required (currently only for choices) * @return string */ private function slugToDQL($slug, $type = "default", array $additionalInfos = []) { $uid = 'slug_'.\uniqid(); - + $this->slugs[$uid] = [ 'slug' => $slug, 'type' => $type, 'additionnalInfos' => $additionalInfos ]; - + return $uid; } - + private function DQLToSlug($cleanedSlug) - { + { return $this->slugs[$cleanedSlug]['slug']; } - + /** - * + * * @param type $cleanedSlug * @return an array with keys = 'slug', 'type', 'additionnalInfo' */ @@ -424,7 +426,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface { return $this->translator->trans( "List for report '%type%'", - [ + [ '%type%' => $this->translatableStringHelper->localize($this->customfieldsGroup->getName()) ] ); @@ -438,22 +440,22 @@ class ReportList implements ListInterface, ExportElementValidatedInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = array()) { $centers = array_map(function($el) { return $el['center']; }, $acl); - + // throw an error if any fields are present if (!\array_key_exists('fields', $data)) { throw new \Doctrine\DBAL\Exception\InvalidArgumentException("any fields " . "have been checked"); } - + $qb = $this->em->createQueryBuilder(); - + // process fields which are not custom fields foreach ($this->fields as $f) { // do not add fields which are not selected if (!\in_array($f, $data['fields'])) { continue; } - + // add a column to the query for each field switch ($f) { case 'person_countryOfBirth': @@ -470,11 +472,11 @@ class ReportList implements ListInterface, ExportElementValidatedInterface case 'person_address_country_code': // remove 'person_' $suffix = \substr($f, 7); - + $qb->addSelect(sprintf( 'GET_PERSON_ADDRESS_%s(person.id, :address_date) AS %s', // get the part after address_ - strtoupper(substr($suffix, 8)), + strtoupper(substr($suffix, 8)), $f)); $qb->setParameter('address_date', $data['address_date']); break; @@ -487,7 +489,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface default: $prefix = \substr($f, 0, 7); $suffix = \substr($f, 7); - + switch($prefix) { case 'person_': $qb->addSelect(sprintf('person.%s as %s', $suffix, $f)); @@ -502,22 +504,22 @@ class ReportList implements ListInterface, ExportElementValidatedInterface } } - + // process fields which are custom fields foreach ($this->getCustomFields() as $cf) { // do not add custom fields which are not selected if (!\in_array($cf->getSlug(), $data['fields'])) { continue; } - + $cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType()); - + // if is multiple, split into multiple columns if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) { foreach($cfType->getChoices($cf) as $choiceSlug => $label) { $slug = $this->slugToDQL($cf->getSlug(), 'choice', [ 'choiceSlug' => $choiceSlug ]); $qb->addSelect( - sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s', + sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s', $slug, $slug)); $qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug()); } @@ -525,12 +527,12 @@ class ReportList implements ListInterface, ExportElementValidatedInterface // not multiple, add a single column $slug = $this->slugToDQL($cf->getSlug()); $qb->addSelect( - sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s', + sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s', $slug, $slug)); $qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug()); } } - + $qb ->from(Report::class, 'report') ->leftJoin('report.person', 'person') @@ -540,7 +542,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface ->andWhere('center IN (:authorized_centers)') ->setParameter('authorized_centers', $centers); ; - + return $qb; } diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php index fe5a8f78d..20e6a5480 100644 --- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php +++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php @@ -38,18 +38,18 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery; class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface { protected EntityManagerInterface $em; - + protected Registry $registry; - + protected AuthorizationHelper $authorizationHelper; protected Security $security; - - + + const TYPE = 'chill_task.transition'; - + public function __construct( - EntityManagerInterface $em, + EntityManagerInterface $em, Registry $registry, AuthorizationHelper $authorizationHelper, Security $security @@ -64,7 +64,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface { $metadata = $this->em ->getClassMetadata(SingleTaskPlaceEvent::class); - + switch ($context) { case 'person': [ $where, $parameters ] = $this->getWhereClauseForPerson($args['person']); @@ -157,7 +157,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface // the parameters - $parameters = []; + $parameters = $circleIds = []; // the clause that we will fill $clause = "{person}.{person_id} = ? AND {task}.{circle} IN ({circle_ids})"; @@ -212,27 +212,27 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface '{single_task}' => sprintf('%s.%s', $singleTask->getSchemaName(), $singleTask->getTableName()), '{single_task_event}' => sprintf('%s.%s', $taskEvent->getSchemaName(), $taskEvent->getTableName()), '{task_pk}' => $singleTask->getColumnName('id'), - '{event_fk_task}' => $eventFkTask, + '{event_fk_task}' => $eventFkTask, '{person}' => $person->getTableName(), '{task_person_fk}' => $taskFkPerson, - '{person_pk}' => $personPk + '{person_pk}' => $personPk ] ); - } - - public function getEntities(array $ids) + } + + public function getEntities(array $ids) { $events = $this->em ->getRepository(SingleTaskPlaceEvent::class) ->findBy([ 'id' => $ids ]) ; - + return \array_combine( \array_map(function($e) { return $e->getId(); }, $events ), $events ); - } - + } + public function getEntityTemplate($entity, $context, array $args) { $workflow = $this->registry->get($entity->getTask(), @@ -242,22 +242,22 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface // `Notice: Undefined property: Chill\TaskBundle\Entity\Task\SingleTaskPlaceEvent::$getData` // * fix syntax error on $entity->getData['workflow'] // * return null if not set - + $transition = $this->getTransitionByName($entity->getTransition(), $workflow); - + return [ 'template' => 'ChillTaskBundle:Timeline:single_task_transition.html.twig', - 'template_data' => [ + 'template_data' => [ 'context' => $context, 'event' => $entity, 'task' => $entity->getTask(), 'transition' => $transition ] ]; - } - + } + /** - * + * * @param string $name * @param Workflow $workflow * @return \Symfony\Component\Workflow\Transition @@ -270,7 +270,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface } } } - + public function supportsType($type): bool { return $type === self::TYPE; diff --git a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php index c62fdb31b..fb4456756 100644 --- a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php +++ b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php @@ -1,5 +1,7 @@ thirdPartyRender = $thirdPartyRender; } + /** + * @param ThirdParty $thirdParty + */ public function normalize($thirdParty, string $format = null, array $context = []) { - /** @var $thirdParty ThirdParty */ - $data['type'] = 'thirdparty'; - $data['text'] = $this->thirdPartyRender->renderString($thirdParty, []); - $data['id'] = $thirdParty->getId(); - $data['kind'] = $thirdParty->getKind(); - $data['address'] = $this->normalizer->normalize($thirdParty->getAddress(), $format, - [ 'address_rendering' => 'short' ]); - $data['phonenumber'] = $thirdParty->getTelephone(); - $data['email'] = $thirdParty->getEmail(); - $data['isChild'] = $thirdParty->isChild(); - $data['parent'] = $this->normalizer->normalize($thirdParty->getParent(), $format, $context); - $data['civility'] = $this->normalizer->normalize($thirdParty->getCivility(), $format, $context); - $data['contactDataAnonymous'] = $thirdParty->isContactDataAnonymous(); - - return $data; + return [ + 'type' => 'thirdparty', + 'text' => $this->thirdPartyRender->renderString($thirdParty, []), + 'id' => $thirdParty->getId(), + 'kind' => $thirdParty->getKind(), + 'address' => $this->normalizer->normalize($thirdParty->getAddress(), $format, [ 'address_rendering' => 'short' ]), + 'phonenumber' => $thirdParty->getTelephone(), + 'email' => $thirdParty->getEmail(), + 'isChild' => $thirdParty->isChild(), + 'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context), + 'civility' => $this->normalizer->normalize($thirdParty->getCivility(), $format, $context), + 'contactDataAnonymous' => $thirdParty->isContactDataAnonymous(), + ]; } public function supportsNormalization($data, string $format = null)