mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts: .travis.yml
This commit is contained in:
commit
738581f0f5
5
.scrutinizer.yml
Normal file
5
.scrutinizer.yml
Normal file
@ -0,0 +1,5 @@
|
||||
tools:
|
||||
custom_commands:
|
||||
-
|
||||
scope: file
|
||||
command: php tests/phpcs_runner.php %pathname%
|
@ -24,14 +24,13 @@ matrix:
|
||||
- env: PHPCS=1 CORE_RELEASE=3.1
|
||||
|
||||
before_script:
|
||||
- pear install pear/PHP_CodeSniffer
|
||||
- phpenv rehash
|
||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
||||
- cd ~/builds/ss
|
||||
|
||||
script:
|
||||
- sh -c "if [ '$PHPCS' != '1' ]; then phpunit framework/tests; else phpcs --encoding=utf-8 --tab-width=4 --standard=framework/tests/phpcs/ruleset.xml -np framework && phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml -np framework; fi"
|
||||
- phpunit framework/tests
|
||||
|
||||
branches:
|
||||
except:
|
||||
|
@ -83,7 +83,7 @@ WARNING: Currently the UploadField doesn't fully support has_many relations, so
|
||||
### Overview
|
||||
|
||||
The field can either be configured on an instance level through `setConfig(<key>, <value>)`,
|
||||
or globally by overriding the YAML defaults. See the [Configuration Reference](#configuration-reference) section for possible values.
|
||||
or globally by overriding the YAML defaults. See the [Configuration Reference](uploadfield#configuration-reference) section for possible values.
|
||||
|
||||
Example: mysite/_config/uploadfield.yml
|
||||
|
||||
|
@ -14,14 +14,6 @@
|
||||
<!-- PHP-PEG generated file not intended for human consumption -->
|
||||
<exclude-pattern>*/SSTemplateParser.php$</exclude-pattern>
|
||||
|
||||
<rule ref="Generic.Files.LineEndings.InvalidEOLChar">
|
||||
<severity>8</severity>
|
||||
</rule>
|
||||
<rule ref="Generic.Files.LineEndings">
|
||||
<properties>
|
||||
<property name="eolChar" value="\n" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Generic.Files.LineLength.TooLong">
|
||||
<severity>7</severity>
|
||||
</rule>
|
||||
|
@ -14,5 +14,13 @@
|
||||
<!-- PHP-PEG generated file not intended for human consumption -->
|
||||
<exclude-pattern>*/SSTemplateParser.php$</exclude-pattern>
|
||||
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
|
||||
<rule ref="Generic.Files.LineEndings.InvalidEOLChar">
|
||||
<severity>8</severity>
|
||||
</rule>
|
||||
<rule ref="Generic.Files.LineEndings">
|
||||
<properties>
|
||||
<property name="eolChar" value="\n" />
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
||||
|
48
tests/phpcs_runner.php
Normal file
48
tests/phpcs_runner.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
if(php_sapi_name() != 'cli') {
|
||||
die("This script must be called from the command line\n");
|
||||
}
|
||||
|
||||
if(!empty($_SERVER['argv'][1])) {
|
||||
$path = $_SERVER['argv'][1];
|
||||
} else {
|
||||
die("Usage: php {$_SERVER['argv'][0]} <file>\n");
|
||||
}
|
||||
|
||||
$result = array('comments' => array());
|
||||
|
||||
// Run each sniff
|
||||
|
||||
// phpcs --encoding=utf-8 --standard=framework/tests/phpcs/tabs.xml
|
||||
run_sniff('tabs.xml', $path, $result);
|
||||
|
||||
// phpcs --encoding=utf-8 --tab-width=4 --standard=framework/tests/phpcs/ruleset.xml
|
||||
run_sniff('ruleset.xml', $path, $result, '--tab-width=4');
|
||||
|
||||
echo json_encode($result);
|
||||
|
||||
function run_sniff($standard, $path, array &$result, $extraFlags = '') {
|
||||
$sniffPath = escapeshellarg(__DIR__ . '/phpcs/' . $standard);
|
||||
$checkPath = escapeshellarg($path);
|
||||
|
||||
exec("phpcs --encoding=utf-8 $extraFlags --standard=$sniffPath --report=xml $checkPath", $output);
|
||||
|
||||
// We can't check the return code as it's non-zero if the sniff finds an error
|
||||
if($output) {
|
||||
$xml = implode("\n", $output);
|
||||
$xml = simplexml_load_string($xml);
|
||||
$errors = $xml->xpath('/phpcs/file/error');
|
||||
if($errors) {
|
||||
$sanePath = str_replace('/', '_', $path);
|
||||
foreach($errors as $error) {
|
||||
$attributes = $error->attributes();
|
||||
$result['comments'][] = array(
|
||||
'line' => (int)strval($attributes->line),
|
||||
'id' => $standard . '-' . $sanePath . '-' . $attributes->line . '-' . $attributes->column,
|
||||
'message' => strval($error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user