These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * This file is part of PHP Mess Detector. |
||
4 | * |
||
5 | * Copyright (c) Manuel Pichler <[email protected]>. |
||
6 | * All rights reserved. |
||
7 | * |
||
8 | * Licensed under BSD License |
||
9 | * For full copyright and license information, please see the LICENSE file. |
||
10 | * Redistributions of files must retain the above copyright notice. |
||
11 | * |
||
12 | * @author Manuel Pichler <[email protected]> |
||
13 | * @copyright Manuel Pichler. All rights reserved. |
||
14 | * @license https://opensource.org/licenses/bsd-license.php BSD License |
||
15 | * @link http://phpmd.org/ |
||
16 | */ |
||
17 | |||
18 | namespace PHPMD\Rule\CleanCode; |
||
19 | |||
20 | use PHPMD\AbstractTest; |
||
21 | |||
22 | /** |
||
23 | * Error Control Operator Test |
||
24 | * |
||
25 | * @coversDefaultClass \PHPMD\Rule\CleanCode\ErrorControlOperator |
||
26 | */ |
||
27 | View Code Duplication | class ErrorControlOperatorTest extends AbstractTest |
|
28 | { |
||
29 | /** |
||
30 | * Tests that the rule does not apply to unary operators in functions |
||
31 | * |
||
32 | * @return void |
||
33 | * @covers ::apply |
||
34 | */ |
||
35 | public function testDoesNotApplyToOtherUnaryOperatorsInFunction() |
||
36 | { |
||
37 | $rule = new ErrorControlOperator(); |
||
38 | $rule->setReport($this->getReportWithOneViolation()); |
||
39 | $rule->apply($this->getFunction()); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Tests that the rule applies error control operators to functions |
||
44 | * |
||
45 | * @return void |
||
46 | * @covers ::apply |
||
47 | */ |
||
48 | public function testAppliesToErrorControlOperatorInFunction() |
||
49 | { |
||
50 | $rule = new ErrorControlOperator(); |
||
51 | $rule->setReport($this->getReportMock(3)); |
||
0 ignored issues
–
show
|
|||
52 | $rule->apply($this->getFunction()); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Tests that the rule applies error control operators to classes and methods |
||
57 | * |
||
58 | * @return void |
||
59 | * @covers ::apply |
||
60 | */ |
||
61 | public function testAppliedToClassesAndMethods() |
||
62 | { |
||
63 | $rule = new ErrorControlOperator(); |
||
64 | $rule->setReport($this->getReportMock(6)); |
||
0 ignored issues
–
show
It seems like
$this->getReportMock(6) targeting PHPMD\AbstractTest::getReportMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject> ; however, PHPMD\AbstractRule::setReport() does only seem to accept object<PHPMD\Report> , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
65 | $rule->apply($this->getClass()); |
||
66 | } |
||
67 | } |
||
68 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.