Skip to content

Commit

Permalink
Merge pull request #91 from koriym/2016
Browse files Browse the repository at this point in the history
year 2016
  • Loading branch information
koriym committed Jan 7, 2016
2 parents 51700dd + 6b5fc68 commit 8b7fc45
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 75 deletions.
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
sudo: false
language: php

php:
- 5.5
- 5.6
- hhvm
- 7

install: travis_retry composer install --no-interaction --prefer-source

before_script:
- composer self-update
- composer install
script:
- if [ "$TRAVIS_PHP_VERSION" == "hhvm" ]; then phpunit; fi
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpunit --coverage-text --coverage-clover=coverage.clover; fi

- phpunit --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012-2015, Akihito Koriyama <[email protected]>
Copyright (c) 2012-2016, Akihito Koriyama <[email protected]>
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
13 changes: 9 additions & 4 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<?xml version="1.0"?>
<ruleset name="BEAR">
<description>The BEAR coding standard.</description>
<!-- 2. General -->
<ruleset>
<description>The coding standard used for applications using BEAR.Sunday Framework.</description>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<!-- Include the whole PSR-2 standard -->
<rule ref="PSR2">
<exclude name="Generic.Files.LineLength"/>
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
</rule>
<rule ref="PEAR.Commenting.FunctionComment">
<exclude name="PEAR.Commenting.FunctionComment.MissingReturn"/>
<exclude name="PEAR.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="PEAR.Commenting.FunctionComment.SpacingBeforeTags"/>
<exclude name="PEAR.Commenting.FunctionComment.MissingParamTag"/>
<exclude name="PEAR.Commenting.FunctionComment.Missing"/>
<exclude name="PEAR.Commenting.FunctionComment.MissingReturn"/>
<exclude name="PEAR.Commenting.FunctionComment.ParameterCommentsNotAligned"/>
<exclude name="PEAR.Commenting.FileComment.Missing"/>
</rule>
<file>src</file>
<file>tests</file>
</ruleset>
76 changes: 43 additions & 33 deletions phpmd.xml
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<!--codesize-->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
<rule ref="rulesets/codesize.xml/NPathComplexity" />
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity" />
<rule ref="rulesets/codesize.xml/ExcessiveClassLength" />
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength" />
<rule ref="rulesets/codesize.xml/ExcessiveParameterList" />
<rule ref="rulesets/codesize.xml/ExcessivePublicCount" />
<rule ref="rulesets/codesize.xml/TooManyFields" />
<rule ref="rulesets/codesize.xml/TooManyMethods" />
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="20"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/NPathComplexity">
<properties>
<property name="minimum" value="200"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
<properties>
<property name="maximum" value="100"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>
<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>
<rule ref="rulesets/codesize.xml/TooManyFields"/>
<rule ref="rulesets/codesize.xml/TooManyMethods"/>
<!--design-->
<rule ref="rulesets/design.xml/EvalExpression" />
<rule ref="rulesets/design.xml/ExitExpression" />
<rule ref="rulesets/design.xml/GotoStatement" />
<rule ref="rulesets/design.xml/NumberOfChildren" />
<rule ref="rulesets/design.xml/DepthOfInheritance" />
<rule ref="rulesets/design.xml/CouplingBetweenObjects" />
<rule ref="rulesets/design.xml/EvalExpression"/>
<rule ref="rulesets/design.xml/ExitExpression"/>
<rule ref="rulesets/design.xml/GotoStatement" />
<rule ref="rulesets/design.xml/NumberOfChildren"/>
<rule ref="rulesets/design.xml/DepthOfInheritance"/>
<!-- <rule ref="rulesets/design.xml/CouplingBetweenObjects" /> -->
<!--naming-->
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
<rule ref="rulesets/naming.xml/BooleanGetMethodName" />
<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
<rule ref="rulesets/naming.xml/BooleanGetMethodName"/>
<!--unusedcode-->
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter" />
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" />
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField" />
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" />
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
<!--controversial-->
<rule ref="rulesets/controversial.xml/Superglobals" />
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
<rule ref="rulesets/controversial.xml/CamelCaseClassName"/>
<rule ref="rulesets/controversial.xml/CamelCasePropertyName"/>
<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>
<!--cleancode-->
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
<rule ref="rulesets/cleancode.xml/ElseExpression" />
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag"/>
<!-- <rule ref="rulesets/cleancode.xml/ElseExpression" /> -->
</ruleset>
2 changes: 2 additions & 0 deletions src/Module/Constant/NamedModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
namespace BEAR\Sunday\Module\Constant;

use BEAR\Sunday\FakeApplication;
use Ray\Di\AbstractModule;

class NamedModule extends AbstractModule
Expand All @@ -29,6 +30,7 @@ public function __construct(array $names)
*/
protected function configure()
{
$this->bind(FakeApplication::class);
foreach ($this->names as $annotatedWith => $instance) {
$this->bind()->annotatedWith($annotatedWith)->toInstance($instance);
}
Expand Down
1 change: 1 addition & 0 deletions src/Provide/Transfer/HttpResponder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class HttpResponder implements TransferInterface
*/
public function __invoke(ResourceObject $resourceObject, array $server)
{
unset($server);
// render
$body = (string) $resourceObject;

Expand Down
30 changes: 30 additions & 0 deletions tests/Fake/FakeApplication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace BEAR\Sunday;

use Ray\Di\Di\Inject;
use Ray\Di\Di\Named;

class FakeApplication
{
public $dir;
public $id;

/**
* @Inject
* @Named("path")
*/
public function setPath($dir)
{
$this->dir = $dir;
}

/**
* @Inject
* @Named("id")
*/
public function setId($id)
{
$this->id = $id;
}
}
31 changes: 3 additions & 28 deletions tests/Module/Constant/NamedModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,13 @@

namespace BEAR\Sunday\Module\Constant;

use Ray\Di\Di\Inject;
use Ray\Di\Di\Named;
use Ray\Di\Injector;

class Application
{
public $dir;
public $id;

/**
* @Inject
* @Named("path")
*/
public function setPath($dir)
{
$this->dir = $dir;
}

/**
* @Inject
* @Named("id")
*/
public function setId($id)
{
$this->id = $id;
}
}
use BEAR\Sunday\FakeApplication;

class ConstantModuleTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Application
* @var FakeApplication
*/
private $app;

Expand All @@ -43,7 +18,7 @@ protected function setUp()
'path' => __DIR__,
'id' => 'bear'
];
$this->app = (new Injector(new NamedModule($names)))->getInstance(__NAMESPACE__ .'\Application');
$this->app = (new Injector(new NamedModule($names)))->getInstance(FakeApplication::class);
}

public function testNamed()
Expand Down

0 comments on commit 8b7fc45

Please sign in to comment.