Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnitとQAツールを追加 #11

Merged
merged 2 commits into from
Nov 20, 2020
Merged
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
3 changes: 3 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,8 @@ return \PhpCsFixer\Config::create()
->setUsingCache(true)
->setFinder(
PhpCsFixer\Finder::create()
->exclude([
'tmp/'
])
->in(__DIR__)
);
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
},
"license": "MIT",
"scripts" :{
"test": ["phpunit"],
"tests": ["psalm --show-info=false", "@cs"],
"cs": ["php-cs-fixer fix -v --dry-run", "phpcs --standard=./phpcs.xml src"],
"cs-fix": ["php-cs-fixer fix -v", "phpcbf src"]
"cs": ["php-cs-fixer fix -v --dry-run"],
"cs-fix": ["php-cs-fixer fix -v"]
},
"require-dev": {
"vimeo/psalm": "^3.4"
"vimeo/psalm": "^4.2",
"phpunit/phpunit": "^7.5",
"friendsofphp/php-cs-fixer": "^2.16"
}
}
2 changes: 1 addition & 1 deletion demo/public/protected/controllers/SiteController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Ray\Di\Di\Inject;
use Koriym\Dii\Injectable;
use Ray\Di\Di\Inject;
use Vendor\Hello\FooInterface;

/**
Expand Down
18 changes: 18 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="all">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="-1" />
</php>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
9 changes: 9 additions & 0 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.2.0@ccf6e2805f4c38655110f425c10ca79511f0bb0e">
<file src="src/Dii.php">
<UndefinedClass occurrences="2">
<code>AppModule</code>
<code>AppModule</code>
</UndefinedClass>
</file>
</files>
43 changes: 2 additions & 41 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,55 +1,16 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
errorLevel="6"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm.baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<InternalMethod errorLevel="info" />
<InternalProperty errorLevel="info" />
<InternalClass errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />

<InvalidStringClass errorLevel="info" />
</issueHandlers>
</psalm>
4 changes: 2 additions & 2 deletions src/Dii.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Koriym\Dii;

use CException;
use Ray\Di\Grapher;
use Koriym\Dii\Module\AppModule;
use Ray\Di\Grapher;
use YiiBase;

/**
Expand All @@ -27,7 +27,7 @@ public static function createComponent($config)
unset($args[0]);

$isInjectable = in_array(Injectable::class, class_implements($type), true);
$object = $isInjectable ? Dii::getGrapher()->newInstanceArgs($type, $args) : (new \ReflectionClass($type))->newInstanceArgs($args);
$object = $isInjectable ? self::getGrapher()->newInstanceArgs($type, $args) : (new \ReflectionClass($type))->newInstanceArgs($args);

foreach ($config as $key => $value) {
$object->$key = $value;
Expand Down
2 changes: 2 additions & 0 deletions src/DiiWebApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function createController($route, $owner = null)
$namespacedClassName = 'application\\' . $controllerName;
if (class_exists($namespacedClassName, false) && is_subclass_of($namespacedClassName, \CController::class)) {
$id[0] = strtolower($id[0]);

return [
$this->newInstance($namespacedClassName, $controllerID . $id, $owner === $this ? null : $owner),
$this->parseActionParams($route),
Expand All @@ -74,6 +75,7 @@ public function createController($route, $owner = null)

if (class_exists($controllerName, false) && is_subclass_of($controllerName, \CController::class)) {
$id[0] = strtolower($id[0]);

return [
$this->newInstance($controllerName, $controllerID . $id, $owner === $this ? null : $owner),
$this->parseActionParams($route),
Expand Down