- reformatted some array
- added missing documentation
- added type-hints
- changed double-quotes to single
This commit is contained in:
Roland Häder 2022-06-23 11:39:45 +02:00
parent c6c936a80f
commit b8353a6eb7
No known key found for this signature in database
GPG key ID: C82EDE5DDFA0BA77
10 changed files with 106 additions and 84 deletions

View file

@ -363,7 +363,7 @@ class Install extends BaseModule
* @return string The text for the next steps
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private function whatNext()
private function whatNext(): string
{
$baseurl = $this->baseUrl->get();
return
@ -383,6 +383,7 @@ class Install extends BaseModule
* @param string $cat The category of the setting
* @param string $key The key of the setting
* @param null|string $default The default value
* @return void
*/
private function checkSetting(Cache $configCache, array $post, string $cat, string $key, ?string $default = null)
{

View file

@ -45,7 +45,7 @@ class Maintenance extends BaseModule
$exception = new HTTPException\ServiceUnavailableException($reason);
header($_SERVER["SERVER_PROTOCOL"] . ' ' . $exception->getCode() . ' ' . DI::l10n()->t('System down for maintenance'));
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $exception->getCode() . ' ' . DI::l10n()->t('System down for maintenance'));
$tpl = Renderer::getMarkupTemplate('exception.tpl');

View file

@ -131,7 +131,7 @@ class NoScrape extends BaseModule
$profile_fields = ['about', 'locality', 'region', 'postal-code', 'country-name', 'xmpp', 'matrix'];
foreach ($profile_fields as $field) {
if (!empty($owner[$field])) {
$json_info["$field"] = $owner[$field];
$json_info[$field] = $owner[$field];
}
}

View file

@ -174,7 +174,7 @@ class PermissionTooltip extends \Friendica\BaseModule
* @param int $uriId
* @return string
*/
private function fetchReceivers(int $uriId):string
private function fetchReceivers(int $uriId): string
{
$own_url = '';
$uid = local_user();

View file

@ -60,17 +60,17 @@ class Photo extends BaseModule
{
$totalstamp = microtime(true);
if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
if (!empty($_SERVER["HTTP_IF_NONE_MATCH"])) {
header("Etag: " . $_SERVER["HTTP_IF_NONE_MATCH"]);
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']);
}
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
header("Cache-Control: max-age=31536000");
if (function_exists("header_remove")) {
header_remove("Last-Modified");
header_remove("Expires");
header_remove("Cache-Control");
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
header('Cache-Control: max-age=31536000');
if (function_exists('header_remove')) {
header_remove('Last-Modified');
header_remove('Expires');
header_remove('Cache-Control');
}
throw new NotModifiedException();
}
@ -132,7 +132,7 @@ class Photo extends BaseModule
} else {
$photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME);
$scale = 0;
if (substr($photoid, -2, 1) == "-") {
if (substr($photoid, -2, 1) == '-') {
$scale = intval(substr($photoid, -1, 1));
$photoid = substr($photoid, 0, -2);
}
@ -148,7 +148,7 @@ class Photo extends BaseModule
throw new HTTPException\NotFoundException();
}
$cacheable = ($photo["allow_cid"] . $photo["allow_gid"] . $photo["deny_cid"] . $photo["deny_gid"] === "") && (isset($photo["cacheable"]) ? $photo["cacheable"] : true);
$cacheable = ($photo['allow_cid'] . $photo['allow_gid'] . $photo['deny_cid'] . $photo['deny_gid'] === '') && (isset($photo['cacheable']) ? $photo['cacheable'] : true);
$stamp = microtime(true);
@ -179,35 +179,35 @@ class Photo extends BaseModule
}
// if customsize is set and image is not a gif, resize it
if ($photo['type'] !== "image/gif" && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) {
if ($photo['type'] !== 'image/gif' && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) {
$img = new Image($imgdata, $photo['type']);
$img->scaleToSquare($customsize);
$imgdata = $img->asString();
} elseif ($photo['type'] !== "image/gif" && $customsize > 0) {
} elseif ($photo['type'] !== 'image/gif' && $customsize > 0) {
$img = new Image($imgdata, $photo['type']);
$img->scaleDown($customsize);
$imgdata = $img->asString();
}
if (function_exists("header_remove")) {
header_remove("Pragma");
header_remove("pragma");
if (function_exists('header_remove')) {
header_remove('Pragma');
header_remove('pragma');
}
header("Content-type: " . $photo['type']);
header('Content-type: ' . $photo['type']);
$stamp = microtime(true);
if (!$cacheable) {
// it is a private photo that they have no permission to view.
// tell the browser not to cache it, in case they authenticate
// and subsequently have permission to see it
header("Cache-Control: no-store, no-cache, must-revalidate");
header('Cache-Control: no-store, no-cache, must-revalidate');
} else {
$md5 = $photo['hash'] ?: md5($imgdata);
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
header("Etag: \"{$md5}\"");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
header("Cache-Control: max-age=31536000");
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
header('Cache-Control: max-age=31536000');
}
$checksum = microtime(true) - $stamp;

View file

@ -55,17 +55,17 @@ class Proxy extends BaseModule
throw new \Friendica\Network\HTTPException\NotFoundException();
}
if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
if (!empty($_SERVER["HTTP_IF_NONE_MATCH"])) {
header("Etag: " . $_SERVER["HTTP_IF_NONE_MATCH"]);
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']);
}
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
header("Cache-Control: max-age=31536000");
if (function_exists("header_remove")) {
header_remove("Last-Modified");
header_remove("Expires");
header_remove("Cache-Control");
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
header('Cache-Control: max-age=31536000');
if (function_exists('header_remove')) {
header_remove('Last-Modified');
header_remove('Expires');
header_remove('Cache-Control');
}
throw new NotModifiedException();
}
@ -123,7 +123,7 @@ class Proxy extends BaseModule
* ]
* @throws \Exception
*/
private function getRequestInfo()
private function getRequestInfo(): array
{
$size = ProxyUtils::PIXEL_LARGE;
$sizetype = '';
@ -187,6 +187,7 @@ class Proxy extends BaseModule
* Output the image with cache headers
*
* @param Image $img
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function responseImageHttpCache(Image $img)