Skip to content

Commit 54d066b

Browse files
authored
Merge pull request #160 from tgalopin/coding-style
Improve Travis configuration and add PHP-CS-Fixer
2 parents c76378a + 91e7977 commit 54d066b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1399
-1437
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
vendor/
22
scratch.php
33
composer.lock
4-
build/
4+
build/
5+
.php_cs.cache

.php_cs.dist

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__)
5+
;
6+
7+
return PhpCsFixer\Config::create()
8+
->setRules(array(
9+
'@Symfony' => true,
10+
'concat_space' => array('spacing' => 'one'),
11+
'phpdoc_annotation_without_dot' => false,
12+
))
13+
->setFinder($finder)
14+
;

.travis.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
language: php
2-
2+
dist: trusty
33
sudo: false
44

5-
php:
6-
- 5.4
7-
- 5.5
8-
- 5.6
9-
- 7.0
10-
- 7.1
11-
- 7.2
12-
- hhvm
13-
145
matrix:
15-
include:
16-
- php: 5.3
17-
dist: precise
18-
fast_finish: true
19-
20-
dist: trusty
6+
include:
7+
- php: 5.3
8+
dist: precise
9+
env: COMPOSER_FLAGS="--prefer-lowest"
10+
- php: 5.4
11+
- php: 5.5
12+
- php: 5.6
13+
env: SCRUTINIZER=1
14+
- php: 7.0
15+
env: COMPOSER_FLAGS="--prefer-lowest"
16+
- php: 7.1
17+
env: CS_FIXER=1
18+
- php: 7.2
19+
env: BENCHMARK=1
20+
- php: hhvm
21+
fast_finish: true
2122

2223
cache:
2324
directories:
2425
- $HOME/.composer/cache
2526

26-
notifications:
27-
irc: "irc.freenode.net#masterminds"
28-
2927
before_script:
3028
- composer self-update
31-
- composer install
29+
- composer update $COMPOSER_FLAGS --prefer-dist
3230

3331
script:
32+
- stty cols 120
33+
- if [ "$CS_FIXER" == 1 ]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.13.1/php-cs-fixer.phar && php php-cs-fixer.phar fix --dry-run --diff; fi
3434
- mkdir -p build/logs
3535
- ./vendor/bin/phpunit --coverage-clover=coverage.xml
3636

3737
after_script:
38-
- bash -c 'if [ "$TRAVIS_PHP_VERSION" == "5.6" ] ; then wget https://scrutinizer-ci.com/ocular.phar; fi;'
39-
- bash -c 'if [ "$TRAVIS_PHP_VERSION" == "5.6" ] ; then php ocular.phar code-coverage:upload --format=php-clover coverage.xml; fi;'
40-
- php test/benchmark/run.php 10
38+
- if [ "$SCRUTINIZER" == 1 ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.xml; fi
39+
- if [ "$BENCHMARK" == 1 ]; then php test/benchmark/run.php 10; fi
40+
41+
notifications:
42+
irc: "irc.freenode.net#masterminds"

bin/entities.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111

1212
$table = array();
1313
foreach ($json as $name => $obj) {
14-
$sname = substr($name, 1, -1);
15-
$table[$sname] = $obj->characters;
14+
$sname = substr($name, 1, -1);
15+
$table[$sname] = $obj->characters;
1616
}
1717

18-
print '<?php
18+
echo '<?php
1919
namespace Masterminds\\HTML5;
2020
/** Entity lookup tables. This class is automatically generated. */
2121
class Entities {
2222
public static $byName = ';
2323
var_export($table);
24-
print ';
24+
echo ';
2525
}' . PHP_EOL;
2626
//print serialize($table);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"require-dev": {
2929
"satooshi/php-coveralls": "1.0.*",
30-
"phpunit/phpunit" : "4.*",
30+
"phpunit/phpunit" : "^4.8.35",
3131
"sami/sami": "~2.0"
3232
},
3333
"autoload": {

example.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22

3-
require "vendor/autoload.php";
3+
require 'vendor/autoload.php';
44
use Masterminds\HTML5;
55

6-
76
$html = <<< 'HERE'
87
<html>
98
<head>
@@ -28,6 +27,6 @@
2827
$html5 = new HTML5();
2928
$dom = $html5->loadHTML($html);
3029

31-
print "Converting to HTML 5\n";
30+
echo "Converting to HTML 5\n";
3231

33-
$html5->save($dom, fopen("php://stdin", 'w'));
32+
$html5->save($dom, fopen('php://stdin', 'w'));

sami.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
use Sami\Sami;
44

5-
return new Sami(__DIR__ . '/src' , array(
6-
'title' => 'HTML5-PHP API',
7-
'build_dir' => __DIR__.'/build/apidoc',
8-
'cache_dir' => __DIR__.'/build/sami-cache',
5+
return new Sami(__DIR__ . '/src', array(
6+
'title' => 'HTML5-PHP API',
7+
'build_dir' => __DIR__ . '/build/apidoc',
8+
'cache_dir' => __DIR__ . '/build/sami-cache',
99
'default_opened_level' => 1,
10-
));
10+
));

0 commit comments

Comments
 (0)