Skip to content

Commit

Permalink
Make syntax compatible with older PHP-versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Sep 17, 2022
1 parent f15116f commit ee59fd1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion RedBeanPHP/Util/Either.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function index( $key = 0 ) {
*
* @return mixed
*/
public function or( $value ) {
public function _or( $value ) {
$reference = (is_null($this->result)) ? $value : $this->result;
return $reference;
}
Expand Down
16 changes: 8 additions & 8 deletions testing/RedUNIT/Base/Either.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ public function testEitherWithBeans()
)
)));
$book = R::load('book', $id);
asrt($book->either()->title->or('nothing'),'Socratic Questions');
asrt($book->either()->title->_or('nothing'),'Socratic Questions');
$pageId = R::findOne('page')->id;
asrt($book->either()->ownPageList->index($pageId)->id->or(0), $pageId);
asrt($book->either()->ownPageList->index($pageId+1)->ownTextList->index(1)->or(0), 0);
$textId = $book->either()->ownPageList->first()->ownParagraphList->last()->id->or(0);
asrt($book->either()->ownPageList->index($pageId)->id->_or(0), $pageId);
asrt($book->either()->ownPageList->index($pageId+1)->ownTextList->index(1)->_or(0), 0);
$textId = $book->either()->ownPageList->first()->ownParagraphList->last()->id->_or(0);
asrt($textId > 0, TRUE);
$text = R::load('paragraph', $textId);
asrt($text->either()->page->book->title->or('nothing'), 'Socratic Questions');
asrt($book->either()->ownPageList->last()->id->or(-1),$pageId);
asrt($book->either()->ownPageList->id->or(-1),-1);
asrt($book->either()->ownPageList->first()->ownQuoteList->first()->or('?'),'?');
asrt($text->either()->page->book->title->_or('nothing'), 'Socratic Questions');
asrt($book->either()->ownPageList->last()->id->_or(-1),$pageId);
asrt($book->either()->ownPageList->id->_or(-1),-1);
asrt($book->either()->ownPageList->first()->ownQuoteList->first()->_or('?'),'?');
}
}

0 comments on commit ee59fd1

Please sign in to comment.