Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Introduce CS Fixer #1991

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
80 changes: 6 additions & 74 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,17 @@
# -----------------------------------------------------------------------------
# MantisBT Travis-CI build configuration file
# -----------------------------------------------------------------------------

language: php
os: linux
dist: focal

# -----------------------------------------------------------------------------
# Environment setup and test scripts execution
#

services:
- postgresql
- mysql

install:
- composer install

before_script:
# sendmail replacement
- chmod +x "$TRAVIS_BUILD_DIR/tests/fakesendmail.sh"
- echo 'sendmail_path = $TRAVIS_BUILD_DIR/tests/fakesendmail.sh' > ./tests/sendmail.ini
- phpenv config-add ./tests/sendmail.ini

# MantisBT setup
- ./build/travis_before_script.sh

script:
- ./build/travis_script.sh

# -----------------------------------------------------------------------------
# What to build, and on which platforms
#

branches:
only:
- master
- /master-[0-9.]+/

php:
- 8.3
- 8.2
- 8.1
- 8.0
- 7.4

env:
- DB=mysql
- DB=pgsql

jobs:
include:
# Add a specific build for Documentation
- name: Documentation
env: DOCBOOK=1
# Using Ruby as it's preinstalled and we don't need PHP to build docs
language: ruby
addons:
apt:
packages:
- publican

allow_failures: []


# -----------------------------------------------------------------------------
# Notifications
#

notifications:
email:
on_success: change
on_failure: always

irc:
on_success: change
on_failure: always
channels:
- "chat.freenode.net#mantisbt"
skip_join: true
template:
- "Build #%{build_number}: %{repository} %{branch} (%{commit}) %{author} - %{message}"
- "Build details: %{build_url}"
- "Code Changes: %{compare_url}"
- name: Coding Standards
php: 8.3
script:
- composer check-cs
allow_failures:
- name: Coding Standards
1 change: 1 addition & 0 deletions build/buildrelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# Directories
"docbook/",
"tests/"
"ecs.php"
)

# Checksum types to includ in digest filese
Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
},
"require-dev": {
"ext-zip": "*",
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^9.6",
"symplify/easy-coding-standard": "^12.1"
},
"repositories": [
{
Expand All @@ -38,5 +39,9 @@
"platform": {
"php": "7.4.33"
}
},
"scripts": {
"check-cs": "vendor/bin/ecs check --ansi",
"fix-cs": "vendor/bin/ecs check --fix --ansi"
}
}
}
62 changes: 60 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
# MantisBT - A PHP based bugtracking system
#
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <https://www.gnu.org/licenses/>.

declare( strict_types = 1 );

use PhpCsFixer\Fixer\Basic\EncodingFixer;
use PhpCsFixer\Fixer\PhpTag\EchoTagSyntaxFixer;
use PhpCsFixer\Fixer\PhpTag\FullOpeningTagFixer;
use PhpCsFixer\Fixer\PhpTag\LinebreakAfterOpeningTagFixer;
use PhpCsFixer\Fixer\PhpTag\NoClosingTagFixer;
use PhpCsFixer\Fixer\Whitespace\LineEndingFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Option;

/**
* MantisBT coding standards
*
* @see https://mantisbt.org/wiki/doku.php/mantisbt:coding_guidelines
*/

return ECSConfig::configure()
->withPaths( [
__DIR__ . '/',
] )
->withSkip( [
__DIR__ . '/build',
__DIR__ . '/config',
__DIR__ . '/library',
] )
->withSpacing(
Option::INDENTATION_TAB,
"\n",
)
->withRules( [
/**
* Basic: Encoding
*
* PHP code MUST use only UTF-8 without BOM (remove BOM).
*
* @see https://cs.symfony.com/doc/rules/basic/encoding.html
*/
EncodingFixer::class,

/**
* Whitespace: Line encoding
*
* All PHP files must use same line ending. Default is "\n"
*
* @see https://cs.symfony.com/doc/rules/whitespace/line_ending.html
*/
LineEndingFixer::class,

/**
* PHP tag: Full opening tag
*
* "<?" > "<?php"
*
* @see https://cs.symfony.com/doc/rules/php_tag/full_opening_tag.html
*/
FullOpeningTagFixer::class,

/**
* PHP tag: Linebreak after opening tag
*
* Ensure there is no code on the same line as the PHP open tag.
*
* @see https://cs.symfony.com/doc/rules/php_tag/linebreak_after_opening_tag.html
*/
LinebreakAfterOpeningTagFixer::class,

/**
* PHP tag: Echo tag syntax
*
* Configurable. Default is "format" = "short", "long_function" = "echo"
*
* "<?= …" > "<?php echo …"
*
* @see https://cs.symfony.com/doc/rules/php_tag/echo_tag_syntax.html
*/
EchoTagSyntaxFixer::class,

/**
* PHP tag: No closing tag
*
* The closing ?> tag MUST be omitted from files containing only PHP.
*
* @see https://cs.symfony.com/doc/rules/php_tag/no_closing_tag.html
*/
NoClosingTagFixer::class,
] )
;