diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..70c0f43
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,50 @@
+before_script:
+ - apk add --no-cache make wget git
+ - make install-composer
+ - make install
+ - mkdir -p result
+
+stages:
+ - test
+
+lint:coding-guideline:
+ image: php:7.0-alpine
+ stage: test
+ script:
+ - ./vendor/bin/phpcs -s -n
+ - ./vendor/bin/phpcs -s -n > result/phpcs-summary.txt
+ artifacts:
+ when: on_failure
+ paths:
+ - result
+
+lint:php-mass-detection:
+ image: php:7.0-alpine
+ stage: test
+ script:
+ - ./vendor/bin/phpmd src text phpmd.xml > result/phpmd.txt
+ - ./vendor/bin/phpmd src html phpmd.xml > result/phpmd.html
+ artifacts:
+ when: on_failure
+ paths:
+ - result
+
+test:5.6:
+ image: php:5.6-alpine
+ stage: test
+ script:
+ - ./vendor/bin/phpunit
+
+test:7.0:
+ image: php:7.0-alpine
+ stage: test
+ script:
+ - ./vendor/bin/phpunit
+
+test:latest:
+ image: php:7-alpine
+ stage: test
+ script:
+ - ./vendor/bin/phpunit
+
+# Further stages, and jobs e.g. linting, cgl, etc.
diff --git a/Makefile b/Makefile
index 432e039..feeeb7e 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ DEFAULT_STANDARD = Typo3Update
CUSTOM_STANDARDS = $(abspath ./src/Standards/)
install:
- composer install
+ composer install --optimize-autoloader --no-interaction --no-ansi
$(BIN_PHPCS) --config-set installed_paths $(CUSTOM_STANDARDS)
$(BIN_PHPCS) -i | grep Typo3Update
$(BIN_PHPCS) --config-set default_standard $(DEFAULT_STANDARD)
@@ -14,3 +14,13 @@ test-search:
$(BIN_PHPCS) -p --colors -s PROJECT_PATH
test-fix:
$(BIN_PHPCBF) -p --colors -s PROJECT_PATH
+
+# For CI:
+install-composer:
+ wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
+ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+ php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
+ php composer-setup.php
+ php -r "unlink('composer-setup.php'); unlink('installer.sig');"
+ chmod ugo+x composer.phar
+ mv composer.phar /usr/local/bin/composer
diff --git a/composer.json b/composer.json
index 26d1954..ad12b19 100644
--- a/composer.json
+++ b/composer.json
@@ -2,6 +2,13 @@
"name": "siepmann/typo3_update",
"description": "Auto migrate PHP Source of extensions to be compatible.",
"type": "project",
+ "license": "GPL-2.0+",
+ "authors": [
+ {
+ "name": "Daniel Siepmann",
+ "email": "coding@daniel-siepmann.de"
+ }
+ ],
"autoload-dev": {
"psr-4": {
"Typo3Update\\Tests\\": "tests/"
@@ -20,15 +27,10 @@
"squizlabs/php_codesniffer": "2.8.*",
"symfony/yaml": "3.2.*"
},
- "license": "GPL-2.0+",
- "authors": [
- {
- "name": "Daniel Siepmann",
- "email": "coding@daniel-siepmann.de"
- }
- ],
"require-dev": {
- "phpunit/phpunit": "^5.7",
- "symfony/finder": "^3.2"
+ "phpunit/phpunit": "5.7.*",
+ "symfony/finder": "3.2.*",
+ "phpmd/phpmd": "2.6.*",
+ "pdepend/pdepend": "2.5.*"
}
}
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
new file mode 100644
index 0000000..c742021
--- /dev/null
+++ b/phpcs.xml.dist
@@ -0,0 +1,22 @@
+
+
+ The coding standard for this Project
+
+ ./src
+ ./tests
+ */Fixtures/*
+
+
+
+ *Sniff.php$
+ */Tokenizers/*
+
+
+ *Sniff.php$
+ */Tokenizers/*
+
+
+ *Sniff.php$
+ */Tokenizers/*
+
+
diff --git a/phpmd.xml b/phpmd.xml
new file mode 100644
index 0000000..67d345c
--- /dev/null
+++ b/phpmd.xml
@@ -0,0 +1,27 @@
+
+
+
+ My custom rule set that checks my code...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CodeSniffer/Tokenizers/TypoScript.php b/src/CodeSniffer/Tokenizers/TypoScript.php
index 8130faf..26136f6 100644
--- a/src/CodeSniffer/Tokenizers/TypoScript.php
+++ b/src/CodeSniffer/Tokenizers/TypoScript.php
@@ -65,6 +65,8 @@ class PHP_CodeSniffer_Tokenizers_TYPOSCRIPT
* @param string $eolChar The EOL character to use for splitting strings.
*
* @return void
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter) We need to match the signature.
*/
public function processAdditional(&$tokens, $eolChar)
{
diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php
index 19719e9..76c3cfe 100644
--- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php
+++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php
@@ -82,6 +82,8 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
* the token was found.
*
* @return void
+ *
+ * @SuppressWarnings(PHPMD.ElseExpression) This is for performance reason.
*/
public function process(PhpCsFile $phpcsFile, $stackPtr)
{
@@ -217,6 +219,8 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
* @param int $classnamePosition
* @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
+ *
+ * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
protected function replaceLegacyClassname(
PhpCsFile $phpcsFile,
@@ -243,6 +247,8 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
* @param string $originalClassname
* @param PhpCsFile $phpcsFile
* @return string
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter) We need to match the signature.
*/
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
{
diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php
index 201263a..685dec6 100644
--- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php
+++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php
@@ -48,6 +48,9 @@ final class Mapping
private function __clone()
{
}
+ /**
+ * @SuppressWarnings(PHPMD.UnusedPrivateMethod) We just want to implement singleton pattern.
+ */
private function __wakeup()
{
}
diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php
index e8d0feb..8e97c45 100644
--- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php
+++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php
@@ -95,6 +95,8 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
* @param int $classnamePosition
* @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
+ *
+ * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
protected function replaceLegacyClassname(
PhpCsFile $phpcsFile,
diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff.php
index f1129ba..bed18bc 100644
--- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff.php
+++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff.php
@@ -46,6 +46,8 @@ class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChec
* @param int $classnamePosition
* @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
+ *
+ * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
protected function replaceLegacyClassname(
PhpCsFile $phpcsFile,
diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php
index 766db34..13697f0 100644
--- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php
+++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php
@@ -29,8 +29,9 @@ use Typo3Update\Sniffs\Options;
/**
* Contains common functionality for removed code like constants or functions.
*
- * Removed parts are configured using YAML-Files, for examples see src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml
- * Also check out the configuration options in Readme.rst.
+ * Removed parts are configured using YAML-Files, for examples see
+ * src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml Also
+ * check out the configuration options in Readme.rst.
*/
abstract class AbstractGenericUsage implements PhpCsSniff
{
diff --git a/tests/SniffsTest.php b/tests/SniffsTest.php
index 16d58b0..2560f1a 100644
--- a/tests/SniffsTest.php
+++ b/tests/SniffsTest.php
@@ -115,6 +115,7 @@ class SniffsTest extends TestCase
protected function executeSniff(\SplFileInfo $folder, array $arguments = [])
{
$internalArguments = array_merge_recursive([
+ 'standard' => 'Typo3Update',
'runtime-set' => [
'mappingFile' => __DIR__ . DIRECTORY_SEPARATOR
. 'Fixtures' . DIRECTORY_SEPARATOR