Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions classes/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function primarykey()
return 'ID';
}

public static function findByPk($pk): static
public static function findByPk($pk): ?static
{
$class = get_called_class();
return $class::findByResult(
Expand All @@ -42,7 +42,7 @@ public static function findByPk($pk): static
);
}

public static function findByAttributes($attributes): static
public static function findByAttributes($attributes): ?static
{
$class = get_called_class();
return $class::findByResult(
Expand Down Expand Up @@ -145,16 +145,16 @@ public static function queryOptions($options, $builder)
}

/**
* @return \Nin\Model
* @return ?\Nin\Model
*/
public static function findByResult($res)
{
if($res === false) {
return false;
return null;
}
$row = $res->fetch_assoc();
if(!$row) {
return false;
return null;
Comment on lines +153 to +157
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning null instead of false is a really big breaking change! I'd prefer if we can still keep returning false here, to make sure existing checks don't break (for example, === false and !== false)

}
$class = get_called_class();
$ret = new $class();
Expand Down