PHPStan tweaks

This commit is contained in:
Alex Cabal 2022-07-09 11:07:38 -05:00
parent edd032be2c
commit 7c087e0e13
2 changed files with 12 additions and 7 deletions

View file

@ -11,10 +11,6 @@ $contentFiles = explode("\n", trim(shell_exec('find ' . escapeshellarg($webRoot
$ebooksByMonth = [];
$lastUpdatedTimestamps = [];
if(!is_dir(WEB_ROOT . '/patrons-circle/downloads')){
mkdir(WEB_ROOT . '/patrons-circle/downloads');
}
// Iterate over all ebooks and arrange them by publication month
foreach($contentFiles as $path){
if($path == '')
@ -50,7 +46,7 @@ foreach($ebooksByMonth as $month => $ebooks){
$filename = 'se-ebooks-' . $month . '.zip';
$filePath = $webRoot . '/www/patrons-circle/downloads/' . $filename;
// If the file doesn't exist, or if the content.opf last updated time is newer than the file creation time
// If the file doesn't exist, or if the content.opf last updated time is newer than the file modification time
if(!file_exists($filePath) || filemtime($filePath) < $lastUpdatedTimestamps[$month]){
print('Creating ' . $filePath . "\n");

View file

@ -1,9 +1,18 @@
<?
require_once('Core.php');
use Safe\DateTime;
use function Safe\filemtime;
use function Safe\filesize;
use function Safe\glob;
use function Safe\gmdate;
use function Safe\rsort;
$ex = null;
if(isset($_SERVER['PHP_AUTH_USER'])){
// We get here if the user entered an invalid HTTP Basic Auth username,
// and this page was served as the 401 page.
$ex = new Exceptions\InvalidPatronException();
}
@ -61,7 +70,7 @@ foreach($files as $file){
<ul class="download-list">
<? foreach($years as $year => $items){ ?>
<li>
<p class="header"><?= Formatter::ToPlainText($year) ?></p>
<p class="header"><?= Formatter::ToPlainText((string)$year) ?></p>
<table>
<thead>
<td></td>
@ -75,7 +84,7 @@ foreach($files as $file){
<td><a download="" href="<?= Formatter::ToPlainText($item->Url) ?>"><?= Formatter::ToPlainText($item->Month) ?></a></td>
<td><?= Formatter::ToPlainText(number_format($item->Count)) ?></td>
<td><?= Formatter::ToPlainText($item->Size) ?></td>
<td><?= Formatter::ToPlainText($obj->Updated) ?></td>
<td><?= Formatter::ToPlainText($item->Updated) ?></td>
</tr>
<? } ?>
</tbody>