Skip to content
Permalink
Browse files

Coding style: TRUE/FALSE/NULL -> true/false/null

  • Loading branch information...
janpecha committed Apr 7, 2019
1 parent 86ba57f commit 6bcd65add0fcf51b6c6189bd3ff781e5121b9ecb
@@ -112,7 +112,7 @@ public static function createFromAnnotation($annotationType, $annotation, Entity
foreach ($flagMatches as $match) {
if ($match[1] === 'belongsToOne' || $match[1] === 'belongsToMany') {
$isWritable = FALSE;
$isWritable = false;
break;
}
}
@@ -24,14 +24,14 @@ class PropertyMethods
/** @var string */
private $getter;
/** @var string|NULL */
/** @var string|null */
private $setter;
/**
* @param string
* @param string|NULL
* @param string|null
*/
public function __construct($getter, $setter)
{
@@ -76,7 +76,7 @@ public static function createFromDefinition($propertyName, $isWritable, $definit
{
$ucName = ucfirst($propertyName);
$getter = 'get' . $ucName;
$setter = NULL;
$setter = null;
if ($isWritable) {
$setter = 'set' . $ucName;
}
@@ -49,7 +49,7 @@ $mapper = $container->getService('LeanMapper.mapper');
/// debug mode + FileLogger
$configurator = new Configurator;
$configurator->setTempDirectory(TEMP_DIR);
$configurator->setDebugMode(TRUE);
$configurator->setDebugMode(true);
$configurator->addParameters([
'container' => ['class' => 'SystemContainer_' . Random::generate()],
]);
@@ -31,14 +31,14 @@ $author = new Author;
$author->state = Author::STATE_ACTIVE;
Assert::equal(Author::STATE_ACTIVE, $author->state);
$author->state = NULL;
Assert::equal(NULL, $author->state);
$author->state = null;
Assert::equal(null, $author->state);
$author->finalState = Author::STATE_DELETED;
Assert::equal(Author::STATE_DELETED, $author->finalState);
Assert::exception(function () use ($author) {
$author->finalState = NULL;
$author->finalState = null;
}, 'LeanMapper\Exception\InvalidValueException', "Property 'finalState' in entity Author cannot be null.");
@@ -15,7 +15,7 @@ class Book extends LeanMapper\Entity
{
protected function decodeRowValue($value, Property $property)
{
if (is_a($property->getType(), 'DateTime', TRUE)) {
if (is_a($property->getType(), 'DateTime', true)) {
if ($value instanceof DateTime) {
return clone $value;
}
@@ -28,7 +28,7 @@ class Book extends LeanMapper\Entity
protected function encodeRowValue($value, Property $property)
{
if (is_a($property->getType(), 'DateTime', TRUE)) {
if (is_a($property->getType(), 'DateTime', true)) {
if ($value instanceof DateTime) {
return $value->format('Y-m-d');
}
@@ -36,7 +36,7 @@ class Book extends LeanMapper\Entity
protected function convertJson($value)
{
if (is_string($value)) {
return (array) json_decode($value, TRUE);
return (array) json_decode($value, true);
}
return json_encode((array) $value);
@@ -25,22 +25,22 @@ class Book extends LeanMapper\Entity
return $this->convertJson($value);
}
if (is_a($type, 'DateTime', TRUE)) {
if (is_a($type, 'DateTime', true)) {
if ($value instanceof DateTime) {
return clone $value;
}
return new DateTime($value);
}
if (is_a($type, 'Uuid', TRUE)) {
if (is_a($type, 'Uuid', true)) {
return ($value instanceof Uuid) ? $value : new Uuid($value);
}
if (is_a($type, 'Time', TRUE)) {
if (is_a($type, 'Time', true)) {
return ($value instanceof Time) ? $value->getTime() : new Time($value);
}
if (!$property->isBasicType() && is_a($type, 'Integer', TRUE)) { // is_a() accepts 'integer' as class name
if (!$property->isBasicType() && is_a($type, 'Integer', true)) { // is_a() accepts 'integer' as class name
return $this->convertToInteger($value);
}
@@ -56,22 +56,22 @@ class Book extends LeanMapper\Entity
return $this->convertJson($value);
}
if (is_a($type, 'DateTime', TRUE)) {
if (is_a($type, 'DateTime', true)) {
if ($value instanceof DateTime) {
return $value->format('Y-m-d');
}
return $value;
}
if (is_a($type, 'Uuid', TRUE)) {
if (is_a($type, 'Uuid', true)) {
return ($value instanceof Uuid) ? $value : new Uuid($value);
}
if (is_a($type, 'Time', TRUE)) {
if (is_a($type, 'Time', true)) {
return ($value instanceof Time) ? $value->getTime() : new Time($value);
}
if (!$property->isBasicType() && is_a($type, 'Integer', TRUE)) { // is_a() accepts 'integer' as class name
if (!$property->isBasicType() && is_a($type, 'Integer', true)) { // is_a() accepts 'integer' as class name
return $this->convertToInteger($value);
}
@@ -15,13 +15,13 @@ class Foo extends LeanMapper\Entity
{
protected function jsonEncodeData($data)
{
return !empty($data) ? json_encode($data) : NULL;
return !empty($data) ? json_encode($data) : null;
}
protected function jsonDecodeData($data)
{
return !empty($data) ? json_decode($data, TRUE) : [];
return !empty($data) ? json_decode($data, true) : [];
}
}
@@ -13,7 +13,7 @@ require_once __DIR__ . '/../bootstrap.php';
class CustomReflectionProvider extends LeanMapper\DefaultEntityReflectionProvider
{
/** @var PropertyFilters|NULL */
/** @var PropertyFilters|null */
public static $customFilters;
@@ -50,7 +50,7 @@ class CustomReflectionProvider extends LeanMapper\DefaultEntityReflectionProvide
$customFlags
)
{
if ($propertyFilters !== NULL) {
if ($propertyFilters !== null) {
$propertyFilters = self::$customFilters;
}
return new Property(
@@ -93,22 +93,22 @@ $oldAuthor = $book->author;
$book->name = $oldName;
$book->author = $oldAuthor;
Assert::same(FALSE, $book->isModified());
Assert::same(false, $book->isModified());
//////////
$book->name = 'new book name';
$book->author = $authorRepository->find(1);
Assert::same(TRUE, $book->isModified());
Assert::same(true, $book->isModified());
//////////
$newBook = new Book;
Assert::same(FALSE, $newBook->isModified());
Assert::same(false, $newBook->isModified());
$newBook->name = 'new book name #2';
$newBook->author = $authorRepository->find(1);
Assert::same(TRUE, $newBook->isModified());
Assert::same(true, $newBook->isModified());

0 comments on commit 6bcd65a

Please sign in to comment.
You can’t perform that action at this time.