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

Add phpcs to CI, following PSR2 #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<ruleset name="cebe/markdown">
<rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent" />

<!-- @TODO The following exclusions need to be checked for validity. -->
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword" />
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine" />
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody" />
<exclude name="PSR2.Files.EndFileNewline.NoneFound" />
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" />
<exclude name="PSR2.Classes.ClassDeclaration.SpaceBeforeName" />
<exclude name="PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter" />
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis" />
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction" />
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />

</rule>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
<arg name="tab-width" value="4" />
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
<file>.</file>
<exclude-pattern>vendor/</exclude-pattern>
</ruleset>
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ install:
- composer install --prefer-dist

script:
- vendor/bin/phpcs -s
- vendor/bin/phpunit --verbose --coverage-clover=coverage.clover
# test against standard markdown spec
# - git clone https://github.com/jgm/stmd && cd stmd && perl runtests.pl spec.txt ../bin/markdown
Expand Down
2 changes: 1 addition & 1 deletion block/CodeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function consumeCode($lines, $current)
$content[] = $line;
// but also if it is empty and the next line is intended by 4 spaces or a tab
} elseif (($line === '' || rtrim($line) === '') && isset($lines[$i + 1][0]) &&
($lines[$i + 1][0] === "\t" || strncmp($lines[$i + 1], ' ', 4) === 0)) {
($lines[$i + 1][0] === "\t" || strncmp($lines[$i + 1], ' ', 4) === 0)) {
if ($line !== '') {
$line = $line[0] === "\t" ? substr($line, 1) : substr($line, 4);
}
Expand Down
2 changes: 1 addition & 1 deletion block/ListTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function identifyUl($line)
{
$l = $line[0];
return ($l === '-' || $l === '+' || $l === '*') && (isset($line[1]) && (($l1 = $line[1]) === ' ' || $l1 === "\t")) ||
($l === ' ' && preg_match('/^ {0,3}[\-\+\*][ \t]/', $line));
($l === ' ' && preg_match('/^ {0,3}[\-\+\*][ \t]/', $line));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"require-dev": {
"phpunit/phpunit": "4.1.*",
"facebook/xhprof": "*@dev",
"cebe/indent": "*"
"cebe/indent": "*",
"squizlabs/php_codesniffer": "^3.6"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions inline/EmphStrongTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ protected function renderEmph($block)
return '<em>' . $this->renderAbsy($block[1]) . '</em>';
}

abstract protected function parseInline($text);
abstract protected function renderAbsy($blocks);
abstract protected function parseInline($text);
abstract protected function renderAbsy($blocks);
}
4 changes: 2 additions & 2 deletions inline/StrikeoutTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ protected function renderStrike($block)
return '<del>' . $this->renderAbsy($block[1]) . '</del>';
}

abstract protected function parseInline($text);
abstract protected function renderAbsy($blocks);
abstract protected function parseInline($text);
abstract protected function renderAbsy($blocks);
}