mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-11 14:38:39 +00:00
Remove is_null
This commit is contained in:
parent
5b243ab2da
commit
3c3c7fe251
|
|
@ -844,10 +844,10 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function parseValue(string $type, $value)
|
private static function parseValue(string $type, $value = null)
|
||||||
{
|
{
|
||||||
// todo: checking for string === string and is_* is slow. maybe only check type or only string
|
// todo: checking for string === string and is_* is slow. maybe only check type or only string
|
||||||
if (is_null($value)) {
|
if ($value === null) {
|
||||||
return null;
|
return null;
|
||||||
} elseif ($type === 'DateTime' || $value instanceof \DateTime) {
|
} elseif ($type === 'DateTime' || $value instanceof \DateTime) {
|
||||||
return $value->format('Y-m-d H:i:s');
|
return $value->format('Y-m-d H:i:s');
|
||||||
|
|
@ -2503,9 +2503,9 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*/
|
*/
|
||||||
public static function getByRequest(RequestAbstract $request)
|
public static function getByRequest(RequestAbstract $request)
|
||||||
{
|
{
|
||||||
if (!is_null($request->getData('id'))) {
|
if ($request->getData('id') !== null) {
|
||||||
$result = static::get((int) $request->getData('id'));
|
$result = static::get((int) $request->getData('id'));
|
||||||
} elseif (!is_null($filter = ((string) $request->getData('filter')))) {
|
} elseif (($filter = ((string) $request->getData('filter'))) !== null) {
|
||||||
$filter = strtolower($filter);
|
$filter = strtolower($filter);
|
||||||
|
|
||||||
if ($filter === 'all') {
|
if ($filter === 'all') {
|
||||||
|
|
@ -2515,8 +2515,8 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
$result = static::get(json_decode($list, true));
|
$result = static::get(json_decode($list, true));
|
||||||
} else {
|
} else {
|
||||||
$limit = (int) ($request->getData('limit') ?? 1);
|
$limit = (int) ($request->getData('limit') ?? 1);
|
||||||
$from = !is_null($request->getData('from')) ? new \DateTime((string) $request->getData('from')) : null;
|
$from = $request->getData('from') === null ? null : new \DateTime((string) $request->getData('from'));
|
||||||
$to = !is_null($request->getData('to')) ? new \DateTime((string) $request->getData('to')) : null;
|
$to = $request->getData('to') === null ? null : new \DateTime((string) $request->getData('to'));
|
||||||
|
|
||||||
$query = static::getQuery();
|
$query = static::getQuery();
|
||||||
$query->limit($limit);
|
$query->limit($limit);
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ class Grammar extends GrammarAbstract
|
||||||
return '(' . rtrim($values, ', ') . ')';
|
return '(' . rtrim($values, ', ') . ')';
|
||||||
} elseif ($value instanceof \DateTime) {
|
} elseif ($value instanceof \DateTime) {
|
||||||
return $query->quote($value->format('Y-m-d H:i:s'));
|
return $query->quote($value->format('Y-m-d H:i:s'));
|
||||||
} elseif (is_null($value)) {
|
} elseif ($value === null) {
|
||||||
return 'NULL';
|
return 'NULL';
|
||||||
} elseif (is_bool($value)) {
|
} elseif (is_bool($value)) {
|
||||||
return (string) ((int) $value);
|
return (string) ((int) $value);
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
*/
|
*/
|
||||||
public function offsetSet($offset, $value)
|
public function offsetSet($offset, $value)
|
||||||
{
|
{
|
||||||
if (is_null($offset)) {
|
if (!isset($offset)) {
|
||||||
$this->addNode($value);
|
$this->addNode($value);
|
||||||
} else {
|
} else {
|
||||||
$this->nodes[$offset] = $value;
|
$this->nodes[$offset] = $value;
|
||||||
|
|
|
||||||
|
|
@ -470,7 +470,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
*/
|
*/
|
||||||
public function offsetSet($offset, $value)
|
public function offsetSet($offset, $value)
|
||||||
{
|
{
|
||||||
if (is_null($offset)) {
|
if (!isset($offset)) {
|
||||||
$this->addNode($value);
|
$this->addNode($value);
|
||||||
} else {
|
} else {
|
||||||
$this->nodes[$offset] = $value;
|
$this->nodes[$offset] = $value;
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class ArrayParser
|
||||||
return '"' . $value . '"';
|
return '"' . $value . '"';
|
||||||
} elseif (is_scalar($value)) {
|
} elseif (is_scalar($value)) {
|
||||||
return (string) $value;
|
return (string) $value;
|
||||||
} elseif (is_null($value)) {
|
} elseif (!isset($value)) {
|
||||||
return 'null';
|
return 'null';
|
||||||
} elseif (is_bool($value)) {
|
} elseif (is_bool($value)) {
|
||||||
return $value ? 'true' : 'false';
|
return $value ? 'true' : 'false';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user