PHPStan tweaks

This commit is contained in:
Alex Cabal 2022-07-04 12:58:18 -05:00
parent 497f749523
commit de9e8161ce
6 changed files with 22 additions and 3 deletions

View file

@ -87,6 +87,10 @@ class Poll extends PropertiesBase{
// *********** // ***********
public static function Get(?int $pollId): Poll{ public static function Get(?int $pollId): Poll{
if($pollId === null){
throw new Exceptions\InvalidPollException();
}
$result = Db::Query('SELECT * from Polls where PollId = ?', [$pollId], 'Poll'); $result = Db::Query('SELECT * from Polls where PollId = ?', [$pollId], 'Poll');
if(sizeof($result) == 0){ if(sizeof($result) == 0){
@ -97,6 +101,10 @@ class Poll extends PropertiesBase{
} }
public static function GetByUrlName(?string $urlName): Poll{ public static function GetByUrlName(?string $urlName): Poll{
if($urlName === null){
throw new Exceptions\InvalidPollException();
}
$result = Db::Query('SELECT * from Polls where UrlName = ?', [$urlName], 'Poll'); $result = Db::Query('SELECT * from Polls where UrlName = ?', [$urlName], 'Poll');
if(sizeof($result) == 0){ if(sizeof($result) == 0){

View file

@ -31,6 +31,10 @@ class PollItem extends PropertiesBase{
// *********** // ***********
public static function Get(?int $pollItemId): PollItem{ public static function Get(?int $pollItemId): PollItem{
if($pollItemId === null ){
throw new Exceptions\InvalidPollItemException();
}
$result = Db::Query('SELECT * from PollItems where PollItemId = ?', [$pollItemId], 'PollItem'); $result = Db::Query('SELECT * from PollItems where PollItemId = ?', [$pollItemId], 'PollItem');
if(sizeof($result) == 0){ if(sizeof($result) == 0){

View file

@ -51,6 +51,10 @@ class User extends PropertiesBase{
} }
public static function GetByEmail(?string $email): User{ public static function GetByEmail(?string $email): User{
if($email === null){
throw new Exceptions\InvalidUserException();
}
$result = Db::Query('SELECT * from Users where Email = ?', [$email], 'User'); $result = Db::Query('SELECT * from Users where Email = ?', [$email], 'User');
if(sizeof($result) == 0){ if(sizeof($result) == 0){

View file

@ -100,10 +100,9 @@ class Vote extends PropertiesBase{
$this->VoteId = Db::GetLastInsertedId(); $this->VoteId = Db::GetLastInsertedId();
} }
public static function Get(?string $pollUrlName, ?int $userId): ?Vote{ public static function Get(?string $pollUrlName, ?int $userId): Vote{
if($pollUrlName === null || $userId === null){ if($pollUrlName === null || $userId === null){
vdd('nn'); throw new Exceptions\InvalidVoteException();
return null;
} }
$result = Db::Query('SELECT v.* from Votes v inner join $result = Db::Query('SELECT v.* from Votes v inner join

View file

@ -1,6 +1,8 @@
<? <?
require_once('Core.php'); require_once('Core.php');
use function \Safe\session_unset;
session_start(); session_start();
$subscription = new NewsletterSubscription(); $subscription = new NewsletterSubscription();

View file

@ -1,6 +1,8 @@
<? <?
require_once('Core.php'); require_once('Core.php');
use function Safe\session_unset;
session_start(); session_start();
$vote = new Vote(); $vote = new Vote();