Skip to content

Commit

Permalink
refactor: Use friendsofphp/php-cs-fixer instead of squizlabs/php_code…
Browse files Browse the repository at this point in the history
…sniffer (#22)
  • Loading branch information
roadiz-ci committed Nov 6, 2024
1 parent 490d359 commit 54dadd3
Show file tree
Hide file tree
Showing 625 changed files with 4,850 additions and 9,420 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-progress
- name: Run PHP Code Sniffer
run: vendor/bin/phpcs -p ./src
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon
- name: Run PHP Unit
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
"phpstan/phpstan": "^1.5.3",
"phpstan/phpstan-doctrine": "^1.3",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5",
"symfony/browser-kit": "6.4.*",
"symfony/phpunit-bridge": "^7.0",
"symfony/stopwatch": "6.4.*"
Expand Down
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ services:
tags: [ 'roadiz_core.document_renderer' ]
RZ\Roadiz\Documents\Renderer\RendererInterface:
alias: RZ\Roadiz\Documents\Renderer\ChainRenderer
RZ\Roadiz\Documents\MediaFinders\FacebookPictureFinder:

# Default AbstractDocumentFactory is the public one.
RZ\Roadiz\Documents\AbstractDocumentFactory:
Expand Down
16 changes: 7 additions & 9 deletions migrations/Version20201203004857.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\Migrations;
Expand All @@ -8,23 +9,21 @@

/**
* Database initialization migration.
*
* @package RZ\Roadiz\Migrations
*/
final class Version20201203004857 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return 'Database initialization migration.';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->skipIf($schema->hasTable('nodes'), 'Database has been initialized before Doctrine Migration tool.');

if ($this->connection->getDatabasePlatform()->getName() === 'mysql') {
if ('mysql' === $this->connection->getDatabasePlatform()->getName()) {
$this->mysqlUp();
} elseif ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
} elseif ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->postgresUp();
}
}
Expand Down Expand Up @@ -480,15 +479,14 @@ private function postgresUp(): void
$this->addSql('ALTER TABLE users_groups ADD CONSTRAINT FK_FF8AB7E0FE54D947 FOREIGN KEY (group_id) REFERENCES usergroups (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
$this->throwIrreversibleMigrationException();
}

/**
* Temporary workaround
* Temporary workaround.
*
* @return bool
* @see https://github.com/doctrine/migrations/issues/1104
*/
public function isTransactional(): bool
Expand Down
14 changes: 7 additions & 7 deletions migrations/Version20201214232628.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\Migrations;
Expand All @@ -8,15 +9,15 @@

final class Version20201214232628 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return 'Rename groups table to usergroups to comply with MySQL 8 reserved words.';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->skipIf(
$this->connection->getDatabasePlatform()->getName() !== 'mysql',
'mysql' !== $this->connection->getDatabasePlatform()->getName(),
'Migration can only be executed safely on \'mysql\'.'
);
$this->skipIf($schema->hasTable('usergroups'), 'Table `usergroups` already exists.');
Expand All @@ -33,10 +34,10 @@ public function up(Schema $schema) : void
// $this->addSql('ALTER TABLE `usergroups` RENAME INDEX uniq_f06d39705e237e06 TO UNIQ_98972EB45E237E06');
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
$this->skipIf(
$this->connection->getDatabasePlatform()->getName() !== 'mysql',
'mysql' !== $this->connection->getDatabasePlatform()->getName(),
'Migration can only be executed safely on \'mysql\'.'
);
$this->skipIf($schema->hasTable('groups'), 'Table `groups` already exists.');
Expand All @@ -54,9 +55,8 @@ public function down(Schema $schema) : void
}

/**
* Temporary workaround
* Temporary workaround.
*
* @return bool
* @see https://github.com/doctrine/migrations/issues/1104
*/
public function isTransactional(): bool
Expand Down
13 changes: 6 additions & 7 deletions migrations/Version20201225181256.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\Migrations;
Expand All @@ -9,30 +10,28 @@
/**
* Database initialization migration for PostgreSQL.
*
* @deprecated Use Roadiz\Core\Migrations\Version20201203004857 instead.
* @package RZ\Roadiz\Migrations
* @deprecated use Roadiz\Core\Migrations\Version20201203004857 instead
*/
final class Version20201225181256 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return '[deprecated] Database initialization migration for PostgreSQL.';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->write('Nothing to do with RZ\Roadiz\Migrations\Version20201225181256.');
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
$this->throwIrreversibleMigrationException();
}

/**
* Temporary workaround
* Temporary workaround.
*
* @return bool
* @see https://github.com/doctrine/migrations/issues/1104
*/
public function isTransactional(): bool
Expand Down
9 changes: 3 additions & 6 deletions migrations/Version20210423072744.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* @package RZ\Roadiz\Migrations
*/
final class Version20210423072744 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return 'Added Documents duration field.';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE documents ADD duration INT DEFAULT 0 NOT NULL');
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE documents DROP duration');
}
Expand Down
8 changes: 4 additions & 4 deletions migrations/Version20210423161606.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
*/
final class Version20210423161606 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return 'Additional table indexes on documents, folders, logs and tags';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->addSql('CREATE INDEX document_created_at ON documents (created_at)');
$this->addSql('CREATE INDEX document_updated_at ON documents (updated_at)');
Expand All @@ -33,9 +33,9 @@ public function up(Schema $schema) : void
$this->addSql('CREATE INDEX tag_parent_position ON tags (parent_tag_id, position)');
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('DROP INDEX IF EXISTS document_created_at');
$this->addSql('DROP INDEX IF EXISTS document_updated_at');
$this->addSql('DROP INDEX IF EXISTS document_raw_created_at');
Expand Down
14 changes: 7 additions & 7 deletions migrations/Version20210423164248.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

final class Version20210423164248 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return 'Additional table indexes and renaming important performance indexes';
}

public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->addSql('CREATE INDEX answer_customform_submitted_at ON custom_form_answers (custom_form_id, submitted_at)');
$this->addSql('CREATE INDEX cffattribute_answer_field ON custom_form_field_attributes (custom_form_answer_id, custom_form_field_id)');
Expand All @@ -23,7 +23,7 @@ public function up(Schema $schema) : void
$this->addSql('CREATE INDEX customform_node_position ON nodes_custom_forms (node_id, position)');
$this->addSql('CREATE INDEX customform_node_field_position ON nodes_custom_forms (node_id, node_type_field_id, position)');

if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('DROP INDEX IF EXISTS IDX_7C7DED6DE0D4FDE19CAA2B25');
$this->addSql('DROP INDEX IF EXISTS IDX_7C7DED6DE0D4FDE14AD260649CAA2B25');
$this->addSql('DROP INDEX IF EXISTS IDX_7C7DED6D2B36786BE0D4FDE19CAA2B25');
Expand All @@ -38,7 +38,7 @@ public function up(Schema $schema) : void
$this->addSql('CREATE INDEX ns_discr_translation_published ON nodes_sources (discr, translation_id, published_at)');
$this->addSql('CREATE INDEX ns_title_translation_published ON nodes_sources (title, translation_id, published_at)');

if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER INDEX IF EXISTS ns_node_translation_discr RENAME TO ns_node_discr_translation');
$this->addSql('ALTER INDEX IF EXISTS idx_7c7ded6d460d9fd79caa2b25e0d4fde1 RENAME TO ns_node_translation_published');
$this->addSql('ALTER INDEX IF EXISTS idx_7c7ded6d4ad260649caa2b25 RENAME TO ns_discr_translation');
Expand All @@ -65,9 +65,9 @@ public function up(Schema $schema) : void
}
}

public function down(Schema $schema) : void
public function down(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('DROP INDEX IF EXISTS answer_customform_submitted_at');
$this->addSql('DROP INDEX IF EXISTS cffattribute_answer_field');
$this->addSql('DROP INDEX IF EXISTS cfield_customform_positio');
Expand Down Expand Up @@ -95,7 +95,7 @@ public function down(Schema $schema) : void
$this->addSql('CREATE INDEX IDX_7C7DED6DE0D4FDE14AD260649CAA2B25 ON nodes_sources (published_at, discr, translation_id)');
$this->addSql('CREATE INDEX IDX_7C7DED6D2B36786BE0D4FDE19CAA2B25 ON nodes_sources (title, published_at, translation_id)');

if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER INDEX IF EXISTS ns_title_published RENAME TO IDX_7C7DED6D2B36786BE0D4FDE1');
$this->addSql('ALTER INDEX IF EXISTS ns_node_discr_translation RENAME TO ns_node_translation_discr');
$this->addSql('ALTER INDEX IF EXISTS ns_discr_translation RENAME TO IDX_7C7DED6D4AD260649CAA2B25');
Expand Down
6 changes: 3 additions & 3 deletions migrations/Version20210506085247.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function up(Schema $schema): void
$this->addSql('CREATE INDEX node_visible_parent_position ON nodes (visible, parent_node_id, position)');
$this->addSql('CREATE INDEX node_status_visible_parent_position ON nodes (status, visible, parent_node_id, position)');

if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER INDEX IF EXISTS idx_1d3d05fc7ab0e8597b00651c3445eb91 RENAME TO node_visible_status_parent');
$this->addSql('ALTER INDEX IF EXISTS idx_1d3d05fc7ab0e8593445eb91 RENAME TO node_visible_parent');
} else {
Expand All @@ -36,7 +36,7 @@ public function up(Schema $schema): void
$this->addSql('CREATE INDEX tag_visible_position ON tags (visible, position)');
$this->addSql('CREATE INDEX tag_parent_visible_position ON tags (parent_tag_id, visible, position)');

if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER INDEX IF EXISTS idx_6fbc9426f5c1a0d77ab0e859 RENAME TO tag_parent_visible');
} else {
$this->addSql('ALTER TABLE tags RENAME INDEX idx_6fbc9426f5c1a0d77ab0e859 TO tag_parent_visible');
Expand All @@ -45,7 +45,7 @@ public function up(Schema $schema): void

public function down(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('DROP INDEX node_status_parent');
$this->addSql('DROP INDEX node_nodetype_status_parent');
$this->addSql('DROP INDEX node_nodetype_status_parent_position');
Expand Down
8 changes: 4 additions & 4 deletions migrations/Version20210520092543.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public function getDescription(): string

public function up(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'mysql') {
if ('mysql' === $this->connection->getDatabasePlatform()->getName()) {
/*
* MYSQL
*/
$this->addSql('ALTER TABLE node_type_fields ADD serialization_exclusion_expression LONGTEXT DEFAULT NULL, ADD serialization_groups JSON DEFAULT NULL, ADD serialization_max_depth INT DEFAULT NULL, ADD excluded_from_serialization TINYINT(1) DEFAULT \'0\' NOT NULL');
$this->addSql('ALTER TABLE node_types ADD searchable TINYINT(1) DEFAULT \'1\' NOT NULL');
$this->addSql('CREATE INDEX nt_searchable ON node_types (searchable)');
} elseif ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
} elseif ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
/*
* POSTGRES
*/
Expand All @@ -42,11 +42,11 @@ public function up(Schema $schema): void

public function down(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'mysql') {
if ('mysql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER TABLE node_type_fields DROP serialization_exclusion_expression, DROP serialization_groups, DROP serialization_max_depth, DROP excluded_from_serialization');
$this->addSql('DROP INDEX nt_searchable ON node_types');
$this->addSql('ALTER TABLE node_types DROP searchable');
} elseif ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
} elseif ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
/*
* POSTGRES
*/
Expand Down
4 changes: 2 additions & 2 deletions migrations/Version20210527131435.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function getDescription(): string

public function up(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER TABLE redirections ALTER redirecturi TYPE TEXT');
$this->addSql('ALTER TABLE redirections ALTER redirecturi DROP DEFAULT');
$this->addSql('ALTER TABLE redirections ALTER redirecturi TYPE TEXT');
Expand All @@ -27,7 +27,7 @@ public function up(Schema $schema): void

public function down(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER TABLE redirections ALTER redirecturi TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE redirections ALTER redirecturi DROP DEFAULT');
$this->addSql('ALTER TABLE redirections ALTER redirecturi TYPE VARCHAR(255)');
Expand Down
2 changes: 1 addition & 1 deletion migrations/Version20210701151713.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function getDescription(): string

public function up(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('CREATE TABLE webhooks (id VARCHAR(36) NOT NULL, message_type VARCHAR(255) DEFAULT NULL, uri TEXT DEFAULT NULL, payload JSON DEFAULT NULL, throttleSeconds INT NOT NULL, last_triggered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, automatic BOOLEAN DEFAULT \'false\' NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX webhook_message_type ON webhooks (message_type)');
$this->addSql('CREATE INDEX webhook_created_at ON webhooks (created_at)');
Expand Down
4 changes: 2 additions & 2 deletions migrations/Version20210715120118.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getDescription(): string

public function up(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER TABLE webhooks ADD root_node INT DEFAULT NULL');
$this->addSql('ALTER TABLE webhooks ADD CONSTRAINT FK_998C4FDDC2A25172 FOREIGN KEY (root_node) REFERENCES nodes (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
} else {
Expand All @@ -31,7 +31,7 @@ public function up(Schema $schema): void

public function down(Schema $schema): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
$this->addSql('ALTER TABLE webhooks DROP CONSTRAINT FK_998C4FDDC2A25172');
$this->addSql('DROP INDEX webhook_root_node');
} else {
Expand Down
13 changes: 0 additions & 13 deletions phpcs.xml.dist

This file was deleted.

Loading

0 comments on commit 54dadd3

Please sign in to comment.