Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

CI fixes #102

Open
wants to merge 9 commits 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
87 changes: 57 additions & 30 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,61 @@
<?php
use Symfony\CS\Config\Config;
use Symfony\CS\Finder\DefaultFinder;
use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;
use Symfony\CS\FixerInterface;

$finder = DefaultFinder::create()->in(['config', 'src', 'tests']);
$header = <<< EOF
This file is part of Underscore.php
$config = PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PHP56Migration' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'align_multiline_comment' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_statement' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
// one should use PHPUnit methods to set up expected exception instead of annotations
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']],
'heredoc_to_nowdoc' => true,
'list_syntax' => ['syntax' => 'long'],
'method_argument_space' => ['ensure_fully_multiline' => true],
'no_extra_consecutive_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
'no_homoglyph_names' => true,
'no_null_property_initialization' => true,
'no_short_echo_tag' => true,
'no_superfluous_elseif' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'php_unit_test_class_requires_covers' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_types_order' => true,
'semicolon_after_instruction' => true,
'single_line_comment_style' => true,
'strict_comparison' => true,
'strict_param' => true,
'yoda_style' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('tests/Fixtures')
->in(__DIR__)
)
;

(c) Maxime Fabre <[email protected]>
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
try {
PhpCsFixer\FixerFactory::create()
->registerBuiltInFixers()
->registerCustomFixers($config->getCustomFixers())
->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
$config->setRules([]);
} catch (UnexpectedValueException $e) {
$config->setRules([]);
}

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

HeaderCommentFixer::setHeader($header);

return Config::create()
->level(FixerInterface::SYMFONY_LEVEL)
->fixers([
'ereg_to_preg',
'header_comment',
'multiline_spaces_before_semicolon',
'ordered_use',
'php4_constructor',
'phpdoc_order',
'short_array_syntax',
'short_echo_tag',
'strict',
'strict_param',
])
->setUsingCache(true)
->finder($finder);
return $config;
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ sudo: false
# Setup build matrix
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

env:
global:
- COMPOSER_DISABLE_XDEBUG_WARN=1
matrix:
- PREFER_LOWEST="--prefer-lowest"
- PREFER_LOWEST=""

# Dependencies
before_install:
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi
- composer self-update

install:
- travis_retry composer update --no-interaction --prefer-source --dev $PREFER_LOWEST
- travis_retry composer update --no-interaction --prefer-source $PREFER_LOWEST

script: composer test

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"patchwork/utf8": "^1.2"
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.10",
"friendsofphp/php-cs-fixer": "^2.6.0",
"phpunit/phpunit": "^4.8"
},
"autoload": {
Expand All @@ -33,7 +33,7 @@
}
},
"scripts": {
"test": ["php-cs-fixer fix --dry-run", "phpunit --verbose"],
"test": ["php-cs-fixer fix --dry-run --verbose", "phpunit --verbose"],
"lint": "php-cs-fixer fix"
}
}
2 changes: 0 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/

return [

// The alias Underscore will be mapped to
'alias' => 'Underscore',

Expand All @@ -21,5 +20,4 @@
'select' => 'filter',
'sortBy' => 'sort',
],

];
20 changes: 11 additions & 9 deletions helpers.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<?php

/**
* Shortcut alias to creating an Underscore object
* Shortcut alias to creating an Underscore object.
*
* @param mixed $type A scalar type to wrap
*
* @return \Underscore\Underscore
*/
if ( ! function_exists('underscore')) {
function underscore($type) {
return new Underscore\Underscore($type);
}
if (!function_exists('underscore')) {
function underscore($type)
{
return new Underscore\Underscore($type);
}
}

/**
/*
* Shortcut alias for underscore()
*
* @param mixed $type
*
* @return \Underscore\Underscore
*/
if (!function_exists('__')) {
function __($type) {
return underscore($type);
}
function __($type)
{
return underscore($type);
}
}
3 changes: 2 additions & 1 deletion src/Dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ public static function toNative($class, $method)
switch ($class) {
case static::TYPES.'Arrays':
$prefix = 'array_';
break;

break;
case static::TYPES.'Strings':
$prefix = 'str_';

break;
}

Expand Down
Loading