Skip to content

Commit

Permalink
Fixes for PHPCQ2
Browse files Browse the repository at this point in the history
  • Loading branch information
e-spin committed Jan 20, 2024
1 parent 6ae8741 commit 50f79aa
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 24 deletions.
15 changes: 15 additions & 0 deletions .composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"symbol-whitelist": [
"Contao\\ManagerBundle\\ContaoManagerBundle",
"Contao\\ManagerPlugin\\Bundle\\BundlePluginInterface",
"Contao\\ManagerPlugin\\Bundle\\Config\\BundleConfig",
"Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface",
"Symfony\\Component\\Config\\FileLocator",
"Symfony\\Component\\Console\\Application",
"Symfony\\Component\\DependencyInjection\\ContainerBuilder",
"Symfony\\Component\\DependencyInjection\\Loader\\YamlFileLoader",
"Symfony\\Component\\HttpFoundation\\Response",
"Symfony\\Component\\HttpKernel\\Bundle\\Bundle",
"Symfony\\Component\\HttpKernel\\DependencyInjection\\ConfigurableExtension"
]
}
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
phpunit.xml.dist export-ignore
/.github export-ignore
/tests export-ignore
1 change: 1 addition & 0 deletions .phpcq.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.16","url":"https://phar.phpunit.de/phpunit-9.6.16.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"891d46f06284db3695498aff5dfd6a944f835e07db2981295db2c2bcf6cfd338"},"signature":"https://phar.phpunit.de/phpunit-9.6.16.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.20.0","url":"https://github.com/vimeo/psalm/releases/download/5.20.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.20.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.7.1","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.7.1/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.8.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcs.phar.asc"},"phpcbf":{"version":"3.8.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.41.1","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.41.1/composer-normalize.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.41.1/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]}
112 changes: 112 additions & 0 deletions .phpcq.yaml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
phpcq:
repositories:
- https://phpcq.github.io/repository/repository.json
directories:
- src
- tests
artifact: .phpcq/build
composer:
autodiscover: false

plugins:
phpunit:
version: ^1.0
signed: false
psalm:
version: ^1.0
signed: false
composer-require-checker:
version: ^1.0
signed: false
phpmd:
version: ^1.0
signed: false
phpcpd:
version: ^1.1
signed: false
phploc:
version: ^1.0
signed: false
phpcs:
version: ^1.0
signed: false
composer-normalize:
version: ^1.0
signed: false
trusted-keys:
# composer-require-checker
- 033E5F8D801A2F8D
# sb@sebastian-bergmann.de
- 4AA394086372C20A
# psalm
- 8A03EA3B385DBAA1
- 12CE0F1D262429A5
# magl@magll.net
- D2CCAC42F6295E7D
# PHP_CodeSniffer
- 31C7E470E2138192
# Composer normalize
- C00543248C87FB13
# phpmd
- A4E55EA12C7C085C
- 9093F8B32E4815AA

tasks:
fix:
- composer-normalize-fix
- phpcbf

verify:
- composer-require-checker
- composer-normalize

analyze:
- phploc
- phpcpd
- phpmd
- phpcs
- psalm
- phpunit

default:
- verify
- analyze

phpcpd:
plugin: phpcpd
config:
exclude:
- tests
- src/CoreBundle/EventListener/DcGeneral/DefinitionBuilder
- src/CoreBundle/Resources/contao/dca

phpmd:
plugin: phpmd
config:
ruleset:
- ./.phpmd.xml

composer-require-checker:
plugin: composer-require-checker
config:
config_file: '.composer-require-checker.json'

phpcs:
plugin: phpcs
config: &phpcs-config
standard: PSR12
excluded:
- '*/Resources/contao/dca/*'
- '*/Resources/contao/languages/*'
- '*/Resources/public/*'

phpcbf:
plugin: phpcs
config:
<<: *phpcs-config
fix: true

composer-normalize-fix:
plugin: composer-normalize
config:
dry_run: false
37 changes: 37 additions & 0 deletions .phpmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<ruleset name="PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation=" http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
PHPMD rule set
</description>

<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCaseVariableName"/>
</rule>
<rule ref="rulesets/controversial.xml/CamelCaseVariableName">
<properties>
<property name="allow-underscore" value="true"/>
</properties>
</rule>
<rule ref="rulesets/design.xml"/>
<rule ref="rulesets/naming.xml">
<exclude name="ShortVariable" />
</rule>
<rule ref="rulesets/naming.xml/ShortVariable">
<properties>
<property name="exceptions" value="id" />
</properties>
</rule>
<rule ref="rulesets/unusedcode.xml">
<exclude name="UnusedLocalVariable"/>
</rule>
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable">
<properties>
<property name="allow-unused-foreach-variables" value="true"/>
</properties>
</rule>
</ruleset>
1 change: 1 addition & 0 deletions .phpunit.result.cache

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "contao-community-alliance/contao-multicolumnwizard-frontend-bundle",
"type": "contao-bundle",
"description": "Frontend support for the MultiColumnWizard",
"license": "LGPL-3.0-or-later",
"type": "contao-bundle",
"keywords": [
"contao",
"multicolumnwizard",
Expand All @@ -11,27 +12,26 @@
"metamodels",
"cca"
],
"homepage": "https://c-c-a.org/",
"license": "LGPL-3.0-or-later",
"authors": [
{
"name": "Richard Henkenjohann",
"email": "richardhenkenjohann@googlemail.com",
"role": "Developer"
}
],
"homepage": "https://c-c-a.org/",
"support": {
"issues": "https://github.com/contao-community-alliance/contao-multicolumnwizard-frontend/issues",
"source": "https://github.com/contao-community-alliance/contao-multicolumnwizard-frontend"
},
"require": {
"php": "^7.4 || ^8.0",
"contao/core-bundle": "^4.13.0, <5.0",
"php": "^8.1",
"contao/core-bundle": "^4.13.0 <5.0",
"menatwork/contao-multicolumnwizard-bundle": "^3.4.7"
},
"require-dev": {
"phpcq/all-tasks": "~1.2",
"contao/manager-bundle": "^4.13.0, <5.0"
"contao/manager-bundle": "^4.13.0 <5.0",
"phpcq/runner-bootstrap": "^1.0@dev"
},
"autoload": {
"psr-4": {
Expand All @@ -43,10 +43,17 @@
"ContaoCommunityAlliance\\MultiColumnWizardFrontendBundle\\Test\\": "tests/"
}
},
"config": {
"allow-plugins": {
"contao-components/installer": true,
"contao/manager-plugin": true,
"php-http/discovery": true
}
},
"extra": {
"contao-manager-plugin": "ContaoCommunityAlliance\\MultiColumnWizardFrontendBundle\\ContaoManager\\Plugin",
"branch-alias": {
"dev-feature/2.3.0": "2.3.x-dev"
}
},
"contao-manager-plugin": "ContaoCommunityAlliance\\MultiColumnWizardFrontendBundle\\ContaoManager\\Plugin"
}
}
25 changes: 25 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
colors="true"
forceCoversAnnotation="true"
failOnRisky="true"
failOnWarning="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="MetaModels attribute for alias tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
16 changes: 16 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="3"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="src/Resources/contao/dca"/>
<directory name="src/Resources/contao/languages"/>
</ignoreFiles>
</projectFiles>
</psalm>
26 changes: 15 additions & 11 deletions src/Contao/Widget/FormMultiColumnWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/contao-multicolumnwizard-frontend-bundle.
*
* (c) 2022 Contao Community Alliance.
* (c) 2020-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,7 +14,7 @@
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @author Stefan Heimes <heimes@men-at-work.de>
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2022 Contao Community Alliance.
* @copyright 2020-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/contao-multicolumnwizard-frontend-bundle/blob/master/LICENSE
* LGPL-3.0-or-later
* @filesource
Expand All @@ -36,6 +36,8 @@ class FormMultiColumnWizard extends MultiColumnWizard
* @param array|null $arrAttributes
*
* @noinspection PhpMissingParentConstructorInspection
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function __construct($arrAttributes = null)
{
Expand All @@ -44,10 +46,11 @@ public function __construct($arrAttributes = null)
$this->strPrefix = 'widget widget-mcw';
$this->strTemplate = 'form_mcw';

$path = 'bundles/multicolumnwizardfrontend/js/';
$GLOBALS['TL_BODY']['mcw_sortable_js'] =
'<script type="text/javascript" src="bundles/multicolumnwizardfrontend/js/Sortable.min.js"></script>';
'<script type="text/javascript" src="' . $path . 'Sortable.min.js"></script>';
$GLOBALS['TL_BODY']['mcw_fe_js'] =
'<script type="text/javascript" src="bundles/multicolumnwizardfrontend/js/multicolumnwizard_fe.min.js"></script>';
'<script type="text/javascript" src="' . $path . 'multicolumnwizard_fe.min.js"></script>';
}

/**
Expand All @@ -65,6 +68,8 @@ protected function convertToResponse($str)

/**
* @inheritdoc
*
* @SuppressWarnings(PHPMD.LongVariable)
*/
public function generate($overwriteRowCurrentRow = null, $onlyRows = false)
{
Expand All @@ -73,7 +78,7 @@ public function generate($overwriteRowCurrentRow = null, $onlyRows = false)
$name = Input::post('name');
$maxRowCount = Input::post('maxRowId');

if ('mcwCreateNewRow' == $action && $name == $this->strName) {
if ('mcwCreateNewRow' === $action && $name === $this->strName) {
// Rewrite the values.
$newRowCount = ($maxRowCount + 1);
foreach ($this->columnFields as $strKey => $arrField) {
Expand All @@ -94,7 +99,7 @@ public function generate($overwriteRowCurrentRow = null, $onlyRows = false)
protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
{
// If null replace it with an empty string.
if ($varValue == '' && isset($arrField['default']) && $arrField['default'] == null) {
if ($varValue === '' && isset($arrField['default']) && $arrField['default'] === null) {
$arrField['default'] = '';
}

Expand All @@ -119,12 +124,11 @@ protected function generateScriptBlock($strId, $maxCount, $minCount)
});
</script>
SCRIPT;
return sprintf(
return \sprintf(
$script,
json_encode($strId),
intval($maxCount),
intval($minCount)
\json_encode($strId) ?? '',
(int) $maxCount,
(int) $minCount
);
}

}
8 changes: 4 additions & 4 deletions src/MultiColumnWizardFrontendBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/contao-multicolumnwizard-frontend-bundle.
*
* (c) 2020 Contao Community Alliance.
* (c) 2020-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,7 +14,7 @@
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @author Stefan Heimes <heimes@men-at-work.de>
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2020 Contao Community Alliance.
* @copyright 2020-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/contao-multicolumnwizard-frontend-bundle/blob/master/LICENSE
* LGPL-3.0-or-later
* @filesource
Expand All @@ -29,8 +29,8 @@

class MultiColumnWizardFrontendBundle extends Bundle
{
const SCOPE_BACKEND = 'backend';
const SCOPE_FRONTEND = 'frontend';
public const SCOPE_BACKEND = 'backend';
public const SCOPE_FRONTEND = 'frontend';

/**
* {@inheritdoc}
Expand Down

0 comments on commit 50f79aa

Please sign in to comment.