Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
added travis/scrutinizer/phpcsfixer/editorconfig + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelandrieu committed Jun 5, 2016
1 parent 78af389 commit a9f7722
Show file tree
Hide file tree
Showing 26 changed files with 360 additions and 236 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
end_of_line = LF

[*.php]
indent_style = space
indent_size = 4
18 changes: 18 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

return Symfony\CS\Config\Config::create()
// use SYMFONY_LEVEL:
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
// and extra fixers:
->fixers(array(
'short_array_syntax',
))
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->in('src/')
->in('app/')
->exclude('cache')
->exclude('logs')
->exclude('Resources')
)
;
14 changes: 14 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
filter:
excluded_paths:
- 'vendor/*'
- 'tests/*'
- 'src/PrestaShopBundle/Tests/*'

tools:
php_cs_fixer:
config:
level: symfony
fixers: { short_array_syntax: true }

build_failure_conditions:
- 'issues.label("coding-style").new.exists'
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: php

sudo: false

cache:
directories:
- bin
- vendor
- $HOME/.composer/cache

php:
- 5.6
- 7.0

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

install:
- composer update --prefer-dist --no-interaction --no-progress

script:
- bin/phpunit -c app/

notifications:
email: false
6 changes: 3 additions & 3 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
Expand All @@ -17,9 +17,9 @@ public function registerBundles()
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
);
];

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
Expand Down
12 changes: 6 additions & 6 deletions app/SymfonyRequirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $
*/
class RequirementCollection implements IteratorAggregate
{
private $requirements = array();
private $requirements = [];

/**
* Gets the current RequirementCollection as an Iterator.
Expand Down Expand Up @@ -279,7 +279,7 @@ public function all()
*/
public function getRequirements()
{
$array = array();
$array = [];
foreach ($this->requirements as $req) {
if (!$req->isOptional()) {
$array[] = $req;
Expand All @@ -296,7 +296,7 @@ public function getRequirements()
*/
public function getFailedRequirements()
{
$array = array();
$array = [];
foreach ($this->requirements as $req) {
if (!$req->isFulfilled() && !$req->isOptional()) {
$array[] = $req;
Expand All @@ -313,7 +313,7 @@ public function getFailedRequirements()
*/
public function getRecommendations()
{
$array = array();
$array = [];
foreach ($this->requirements as $req) {
if ($req->isOptional()) {
$array[] = $req;
Expand All @@ -330,7 +330,7 @@ public function getRecommendations()
*/
public function getFailedRecommendations()
{
$array = array();
$array = [];
foreach ($this->requirements as $req) {
if (!$req->isFulfilled() && $req->isOptional()) {
$array[] = $req;
Expand Down Expand Up @@ -432,7 +432,7 @@ public function __construct()
);

if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) {
$timezones = array();
$timezones = [];
foreach (DateTimeZone::listAbbreviations() as $abbreviations) {
foreach ($abbreviations as $abbreviation) {
$timezones[$abbreviation['timezone_id']] = true;
Expand Down
4 changes: 2 additions & 2 deletions app/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
use Composer\Autoload\ClassLoader;

/**
* @var ClassLoader $loader
* @var ClassLoader
*/
$loader = require __DIR__.'/../vendor/autoload.php';

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
AnnotationRegistry::registerLoader([$loader, 'loadClass']);

return $loader;
6 changes: 3 additions & 3 deletions app/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

echo '> Checking Symfony requirements:'.PHP_EOL.' ';

$messages = array();
$messages = [];
foreach ($symfonyRequirements->getRequirements() as $req) {
/** @var $req Requirement */
if ($helpText = get_error_message($req, $lineSize)) {
Expand Down Expand Up @@ -99,15 +99,15 @@ function echo_title($title, $style = null)
function echo_style($style, $message)
{
// ANSI color codes
$styles = array(
$styles = [
'reset' => "\033[0m",
'red' => "\033[31m",
'green' => "\033[32m",
'yellow' => "\033[33m",
'error' => "\033[37;41m",
'success' => "\033[37;42m",
'title' => "\033[34m",
);
];
$supports = has_color_support();

echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : '');
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"lp-digital/github-event-parser": "~0.7"
},
"require-dev": {
"phpunit/phpunit": "5.4.*"
"phpunit/phpunit": "5.4.*",
"fabpot/php-cs-fixer": "1.11.3"
},
"scripts": {
"post-root-package-install": [
Expand Down
59 changes: 57 additions & 2 deletions composer.lock

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

8 changes: 4 additions & 4 deletions src/AppBundle/Comments/GitHubCommentApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
use Lpdigital\Github\Entity\PullRequest;

/**
* Responsible of comments publication on repository
* Responsible of comments publication on repository.
*/
class GitHubCommentApi
{
/**
* @var Issue
*/
private $issue;

/**
* @var string
*/
Expand All @@ -24,14 +24,14 @@ class GitHubCommentApi
* @var string
*/
private $repositoryName;

public function __construct(Issue $issue, $repositoryUsername, $repositoryName)
{
$this->issue = $issue;
$this->repositoryUsername = $repositoryUsername;
$this->repositoryName = $repositoryName;
}

public function send(PullRequest $pullRequest, $comment)
{
$this->issue
Expand Down
4 changes: 2 additions & 2 deletions src/AppBundle/Controller/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public function githubAction(Request $request)
{
$data = json_decode($request->getContent(), true);
$responseData = [];

if ($data === null) {
return new JsonResponse(['error' => 'Invalid JSON body'], 500);
}

$event = $this->get('app.webhook_resolver')->resolve($data);
$githubEvent = new GitHubEvent($event::name(), $event);

if ($event instanceof ActionableEventInterface) {
$eventName = strtolower($event::name()).'_'.$event->getAction();

Expand Down
12 changes: 6 additions & 6 deletions src/AppBundle/Event/GitHubEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@
use Symfony\Component\EventDispatcher\Event;

/**
* Every event returned by GitHub is stored as a GitHubEvent instance
* Every event returned by GitHub is stored as a GitHubEvent instance.
*/
class GitHubEvent extends Event
{
private $name;
private $event;
private $statuses;

public function __construct($name, $event)
{
$this->name = $name;
$this->event = $event;
$this->statuses = [];
}

public function getName()
{
return $this->name;
}

public function getEvent()
{
return $this->event;
}

public function getStatuses()
{
return $this->statuses;
}

public function addStatus($status)
{
$this->statuses[] = $status;
Expand Down
Loading

0 comments on commit a9f7722

Please sign in to comment.