Completed
Pull Request — 5.1 (#1327)
by
unknown
05:23
created

InstanceTestFather   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _protectedStaticFunc() 0 3 1
A __construct() 0 3 1
1
<?php
2
namespace tests\thinkphp\library\traits\think;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use traits\think\Instance;
0 ignored issues
show
Bug introduced by
The type traits\think\Instance was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
6
class instanceTest extends \PHPUnit_Framework_TestCase
1 ignored issue
show
Bug introduced by
The type PHPUnit_Framework_TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Coding Style introduced by
Missing class doc comment
Loading history...
Coding Style introduced by
Class name must begin with a capital letter
Loading history...
7
{
8
    public function testInstance()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
9
    {
10
        $father = InstanceTestFather::instance();
11
        $this->assertInstanceOf('\tests\thinkphp\library\traits\think\InstanceTestFather', $father);
12
        $this->assertEquals([], $father->options);
13
14
        $son = InstanceTestFather::instance(['son']);
15
        $this->assertSame($father, $son);
16
    }
17
18
    public function testCallStatic()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
19
    {
20
        $father = InstanceTestFather::instance();
21
        $this->assertEquals([], $father->options);
22
23
        $this->assertEquals($father::__protectedStaticFunc(['thinkphp']), 'protectedStaticFunc["thinkphp"]');
24
25
        try {
26
            $father::_protectedStaticFunc();
27
            $this->setExpectedException('\think\Exception');
28
        } catch (\Exception $e) {
29
            $this->assertInstanceOf('\think\Exception', $e);
30
        }
31
    }
32
33
    protected function tearDown()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
34
    {
35
        call_user_func(\Closure::bind(function () {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
36
            InstanceTestFather::$instance = null;
37
        }, null, '\tests\thinkphp\library\traits\think\InstanceTestFather'));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
38
    }
39
}
40
41
class InstanceTestFather
1 ignored issue
show
Coding Style introduced by
Missing class doc comment
Loading history...
42
{
43
    use Instance;
44
45
    public $options = null;
46
47
    public function __construct($options)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
48
    {
49
        $this->options = $options;
50
    }
51
52
    protected static function _protectedStaticFunc($params)
1 ignored issue
show
Coding Style introduced by
Missing function doc comment
Loading history...
Coding Style introduced by
Protected method name "InstanceTestFather::_protectedStaticFunc" must not be prefixed with an underscore
Loading history...
53
    {
54
        return 'protectedStaticFunc' . json_encode($params);
55
    }
56
}
57
58
class InstanceTestSon extends InstanceTestFather
1 ignored issue
show
Coding Style introduced by
Missing class doc comment
Loading history...
59
{
60
}
61