Completed
Push — master ( 84cc78...40cd21 )
by Jeroen De
01:50
created

tests/phpunit/Definitions/NumericParamTest.php (4 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace ParamProcessor\Tests\Definitions;
4
5
use ParamProcessor\Options;
6
7
/**
8
 * @licence GNU GPL v2+
9
 * @author Jeroen De Dauw < [email protected] >
10
 */
11
abstract class NumericParamTest extends ParamDefinitionTest {
12
13
	public function lowerBoundProvider() {
14
		return [
15
			[ 42, 42, true ],
16
			[ 42, 41, false ],
17
			[ 42, 43, true ],
18
			[ false, 43, true ],
19
			[ false, 0, true ],
20
			[ false, -100, true ],
21
			[ -100, -100, true ],
22
			[ -99, -100, false ],
23
			[ -101, -100, true ],
24
		];
25
	}
26
27
	/**
28
	 * @dataProvider lowerBoundProvider
29
	 */
30
	public function testSetLowerBound( $bound, $testValue, $validity ) {
31
		$definition = $this->getEmptyInstance();
32
		$definition->setArrayValues( [ 'lowerbound' => $bound ] );
33
34
		$this->validate( $definition, (string)$testValue, $validity );
0 ignored issues
show
$definition is of type false|object<ParamProcessor\IParamDefinition>, but the function expects a object<ParamProcessor\ParamDefinition>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
36
		$options = new Options();
37
		$options->setRawStringInputs( false );
38
		$this->validate( $definition, $testValue, $validity, $options );
0 ignored issues
show
$definition is of type false|object<ParamProcessor\IParamDefinition>, but the function expects a object<ParamProcessor\ParamDefinition>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
	}
40
41
	public function upperBoundProvider() {
42
		return [
43
			[ 42, 42, true ],
44
			[ 42, 41, true ],
45
			[ 42, 43, false ],
46
			[ false, 43, true ],
47
			[ false, 0, true ],
48
			[ false, -100, true ],
49
			[ -100, -100, true ],
50
			[ -99, -100, true ],
51
			[ -101, -100, false ],
52
		];
53
	}
54
55
	/**
56
	 * @dataProvider upperBoundProvider
57
	 */
58
	public function testSetUpperBound( $bound, $testValue, $validity ) {
59
		$definition = $this->getEmptyInstance();
60
		$definition->setArrayValues( [ 'upperbound' => $bound ] );
61
62
		$this->validate( $definition, (string)$testValue, $validity );
0 ignored issues
show
$definition is of type false|object<ParamProcessor\IParamDefinition>, but the function expects a object<ParamProcessor\ParamDefinition>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
63
64
		$options = new Options();
65
		$options->setRawStringInputs( false );
66
		$this->validate( $definition, $testValue, $validity, $options );
0 ignored issues
show
$definition is of type false|object<ParamProcessor\IParamDefinition>, but the function expects a object<ParamProcessor\ParamDefinition>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
67
	}
68
69
}
70