for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
/**
* This file is part of the daikon-cqrs/value-object project.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Daikon\ValueObject;
use Assert\Assertion;
final class NullValue implements ValueObjectInterface
{
/** @param null|string $value */
public static function fromNative($value): self
Assertion::nullOrRegex($value, '#^$#', 'Trying to create NullValue VO from unsupported value.');
return new self;
}
public static function makeEmpty(): self
/** @return null */
public function toNative()
return null;
/** @param self $comparator */
public function equals($comparator): bool
Assertion::isInstanceOf($comparator, self::class);
return $this->toNative() === $comparator->toNative();
$this->toNative()
Daikon\ValueObject\NullValue::toNative()
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 getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
$comparator->toNative()
public function __toString(): string
return '';
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.