mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Enable some additional PHPStan rules and fix some type issues
This commit is contained in:
parent
c9e5026cf4
commit
a019d5e87c
8 changed files with 21 additions and 18 deletions
|
@ -5,6 +5,9 @@ includes:
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
level: 9
|
level: 9
|
||||||
|
checkFunctionNameCase: true
|
||||||
|
checkInternalClassCaseSensitivity: true
|
||||||
|
checkTooWideReturnTypesInProtectedAndPublicMethods: true
|
||||||
|
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
# Ignore errors caused by `Template` static class reflection.
|
# Ignore errors caused by `Template` static class reflection.
|
||||||
|
|
|
@ -53,7 +53,7 @@ class AtomFeed extends Feed{
|
||||||
|
|
||||||
$currentEntries = [];
|
$currentEntries = [];
|
||||||
foreach($this->Entries as $entry){
|
foreach($this->Entries as $entry){
|
||||||
$obj = new StdClass();
|
$obj = new stdClass();
|
||||||
if($entry instanceof Ebook){
|
if($entry instanceof Ebook){
|
||||||
if($entry->EbookUpdated !== null){
|
if($entry->EbookUpdated !== null){
|
||||||
$obj->Updated = $entry->EbookUpdated->format(Enums\DateTimeFormat::Iso->value);
|
$obj->Updated = $entry->EbookUpdated->format(Enums\DateTimeFormat::Iso->value);
|
||||||
|
@ -75,7 +75,7 @@ class AtomFeed extends Feed{
|
||||||
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', file_get_contents($path)));
|
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', file_get_contents($path)));
|
||||||
|
|
||||||
foreach($xml->xpath('/feed/entry') ?: [] as $entry){
|
foreach($xml->xpath('/feed/entry') ?: [] as $entry){
|
||||||
$obj = new StdClass();
|
$obj = new stdClass();
|
||||||
$obj->Updated = $entry->updated;
|
$obj->Updated = $entry->updated;
|
||||||
$obj->Id = $entry->id;
|
$obj->Id = $entry->id;
|
||||||
$oldEntries[] = $obj;
|
$oldEntries[] = $obj;
|
||||||
|
|
|
@ -315,7 +315,7 @@ class Db{
|
||||||
* @param string $sql The SQL query to execute.
|
* @param string $sql The SQL query to execute.
|
||||||
* @param array<mixed> $params An array of parameters to bind to the SQL statement.
|
* @param array<mixed> $params An array of parameters to bind to the SQL statement.
|
||||||
*
|
*
|
||||||
* @return \PdoStatement The `\PDOStatement` to be used to execute the query.
|
* @return \PDOStatement The `\PDOStatement` to be used to execute the query.
|
||||||
*
|
*
|
||||||
* @throws Exceptions\DatabaseQueryException When an error occurs during execution of the query.
|
* @throws Exceptions\DatabaseQueryException When an error occurs during execution of the query.
|
||||||
*/
|
*/
|
||||||
|
@ -360,7 +360,7 @@ class Db{
|
||||||
*
|
*
|
||||||
* @template T
|
* @template T
|
||||||
*
|
*
|
||||||
* @param \PdoStatement $handle The PDO handle to execute.
|
* @param \PDOStatement $handle The PDO handle to execute.
|
||||||
* @param class-string<T> $class The type of object to return in the return array.
|
* @param class-string<T> $class The type of object to return in the return array.
|
||||||
*
|
*
|
||||||
* @return array<T> An array of objects of type `$class`, or `stdClass` if `$class` is `null`.
|
* @return array<T> An array of objects of type `$class`, or `stdClass` if `$class` is `null`.
|
||||||
|
@ -440,7 +440,7 @@ class Db{
|
||||||
*
|
*
|
||||||
* @template T
|
* @template T
|
||||||
*
|
*
|
||||||
* @param \PdoStatement $handle The PDO handle to execute.
|
* @param \PDOStatement $handle The PDO handle to execute.
|
||||||
* @param class-string<T> $class The class to instantiate for each row, or `stdClass` to return an array of rows.
|
* @param class-string<T> $class The class to instantiate for each row, or `stdClass` to return an array of rows.
|
||||||
*
|
*
|
||||||
* @return array<T>|array<array<string, stdClass>> An array of `$class` if `$class` is not `stdClass`, otherwise an array of rows of the form `["LeftTableName" => $stdClass, "RightTableName" => $stdClass]`.
|
* @return array<T>|array<array<string, stdClass>> An array of `$class` if `$class` is not `stdClass`, otherwise an array of rows of the form `["LeftTableName" => $stdClass, "RightTableName" => $stdClass]`.
|
||||||
|
|
|
@ -40,25 +40,25 @@ class Email{
|
||||||
$phpMailer = new PHPMailer(true);
|
$phpMailer = new PHPMailer(true);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$phpMailer->SetFrom($this->From, $this->FromName);
|
$phpMailer->setFrom($this->From, $this->FromName);
|
||||||
$phpMailer->AddReplyTo($this->ReplyTo);
|
$phpMailer->addReplyTo($this->ReplyTo);
|
||||||
$phpMailer->AddAddress($this->To, $this->ToName);
|
$phpMailer->addAddress($this->To, $this->ToName);
|
||||||
$phpMailer->Subject = $this->Subject;
|
$phpMailer->Subject = $this->Subject;
|
||||||
$phpMailer->CharSet = 'UTF-8';
|
$phpMailer->CharSet = 'UTF-8';
|
||||||
if($this->TextBody != ''){
|
if($this->TextBody != ''){
|
||||||
$phpMailer->IsHTML(true);
|
$phpMailer->isHTML(true);
|
||||||
$phpMailer->Body = $this->Body;
|
$phpMailer->Body = $this->Body;
|
||||||
$phpMailer->AltBody = $this->TextBody;
|
$phpMailer->AltBody = $this->TextBody;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$phpMailer->MsgHTML($this->Body);
|
$phpMailer->msgHTML($this->Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->Attachments as $attachment){
|
foreach($this->Attachments as $attachment){
|
||||||
$phpMailer->addStringAttachment($attachment['contents'], $attachment['filename']);
|
$phpMailer->addStringAttachment($attachment['contents'], $attachment['filename']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$phpMailer->IsSMTP();
|
$phpMailer->isSMTP();
|
||||||
$phpMailer->SMTPAuth = true;
|
$phpMailer->SMTPAuth = true;
|
||||||
$phpMailer->SMTPSecure = 'tls';
|
$phpMailer->SMTPSecure = 'tls';
|
||||||
$phpMailer->Port = 587;
|
$phpMailer->Port = 587;
|
||||||
|
@ -78,7 +78,7 @@ class Email{
|
||||||
$log->Write($this->TextBody);
|
$log->Write($this->TextBody);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$phpMailer->Send();
|
$phpMailer->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception $ex){
|
catch(Exception $ex){
|
||||||
|
|
|
@ -45,7 +45,7 @@ class RssFeed extends Feed{
|
||||||
$currentEntries = [];
|
$currentEntries = [];
|
||||||
foreach($this->Entries as $entry){
|
foreach($this->Entries as $entry){
|
||||||
/** @var Ebook $entry */
|
/** @var Ebook $entry */
|
||||||
$obj = new StdClass();
|
$obj = new stdClass();
|
||||||
$obj->Size = (string)filesize(WEB_ROOT . $entry->EpubUrl);
|
$obj->Size = (string)filesize(WEB_ROOT . $entry->EpubUrl);
|
||||||
$obj->Id = preg_replace('/^url:/ius', '', $entry->Identifier);
|
$obj->Id = preg_replace('/^url:/ius', '', $entry->Identifier);
|
||||||
$currentEntries[] = $obj;
|
$currentEntries[] = $obj;
|
||||||
|
@ -56,7 +56,7 @@ class RssFeed extends Feed{
|
||||||
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', file_get_contents($path)));
|
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', file_get_contents($path)));
|
||||||
$xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
|
$xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom');
|
||||||
foreach($xml->xpath('/rss/channel/item') ?: [] as $entry){
|
foreach($xml->xpath('/rss/channel/item') ?: [] as $entry){
|
||||||
$obj = new StdClass();
|
$obj = new stdClass();
|
||||||
foreach($entry->xpath('enclosure') ?: [] as $enclosure){
|
foreach($entry->xpath('enclosure') ?: [] as $enclosure){
|
||||||
$obj->Size = (string)$enclosure['length'];
|
$obj->Size = (string)$enclosure['length'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ try{
|
||||||
// Check if we need to log in to FA.
|
// Check if we need to log in to FA.
|
||||||
// Wait until the <body> element is visible, then check the current URL.
|
// Wait until the <body> element is visible, then check the current URL.
|
||||||
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('/html/body')));
|
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('/html/body')));
|
||||||
if(stripos($driver->getCurrentUrl(), 'auth0.com')){
|
if(stripos($driver->getCurrentURL(), 'auth0.com')){
|
||||||
$log->Write('Logging in to Fractured Atlas ...');
|
$log->Write('Logging in to Fractured Atlas ...');
|
||||||
|
|
||||||
// We were redirected to the login page, so try to log in.
|
// We were redirected to the login page, so try to log in.
|
||||||
|
|
|
@ -91,7 +91,7 @@ try{
|
||||||
// Check if we need to log in to FA.
|
// Check if we need to log in to FA.
|
||||||
// Wait until the <body> element is visible, then check the current URL.
|
// Wait until the <body> element is visible, then check the current URL.
|
||||||
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('/html/body')));
|
$driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('/html/body')));
|
||||||
if(stripos($driver->getCurrentUrl(), 'auth0.com')){
|
if(stripos($driver->getCurrentURL(), 'auth0.com')){
|
||||||
$log->Write('Logging in to Fractured Atlas ...');
|
$log->Write('Logging in to Fractured Atlas ...');
|
||||||
|
|
||||||
// We were redirected to the login page, so try to log in.
|
// We were redirected to the login page, so try to log in.
|
||||||
|
|
|
@ -76,7 +76,7 @@ catch(Exceptions\InvalidPermissionsException){
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Created:</td>
|
<td>Created:</td>
|
||||||
<td><?= $user->Created->Format(Enums\DateTimeFormat::FullDateTime->value) ?></td>
|
<td><?= $user->Created->format(Enums\DateTimeFormat::FullDateTime->value) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -219,7 +219,7 @@ catch(Exceptions\InvalidPermissionsException){
|
||||||
<? foreach($user->Payments as $payment){ ?>
|
<? foreach($user->Payments as $payment){ ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<time datetime="<?= $payment->Created->format(Enums\DateTimeFormat::Html->value) ?>"><?= $payment->Created->Format(Enums\DateTimeFormat::FullDateTime->value) ?></time>
|
<time datetime="<?= $payment->Created->format(Enums\DateTimeFormat::Html->value) ?>"><?= $payment->Created->format(Enums\DateTimeFormat::FullDateTime->value) ?></time>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<? if($payment->IsRecurring){ ?>
|
<? if($payment->IsRecurring){ ?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue