core icon indicating copy to clipboard operation
core copied to clipboard

Diverse fehlende Null-Checks in verschiedenen Repositories

Open usox opened this issue 3 years ago • 2 comments

 ------ ------------------------------------------------------------------------------- 
  Line   ColonyRepository.php                                                           
 ------ ------------------------------------------------------------------------------- 
  112    Cannot call method getSystem() on Stu\Orm\Entity\StarSystemMapInterface|null.  
  113    Cannot call method getSx() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  114    Cannot call method getSy() on Stu\Orm\Entity\StarSystemMapInterface|null.      
 ------ ------------------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   ColonyShipRepairRepository.php                                                                                                                                              
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  33     Method Stu\Orm\Repository\ColonyShipRepairRepository::getByShip() should return Stu\Orm\Entity\ColonyShipRepairInterface but returns Stu\Orm\Entity\ColonyShipRepair|null.  
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   DatabaseEntryRepository.php                                                                                                                                                         
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  25     Method Stu\Orm\Repository\DatabaseEntryRepository::getByCategoryIdAndObjectId() should return Stu\Orm\Entity\DatabaseEntryInterface but returns Stu\Orm\Entity\DatabaseEntry|null.  
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   GameTurnRepository.php                                                                                                                               
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------- 
  18     Method Stu\Orm\Repository\GameTurnRepository::getCurrent() should return Stu\Orm\Entity\GameTurnInterface but returns Stu\Orm\Entity\GameTurn|null.  
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   RepairTaskRepository.php                                                                                                                            
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------- 
  39     Method Stu\Orm\Repository\RepairTaskRepository::getByShip() should return Stu\Orm\Entity\ShipInterface but returns Stu\Orm\Entity\RepairTask|null.  
 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------- 
  Line   ShipRepository.php                                                             
 ------ ------------------------------------------------------------------------------- 
  134    Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.                
  134    Cannot call method getId() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  177    Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.                
  249    Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.                
  249    Cannot call method getId() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  548    Cannot call method getSystem() on Stu\Orm\Entity\StarSystemMapInterface|null.  
  549    Cannot call method getSx() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  550    Cannot call method getSx() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  551    Cannot call method getSy() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  552    Cannot call method getSy() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  846    Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.                
  846    Cannot call method getId() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  923    Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.                
  923    Cannot call method getId() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  937    Cannot call method getId() on Stu\Orm\Entity\StarSystemMapInterface|null.      
  938    Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.                
  1014   Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.                
  1014   Cannot call method getId() on Stu\Orm\Entity\StarSystemMapInterface|null.      
 ------ ------------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------- 
  Line   TachyonScanRepository.php                                                  
 ------ --------------------------------------------------------------------------- 
  51     Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.            
  51     Cannot call method getId() on Stu\Orm\Entity\StarSystemMapInterface|null.  
 ------ --------------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------- 
  Line   TholianWebRepository.php                                         
 ------ ----------------------------------------------------------------- 
  53     Cannot call method getId() on Stu\Orm\Entity\MapInterface|null.  
 ------ ----------------------------------------------------------------- 

usox avatar Jan 22 '23 13:01 usox

in den meisten Fällen sind NPEs nicht möglich. Denn wenn das Schiff in einem System ist, dann ist zwangsläufig auch immer der FK für die SystemMap gefüllt. Und wenn nicht, dann der FK für die Map Entity. ist ein XOR, aber erkennt die automatische Analyse an der Stelle wohl nicht.

g5bot avatar Jan 22 '23 19:01 g5bot

Für die Typsicherheit ist es leider unerheblich, weshalb es so ist. Fakt ist, es könnte hier ein Problem entstehen - also muss die Programmlogik damit umgehen können.

usox avatar Jan 22 '23 19:01 usox