mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-14 18:07:47 +00:00
Apply new rector rules regarding to PHP version to 8.4
This commit is contained in:
@@ -13,11 +13,11 @@ namespace Chill\BudgetBundle\Calculator;
|
||||
|
||||
class CalculatorResult
|
||||
{
|
||||
final public const TYPE_CURRENCY = 'currency';
|
||||
final public const string TYPE_CURRENCY = 'currency';
|
||||
|
||||
final public const TYPE_PERCENTAGE = 'percentage';
|
||||
final public const string TYPE_PERCENTAGE = 'percentage';
|
||||
|
||||
final public const TYPE_RATE = 'rate';
|
||||
final public const string TYPE_RATE = 'rate';
|
||||
|
||||
public $label;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class ChargeKindController extends CRUDController
|
||||
{
|
||||
#[\Override]
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||
{
|
||||
/* @var QueryBuilder $query */
|
||||
|
||||
@@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class ResourceKindController extends CRUDController
|
||||
{
|
||||
#[\Override]
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||
{
|
||||
/* @var QueryBuilder $query */
|
||||
|
||||
@@ -22,15 +22,15 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
#[ORM\Table(name: 'chill_budget.charge')]
|
||||
class Charge extends AbstractElement implements HasCentersInterface
|
||||
{
|
||||
final public const HELP_ASKED = 'running';
|
||||
final public const string HELP_ASKED = 'running';
|
||||
|
||||
final public const HELP_NO = 'no';
|
||||
final public const string HELP_NO = 'no';
|
||||
|
||||
final public const HELP_NOT_RELEVANT = 'not-relevant';
|
||||
final public const string HELP_NOT_RELEVANT = 'not-relevant';
|
||||
|
||||
final public const HELP_YES = 'yes';
|
||||
final public const string HELP_YES = 'yes';
|
||||
|
||||
final public const HELPS = [
|
||||
final public const array HELPS = [
|
||||
self::HELP_ASKED,
|
||||
self::HELP_NO,
|
||||
self::HELP_YES,
|
||||
|
||||
@@ -89,6 +89,7 @@ class ChargeType extends AbstractType
|
||||
->setAllowedTypes('show_help', 'boolean');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getBlockPrefix(): string
|
||||
{
|
||||
return 'chill_budgetbundle_charge';
|
||||
|
||||
@@ -72,6 +72,7 @@ class ResourceType extends AbstractType
|
||||
->setAllowedTypes('show_end_date', 'boolean');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getBlockPrefix(): string
|
||||
{
|
||||
return 'chill_budgetbundle_resource';
|
||||
|
||||
@@ -22,20 +22,20 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
class BudgetElementVoter extends Voter implements ProvideRoleHierarchyInterface
|
||||
{
|
||||
final public const CREATE = 'CHILL_BUDGET_ELEMENT_CREATE';
|
||||
final public const string CREATE = 'CHILL_BUDGET_ELEMENT_CREATE';
|
||||
|
||||
final public const DELETE = 'CHILL_BUDGET_ELEMENT_DELETE';
|
||||
final public const string DELETE = 'CHILL_BUDGET_ELEMENT_DELETE';
|
||||
|
||||
final public const ROLES = [
|
||||
final public const array ROLES = [
|
||||
self::CREATE,
|
||||
self::DELETE,
|
||||
self::SEE,
|
||||
self::UPDATE,
|
||||
];
|
||||
|
||||
final public const SEE = 'CHILL_BUDGET_ELEMENT_SEE';
|
||||
final public const string SEE = 'CHILL_BUDGET_ELEMENT_SEE';
|
||||
|
||||
final public const UPDATE = 'CHILL_BUDGET_ELEMENT_UPDATE';
|
||||
final public const string UPDATE = 'CHILL_BUDGET_ELEMENT_UPDATE';
|
||||
|
||||
protected VoterHelperInterface $voter;
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ use Doctrine\ORM\Query\ResultSetMapping;
|
||||
*/
|
||||
final readonly class SummaryBudget implements SummaryBudgetInterface
|
||||
{
|
||||
private const QUERY_CHARGE_BY_HOUSEHOLD = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, charge_id AS kind_id FROM chill_budget.charge WHERE (person_id IN (_ids_) OR household_id = ?) AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY charge_id';
|
||||
private const string QUERY_CHARGE_BY_HOUSEHOLD = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, charge_id AS kind_id FROM chill_budget.charge WHERE (person_id IN (_ids_) OR household_id = ?) AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY charge_id';
|
||||
|
||||
private const QUERY_CHARGE_BY_PERSON = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, charge_id AS kind_id FROM chill_budget.charge WHERE person_id = ? AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY charge_id';
|
||||
private const string QUERY_CHARGE_BY_PERSON = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, charge_id AS kind_id FROM chill_budget.charge WHERE person_id = ? AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY charge_id';
|
||||
|
||||
private const QUERY_RESOURCE_BY_HOUSEHOLD = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, resource_id AS kind_id FROM chill_budget.resource WHERE (person_id IN (_ids_) OR household_id = ?) AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY resource_id';
|
||||
private const string QUERY_RESOURCE_BY_HOUSEHOLD = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, resource_id AS kind_id FROM chill_budget.resource WHERE (person_id IN (_ids_) OR household_id = ?) AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY resource_id';
|
||||
|
||||
private const QUERY_RESOURCE_BY_PERSON = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, resource_id AS kind_id FROM chill_budget.resource WHERE person_id = ? AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY resource_id';
|
||||
private const string QUERY_RESOURCE_BY_PERSON = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, resource_id AS kind_id FROM chill_budget.resource WHERE person_id = ? AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY resource_id';
|
||||
|
||||
public function __construct(private EntityManagerInterface $em, private TranslatableStringHelperInterface $translatableStringHelper, private ResourceKindRepositoryInterface $resourceKindRepository, private ChargeKindRepositoryInterface $chargeKindRepository) {}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ final class SummaryBudgetTest extends TestCase
|
||||
|
||||
$chargeRepository = $this->prophesize(ChargeKindRepositoryInterface::class);
|
||||
$chargeRepository->findAll()->willReturn([
|
||||
$rental = (new ChargeKind())->setKind('rental')->setName(['fr' => 'Rental']),
|
||||
$other = (new ChargeKind())->setKind('other')->setName(['fr' => 'Other']),
|
||||
$rental = new ChargeKind()->setKind('rental')->setName(['fr' => 'Rental']),
|
||||
$other = new ChargeKind()->setKind('other')->setName(['fr' => 'Other']),
|
||||
]);
|
||||
$chargeRepository->find(1)->willReturn($rental);
|
||||
$chargeRepository->findOneByKind('rental')->willReturn($rental);
|
||||
@@ -85,8 +85,8 @@ final class SummaryBudgetTest extends TestCase
|
||||
|
||||
$resourceRepository = $this->prophesize(ResourceKindRepositoryInterface::class);
|
||||
$resourceRepository->findAll()->willReturn([
|
||||
$salary = (new ResourceKind())->setKind('salary')->setName(['fr' => 'Salary']),
|
||||
$misc = (new ResourceKind())->setKind('misc')->setName(['fr' => 'Misc']),
|
||||
$salary = new ResourceKind()->setKind('salary')->setName(['fr' => 'Salary']),
|
||||
$misc = new ResourceKind()->setKind('misc')->setName(['fr' => 'Misc']),
|
||||
]);
|
||||
$resourceRepository->find(2)->willReturn($salary);
|
||||
$resourceRepository->findOneByKind('salary')->willReturn($salary);
|
||||
@@ -98,15 +98,13 @@ final class SummaryBudgetTest extends TestCase
|
||||
$person = new Person();
|
||||
$personReflection = new \ReflectionClass($person);
|
||||
$personIdReflection = $personReflection->getProperty('id');
|
||||
$personIdReflection->setAccessible(true);
|
||||
$personIdReflection->setValue($person, 1);
|
||||
|
||||
$household = new Household();
|
||||
$householdReflection = new \ReflectionClass($household);
|
||||
$householdId = $householdReflection->getProperty('id');
|
||||
$householdId->setAccessible(true);
|
||||
$householdId->setValue($household, 1);
|
||||
$householdMember = (new HouseholdMember())->setPerson($person)
|
||||
$householdMember = new HouseholdMember()->setPerson($person)
|
||||
->setStartDate(new \DateTimeImmutable('1 month ago'));
|
||||
$household->addMember($householdMember);
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20180522080432 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SCHEMA chill_budget CASCADE');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Creation of necessary tables for budget bundle';
|
||||
|
||||
@@ -19,6 +19,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20181219145631 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_budget.charge ALTER help SET NOT NULL');
|
||||
|
||||
@@ -19,6 +19,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20220224090319 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_budget.charge DROP CONSTRAINT FK_5C99D2C3E79FF843');
|
||||
@@ -27,6 +28,7 @@ final class Version20220224090319 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_budget.resource DROP household_id');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add household to budget AbstractElement';
|
||||
|
||||
@@ -16,6 +16,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20221116163445 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_budget.charge_type_id_seq CASCADE');
|
||||
@@ -24,6 +25,7 @@ final class Version20221116163445 extends AbstractMigration
|
||||
$this->addSql('DROP TABLE chill_budget.resource_type');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create resource type and charge type';
|
||||
|
||||
@@ -16,6 +16,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20221130101659 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_budget.resource_type DROP kind');
|
||||
@@ -24,6 +25,7 @@ final class Version20221130101659 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_budget.charge_type DROP tags');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add kind and tags property to charge and resource types';
|
||||
|
||||
@@ -16,6 +16,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20221202165608 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_budget.charge DROP CONSTRAINT FK_5C99D2C355284914');
|
||||
@@ -24,6 +25,7 @@ final class Version20221202165608 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_budget.resource DROP resource_id');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Integrate budget admin entity';
|
||||
|
||||
@@ -17,12 +17,14 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20221207105407 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DELETE FROM chill_budget.resource_type;');
|
||||
$this->addSql('DELETE FROM chill_budget.charge_type;');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Use new budget admin entities';
|
||||
|
||||
@@ -19,11 +19,13 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20230201131008 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this shouldn't be undone.
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Fix the comment on tags column in resource and charge type';
|
||||
|
||||
@@ -16,12 +16,14 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20230209161546 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX resource_kind_unique_type_idx');
|
||||
$this->addSql('DROP INDEX charge_kind_unique_type_idx');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Budget: add unique constraint on kind for charge_kind and resource_kind';
|
||||
|
||||
@@ -16,6 +16,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20230328155010 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'budget elements: restore the previous type to resource/charge kind if applicable';
|
||||
@@ -48,6 +49,7 @@ final class Version20230328155010 extends AbstractMigration
|
||||
SQL);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("UPDATE chill_budget.resource_type SET kind=md5(random()::text) WHERE kind = ''");
|
||||
|
||||
Reference in New Issue
Block a user