Created
March 8, 2016 21:29
-
-
Save BlackScorp/a67b278c365a18d24435 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface BarRepository{ | |
public function findByFoo($foo) : BarEntity[] | |
} | |
class BarRepositoryImplementation implements BarRepository{ | |
public function findByFoo($foo): BarEntity[] | |
{ | |
//Some SQL or other things | |
if($noResults){ //case 1 | |
throw new NotFoundException(); | |
} | |
$collection = [new NullBarEntity()]; | |
if($noResults){ //case 2 | |
return $collection; | |
} | |
if($noResults){ | |
return []; //fatal error, wrong return value | |
} | |
if($noResults){ | |
return null; //fatal error, wrong return value | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment