apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -13,11 +13,6 @@ namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\ORM\Query\ResultSetMapping;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use function count;
/**
* Migrate association from
@@ -29,7 +24,7 @@ class Version20150821105642 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE group_centers DROP CONSTRAINT FK_A14D8F3D447BBB3B');
$this->addSql('DROP INDEX IDX_A14D8F3D447BBB3B');
@@ -38,7 +33,7 @@ class Version20150821105642 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE group_centers ADD permissionsGroup_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE group_centers ADD CONSTRAINT FK_A14D8F3D447BBB3B FOREIGN KEY (permissionsGroup_id) REFERENCES permission_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE');

View File

@@ -21,10 +21,10 @@ class Version20160310122322 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_main_address '
. 'DROP CONSTRAINT FK_165051F6EECBFDF1');
.'DROP CONSTRAINT FK_165051F6EECBFDF1');
$this->addSql('DROP SEQUENCE chill_main_address_id_seq CASCADE');
$this->addSql('DROP SEQUENCE chill_main_postal_code_id_seq CASCADE');
$this->addSql('DROP TABLE chill_main_address');
@@ -33,36 +33,36 @@ class Version20160310122322 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE chill_main_address_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE chill_main_postal_code_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_main_address ('
. 'id INT NOT NULL, '
. 'postcode_id INT DEFAULT NULL, '
. 'streetAddress1 VARCHAR(255) NOT NULL, '
. 'streetAddress2 VARCHAR(255) NOT NULL, '
. 'validFrom DATE NOT NULL, '
. 'PRIMARY KEY(id))');
.'id INT NOT NULL, '
.'postcode_id INT DEFAULT NULL, '
.'streetAddress1 VARCHAR(255) NOT NULL, '
.'streetAddress2 VARCHAR(255) NOT NULL, '
.'validFrom DATE NOT NULL, '
.'PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_165051F6EECBFDF1 ON chill_main_address '
. '(postcode_id)');
.'(postcode_id)');
$this->addSql('CREATE TABLE chill_main_postal_code ('
. 'id INT NOT NULL, '
. 'country_id INT DEFAULT NULL, '
. 'label VARCHAR(255) NOT NULL, '
. 'code VARCHAR(100) NOT NULL, '
. 'PRIMARY KEY(id))');
.'id INT NOT NULL, '
.'country_id INT DEFAULT NULL, '
.'label VARCHAR(255) NOT NULL, '
.'code VARCHAR(100) NOT NULL, '
.'PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_6CA145FAF92F3E70 ON chill_main_postal_code '
. '(country_id)');
.'(country_id)');
$this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT '
. 'FK_165051F6EECBFDF1 '
. 'FOREIGN KEY (postcode_id) '
. 'REFERENCES chill_main_postal_code (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'FK_165051F6EECBFDF1 '
.'FOREIGN KEY (postcode_id) '
.'REFERENCES chill_main_postal_code (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_postal_code ADD CONSTRAINT '
. 'FK_6CA145FAF92F3E70 '
. 'FOREIGN KEY (country_id) '
. 'REFERENCES Country (id) '
. 'NOT DEFERRABLE INITIALLY IMMEDIATE');
.'FK_6CA145FAF92F3E70 '
.'FOREIGN KEY (country_id) '
.'REFERENCES Country (id) '
.'NOT DEFERRABLE INITIALLY IMMEDIATE');
}
}

View File

@@ -13,7 +13,6 @@ namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Exception;
/**
* Add index to postal code.
@@ -22,19 +21,19 @@ final class Version20180703191509 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP INDEX search_name_code');
}
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
try {
$this->addSql('CREATE EXTENSION IF NOT EXISTS pg_trgm');
$this->addSql('CREATE INDEX search_name_code ON chill_main_postal_code USING GIN (LOWER(code) gin_trgm_ops, LOWER(label) gin_trgm_ops)');
} catch (Exception) {
} catch (\Exception) {
$this->skipIf(true, 'Could not create extension pg_trgm');
}
}

View File

@@ -22,7 +22,7 @@ final class Version20180709181423 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP INDEX UNIQ_1483A5E9F5A5DC32');
$this->addSql('DROP INDEX UNIQ_1483A5E9885281E');
@@ -37,7 +37,7 @@ final class Version20180709181423 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE users ADD usernameCanonical VARCHAR(80) DEFAULT NULL');
$this->addSql('UPDATE users SET usernameCanonical=LOWER(UNACCENT(username))');

View File

@@ -21,7 +21,7 @@ final class Version20210308111926 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_main_address DROP customs');
}
@@ -33,7 +33,7 @@ final class Version20210308111926 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_main_address ADD customs JSONB DEFAULT \'[]\'');
}

View File

@@ -21,7 +21,7 @@ final class Version20210414091001 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP EXTENSION IF NOT EXISTS postgis;');
}
@@ -33,7 +33,7 @@ final class Version20210414091001 extends AbstractMigration
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE EXTENSION IF NOT EXISTS postgis;');
}

View File

@@ -14,7 +14,6 @@ namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use libphonenumber\PhoneNumberUtil;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
@@ -43,7 +42,7 @@ final class Version20220302132728 extends AbstractMigration implements Container
->getParameter('chill_main')['phone_helper']['default_carrier_code'];
if (null === $carrier_code) {
throw new RuntimeException('no carrier code');
throw new \RuntimeException('no carrier code');
}
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber1 TYPE VARCHAR(35)');
@@ -56,9 +55,9 @@ final class Version20220302132728 extends AbstractMigration implements Container
$this->addSql('COMMENT ON COLUMN chill_main_location.phonenumber2 IS \'(DC2Type:phone_number)\'');
$this->addSql(
'UPDATE chill_main_location SET ' .
$this->buildMigrationPhonenumberClause($carrier_code, 'phonenumber1') .
', ' .
'UPDATE chill_main_location SET '.
$this->buildMigrationPhonenumberClause($carrier_code, 'phonenumber1').
', '.
$this->buildMigrationPhoneNumberClause($carrier_code, 'phonenumber2')
);
}

View File

@@ -47,7 +47,7 @@ final class Version20220729205416 extends AbstractMigration
$this->addSql('CREATE INDEX IDX_6CA145FA65FF1AEC ON chill_main_postal_code (updatedBy_id)');
$this->addSql('CREATE INDEX IDX_6CA145FA3174800F ON chill_main_postal_code (createdBy_id)');
$this->addSql('CREATE UNIQUE INDEX postal_code_import_unicity ON chill_main_postal_code (code, refpostalcodeid, postalcodesource) WHERE refpostalcodeid is not null');
//$this->addSql('ALTER TABLE chill_main_postal_code ADD CONSTRAINT chill_internal_postal_code_import_unicity '.
// $this->addSql('ALTER TABLE chill_main_postal_code ADD CONSTRAINT chill_internal_postal_code_import_unicity '.
// 'EXCLUDE (code WITH =, refpostalcodeid WITH =, postalcodesource WITH =) WHERE (refpostalcodeid IS NOT NULL)');
}
}

View File

@@ -15,7 +15,7 @@ use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add property to center
* Add property to center.
*/
final class Version20230906134410 extends AbstractMigration
{

View File

@@ -41,7 +41,6 @@ final class Version20230913114115 extends AbstractMigration
$this->addSql('ALTER TABLE users ADD mainscope_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE users ADD CONSTRAINT fk_1483a5e9115e73f3 FOREIGN KEY (mainscope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX idx_1483a5e9115e73f3 ON users (mainscope_id)');
}
public function getDescription(): string
@@ -54,12 +53,12 @@ final class Version20230913114115 extends AbstractMigration
// create scope_history
$this->addSql('CREATE SEQUENCE chill_main_user_scope_history_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_main_user_scope_history ('
. 'id INT NOT NULL,'
. 'scope_id INT DEFAULT NULL,'
. 'user_id INT DEFAULT NULL,'
. 'endDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,'
. 'startDate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,'
. 'PRIMARY KEY(id))');
.'id INT NOT NULL,'
.'scope_id INT DEFAULT NULL,'
.'user_id INT DEFAULT NULL,'
.'endDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,'
.'startDate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,'
.'PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_48B969D7682B5931 ON chill_main_user_scope_history (scope_id)');
$this->addSql('CREATE INDEX IDX_48B969D7A76ED395 ON chill_main_user_scope_history (user_id)');
@@ -68,39 +67,38 @@ final class Version20230913114115 extends AbstractMigration
$this->addSql('COMMENT ON COLUMN chill_main_user_scope_history.startDate IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE chill_main_user_scope_history ADD CONSTRAINT FK_48B969D7682B5931 '
. 'FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
.'FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_user_scope_history ADD CONSTRAINT FK_48B969D7A76ED395 '
. 'FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
.'FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_user_scope_history '
. 'ADD CONSTRAINT user_scope_history_not_overlaps '
. 'EXCLUDE USING GIST (user_id with =, tsrange(startDate, endDate) with &&) '
. 'DEFERRABLE INITIALLY DEFERRED');
.'ADD CONSTRAINT user_scope_history_not_overlaps '
.'EXCLUDE USING GIST (user_id with =, tsrange(startDate, endDate) with &&) '
.'DEFERRABLE INITIALLY DEFERRED');
$this->addSql('ALTER TABLE chill_main_user_scope_history '
. 'ADD CONSTRAINT user_scope_history_endate_null_or_after_startdate '
. 'CHECK (startDate <= endDate OR endDate IS NULL)');
.'ADD CONSTRAINT user_scope_history_endate_null_or_after_startdate '
.'CHECK (startDate <= endDate OR endDate IS NULL)');
// insert user scope_history datas
$this->addSql('INSERT INTO chill_main_user_scope_history (id, startDate, endDate, user_id, scope_id) '
. 'SELECT nextval(\'chill_main_user_scope_history_id_seq\'), \'1970-01-01\'::date, NULL, users.id, mainscope_id '
. 'FROM users');
.'SELECT nextval(\'chill_main_user_scope_history_id_seq\'), \'1970-01-01\'::date, NULL, users.id, mainscope_id '
.'FROM users');
// remove mainscope
$this->addSql('ALTER TABLE users DROP CONSTRAINT fk_1483a5e9115e73f3');
$this->addSql('ALTER TABLE users DROP mainscope_id');
// create job_history
$this->addSql('CREATE SEQUENCE chill_main_user_job_history_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_main_user_job_history ('
. 'id INT NOT NULL,'
. 'job_id INT DEFAULT NULL,'
. 'user_id INT DEFAULT NULL,'
. 'endDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,'
. 'startDate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,'
. 'PRIMARY KEY(id))');
.'id INT NOT NULL,'
.'job_id INT DEFAULT NULL,'
.'user_id INT DEFAULT NULL,'
.'endDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,'
.'startDate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,'
.'PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_4E3BF4DDBE04EA9 ON chill_main_user_job_history (job_id)');
$this->addSql('CREATE INDEX IDX_4E3BF4DDA76ED395 ON chill_main_user_job_history (user_id)');
@@ -109,28 +107,27 @@ final class Version20230913114115 extends AbstractMigration
$this->addSql('COMMENT ON COLUMN chill_main_user_job_history.startDate IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE chill_main_user_job_history ADD CONSTRAINT FK_4E3BF4DDBE04EA9 '
. 'FOREIGN KEY (job_id) REFERENCES chill_main_user_job (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
.'FOREIGN KEY (job_id) REFERENCES chill_main_user_job (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_user_job_history ADD CONSTRAINT FK_4E3BF4DDA76ED395 '
. 'FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
.'FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_user_job_history '
. 'ADD CONSTRAINT user_job_history_not_overlaps '
. 'EXCLUDE USING GIST (user_id with =, tsrange(startDate, endDate) with &&) '
. 'DEFERRABLE INITIALLY DEFERRED');
.'ADD CONSTRAINT user_job_history_not_overlaps '
.'EXCLUDE USING GIST (user_id with =, tsrange(startDate, endDate) with &&) '
.'DEFERRABLE INITIALLY DEFERRED');
$this->addSql('ALTER TABLE chill_main_user_job_history '
. 'ADD CONSTRAINT user_job_history_endate_null_or_after_startdate '
. 'CHECK (startDate <= endDate OR endDate IS NULL)');
.'ADD CONSTRAINT user_job_history_endate_null_or_after_startdate '
.'CHECK (startDate <= endDate OR endDate IS NULL)');
// insert user job_history datas
$this->addSql('INSERT INTO chill_main_user_job_history (id, startDate, endDate, user_id, job_id) '
. 'SELECT nextval(\'chill_main_user_job_history_id_seq\'), \'1970-01-01\'::date, NULL, users.id, userjob_id '
. 'FROM users');
.'SELECT nextval(\'chill_main_user_job_history_id_seq\'), \'1970-01-01\'::date, NULL, users.id, userjob_id '
.'FROM users');
// remove userjob
$this->addSql('ALTER TABLE users DROP CONSTRAINT fk_1483a5e964b65c5b');
$this->addSql('ALTER TABLE users DROP userjob_id');
}
}