1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2018 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link http://mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\LeadBundle\Tests\Validator\Constraints; |
||
13 | |||
14 | use Mautic\LeadBundle\Validator\Constraints\Length; |
||
15 | use Mautic\LeadBundle\Validator\Constraints\LengthValidator; |
||
16 | |||
17 | class LengthValidatorTest extends \PHPUnit\Framework\TestCase |
||
18 | { |
||
19 | public function testValidate() |
||
20 | { |
||
21 | $constraint = new Length(['min' => 3]); |
||
22 | $validator = new LengthValidator(); |
||
23 | $this->assertNull($validator->validate('valid', $constraint)); |
||
0 ignored issues
–
show
|
|||
24 | // Not thrownig Symfony\Component\Validator\Exception\UnexpectedTypeException |
||
25 | $this->assertNull($validator->validate(['0', '1'], $constraint)); |
||
0 ignored issues
–
show
Are you sure the usage of
$validator->validate(arr...'0', '1'), $constraint) targeting Mautic\LeadBundle\Valida...thValidator::validate() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
26 | } |
||
27 | } |
||
28 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.