Move to PHP 8.0 (#4051)

This commit is contained in:
Buster "Silver Eagle" Neece 2021-04-22 21:16:00 -05:00 committed by GitHub
parent c5e3072819
commit acab8806b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 236 additions and 263 deletions

View File

@ -1,4 +1,11 @@
FROM azuracast/azuracast_testing:latest
FROM php:8.0-cli-alpine
RUN apk add --no-cache npm
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
RUN mkdir /app
WORKDIR /app
USER root

View File

@ -1,5 +1,8 @@
#!/usr/bin/env sh
# Install Composer dependencies if not already installed.
composer install --no-interaction --ignore-platform-reqs
# Import locales on backend
bin/console locale:import

View File

@ -1,11 +1,15 @@
FROM azuracast/azuracast_testing:latest
FROM php:8.0-cli-alpine
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
RUN mkdir /app
WORKDIR /app
USER root
ENV APPLICATION_ENV="testing"
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod a+x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh
# Install Composer dependencies
composer install --no-interaction --ignore-platform-req=ext-maxminddb
composer install --no-interaction --ignore-platform-reqs
# Import locales on backend
bin/console locale:generate

View File

@ -4,7 +4,7 @@
"license": "Apache-2.0",
"type": "project",
"require": {
"php": ">=7.4 || ^8.0",
"php": "^8.0",
"ext-PDO": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
@ -40,7 +40,7 @@
"league/flysystem-aws-s3-v3": "^2.0",
"league/mime-type-detection": "^1.7",
"league/plates": "^3.1",
"lstrojny/fxmlrpc": "dev-master",
"lstrojny/fxmlrpc": "dev-php8 as 0.13",
"matomo/device-detector": "^4.0",
"mezzio/mezzio-session": "^1.3",
"mezzio/mezzio-session-cache": "^1.4",
@ -57,7 +57,7 @@
"psr/simple-cache": "^1.0",
"ramsey/uuid": "^4.0",
"ramsey/uuid-doctrine": "^1.6",
"rlanvin/php-ip": "^2.0",
"rlanvin/php-ip": "dev-master",
"slim/http": "^1.1",
"slim/slim": "^4.2",
"spatie/flysystem-dropbox": "^2",
@ -80,6 +80,12 @@
"wikimedia/composer-merge-plugin": "dev-master",
"zircote/swagger-php": "^3"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/VincentLanglet/fxmlrpc.git"
}
],
"require-dev": {
"codeception/codeception": "^4.0",
"codeception/module-asserts": "^1.1",
@ -107,6 +113,7 @@
"symfony/polyfill-php72": "1.99",
"symfony/polyfill-php73": "1.99",
"symfony/polyfill-php74": "1.99",
"symfony/polyfill-php80": "1.99",
"symfony/polyfill-iconv": "1.99",
"symfony/polyfill-intl-grapheme": "1.99",
"symfony/polyfill-intl-normalizer": "1.99",

186
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "17f74c9a9115bff2e514f58d32a7f93f",
"content-hash": "e86fbe854cbc0f8ea151f1c5c9fee013",
"packages": [
{
"name": "aws/aws-sdk-php",
@ -102,12 +102,12 @@
"source": {
"type": "git",
"url": "https://github.com/AzuraCast/azuraforms.git",
"reference": "16da3c4c2ca17d2b5e89d1569f9ef39f58e7e95c"
"reference": "ed1aaa82c684ebd2a748a6e834fd307f3618bd48"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/AzuraCast/azuraforms/zipball/16da3c4c2ca17d2b5e89d1569f9ef39f58e7e95c",
"reference": "16da3c4c2ca17d2b5e89d1569f9ef39f58e7e95c",
"url": "https://api.github.com/repos/AzuraCast/azuraforms/zipball/ed1aaa82c684ebd2a748a6e834fd307f3618bd48",
"reference": "ed1aaa82c684ebd2a748a6e834fd307f3618bd48",
"shasum": ""
},
"require": {
@ -163,7 +163,7 @@
"type": "patreon"
}
],
"time": "2021-04-06T22:53:26+00:00"
"time": "2021-04-22T09:53:37+00:00"
},
{
"name": "azuracast/flysystem-v2-extensions",
@ -862,40 +862,39 @@
},
{
"name": "doctrine/cache",
"version": "1.10.2",
"version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "13e3381b25847283a91948d04640543941309727"
"reference": "a9c1b59eba5a08ca2770a76eddb88922f504e8e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/13e3381b25847283a91948d04640543941309727",
"reference": "13e3381b25847283a91948d04640543941309727",
"url": "https://api.github.com/repos/doctrine/cache/zipball/a9c1b59eba5a08ca2770a76eddb88922f504e8e0",
"reference": "a9c1b59eba5a08ca2770a76eddb88922f504e8e0",
"shasum": ""
},
"require": {
"php": "~7.1 || ^8.0"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
"doctrine/common": ">2.2,<2.4",
"psr/cache": ">=3"
},
"require-dev": {
"alcaeus/mongo-php-adapter": "^1.1",
"doctrine/coding-standard": "^6.0",
"cache/integration-tests": "dev-master",
"doctrine/coding-standard": "^8.0",
"mongodb/mongodb": "^1.1",
"phpunit/phpunit": "^7.0",
"predis/predis": "~1.0"
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"predis/predis": "~1.0",
"psr/cache": "^1.0 || ^2.0",
"symfony/cache": "^4.4 || ^5.2"
},
"suggest": {
"alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
@ -942,7 +941,7 @@
],
"support": {
"issues": "https://github.com/doctrine/cache/issues",
"source": "https://github.com/doctrine/cache/tree/1.10.x"
"source": "https://github.com/doctrine/cache/tree/1.11.0"
},
"funding": [
{
@ -958,7 +957,7 @@
"type": "tidelift"
}
],
"time": "2020-07-07T18:54:01+00:00"
"time": "2021-04-13T14:46:17+00:00"
},
{
"name": "doctrine/collections",
@ -3481,31 +3480,24 @@
},
{
"name": "lstrojny/fxmlrpc",
"version": "dev-master",
"version": "dev-php8",
"source": {
"type": "git",
"url": "https://github.com/lstrojny/fxmlrpc.git",
"reference": "968c92c12a950146551f228f709170c52ca35911"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lstrojny/fxmlrpc/zipball/968c92c12a950146551f228f709170c52ca35911",
"reference": "968c92c12a950146551f228f709170c52ca35911",
"shasum": ""
"url": "https://github.com/VincentLanglet/fxmlrpc.git",
"reference": "8f053ee53d27da796adff3e1ca929f48e7171c1f"
},
"require": {
"php": "~7.1",
"php": "^7.2 || ^8.0",
"php-http/discovery": "^1.0"
},
"require-dev": {
"internations/kodierungsregelwerksammlung": "dev-master",
"lstrojny/hmmmath": "dev-master",
"lstrojny/hmmmath": "^0.8",
"monolog/monolog": "~1",
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
"php-http/guzzle7-adapter": "^0.1",
"php-http/httplug": "^1.0 || ^2.0",
"php-http/message": "^1.2",
"php-http/message-factory": "^1.0",
"phpunit/phpunit": "~7",
"phpunit/phpunit": "^8.5",
"psr/http-factory": "*",
"psr/log": "*",
"symfony/process": "~2.1",
@ -3518,11 +3510,11 @@
"php-http/curl-client": "A simple PSR-7 compatible HTTP client",
"php-http/guzzle5-adapter": "Guzzle 5 PSR-7 adapter",
"php-http/guzzle6-adapter": "Guzzle 6 PSR-7 adapter",
"php-http/guzzle7-adapter": "Guzzle 7 PSR-7 adapter",
"php-http/message": "For PSR-7 message factories",
"zendframework/zend-log": "To use ZF2 Zend\\Log\\Logger as a logger",
"zendframework/zendframework1": "To use ZF1 Log"
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
@ -3534,7 +3526,11 @@
"fXmlRpc\\": "src/fXmlRpc"
}
},
"notification-url": "https://packagist.org/downloads/",
"autoload-dev": {
"psr-4": {
"fXmlRpc\\": "tests/fXmlRpc"
}
},
"license": [
"MIT"
],
@ -3553,11 +3549,7 @@
"xml",
"xmlrpc"
],
"support": {
"issues": "https://github.com/lstrojny/fxmlrpc/issues",
"source": "https://github.com/lstrojny/fxmlrpc/tree/master"
},
"time": "2020-11-23T14:42:43+00:00"
"time": "2020-12-17T18:20:51+00:00"
},
{
"name": "matomo/device-detector",
@ -5724,25 +5716,26 @@
},
{
"name": "rlanvin/php-ip",
"version": "v2.1.0",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/rlanvin/php-ip.git",
"reference": "1bea521987f3c7db5f4b9f17f321e90feaefad11"
"reference": "6b74d8bc8f054e2f2da8b636e772b8155b8f1b97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rlanvin/php-ip/zipball/1bea521987f3c7db5f4b9f17f321e90feaefad11",
"reference": "1bea521987f3c7db5f4b9f17f321e90feaefad11",
"url": "https://api.github.com/repos/rlanvin/php-ip/zipball/6b74d8bc8f054e2f2da8b636e772b8155b8f1b97",
"reference": "6b74d8bc8f054e2f2da8b636e772b8155b8f1b97",
"shasum": ""
},
"require": {
"ext-gmp": "*",
"php": "~7.0"
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": ">=6.5 <8.1"
"phpunit/phpunit": "^6.5|^8.0"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
@ -5762,9 +5755,9 @@
],
"support": {
"issues": "https://github.com/rlanvin/php-ip/issues",
"source": "https://github.com/rlanvin/php-ip/tree/v2.1.0"
"source": "https://github.com/rlanvin/php-ip/tree/v3.0.0-rc1"
},
"time": "2020-10-31T12:31:56+00:00"
"time": "2021-04-18T09:53:09+00:00"
},
{
"name": "slim/http",
@ -7493,89 +7486,6 @@
],
"time": "2021-01-22T09:19:47+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91",
"reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.22.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-07T16:49:33+00:00"
},
{
"name": "symfony/process",
"version": "v5.2.4",
@ -12973,13 +12883,21 @@
"time": "2021-03-09T10:59:23+00:00"
}
],
"aliases": [],
"aliases": [
{
"package": "lstrojny/fxmlrpc",
"version": "dev-php8",
"alias": "0.13",
"alias_normalized": "0.13.0.0"
}
],
"minimum-stability": "dev",
"stability-flags": {
"azuracast/azuraforms": 20,
"azuracast/flysystem-v2-extensions": 20,
"azuracast/nowplaying": 20,
"lstrojny/fxmlrpc": 20,
"rlanvin/php-ip": 20,
"supervisorphp/supervisor": 20,
"wikimedia/composer-merge-plugin": 20,
"roave/security-advisories": 20
@ -12987,7 +12905,7 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">=7.4 || ^8.0",
"php": "^8.0",
"ext-pdo": "*",
"ext-fileinfo": "*",
"ext-gd": "*",

View File

@ -2,6 +2,8 @@ version : '2.2'
services :
web :
build :
context : .
environment :
APPLICATION_ENV : 'testing'
volumes :

View File

@ -33,9 +33,8 @@ abstract class AbstractAdminCrudController
* @param ServerRequest $request
* @param string|int|null $id
*
* @return object|bool|null
*/
protected function doEdit(ServerRequest $request, $id = null)
protected function doEdit(ServerRequest $request, $id = null): object|bool|null
{
$record = $this->getRecord($id);
return $this->form->process($request, $record);

View File

@ -45,8 +45,10 @@ class IndexController
$meminfoRaw = explode("\n", file_get_contents("/proc/meminfo"));
$meminfo = [];
foreach ($meminfoRaw as $line) {
[$key, $val] = explode(":", $line);
$meminfo[$key] = trim($val);
if (str_contains($line, ':')) {
[$key, $val] = explode(":", $line);
$meminfo[$key] = trim($val);
}
}
$memoryTotal = Quota::convertFromReadableSize($meminfo['MemTotal']) ?? BigInteger::zero();

View File

@ -68,9 +68,8 @@ abstract class AbstractApiCrudController
* @param object $record
* @param ServerRequest $request
*
* @return mixed
*/
protected function viewRecord($record, ServerRequest $request)
protected function viewRecord($record, ServerRequest $request): mixed
{
if (!($record instanceof $this->entityClass)) {
throw new InvalidArgumentException(sprintf('Record must be an instance of %s.', $this->entityClass));
@ -126,9 +125,8 @@ abstract class AbstractApiCrudController
/**
* @param object $object
*
* @return mixed
*/
protected function displayShortenedObject($object)
protected function displayShortenedObject($object): mixed
{
if (method_exists($object, 'getName')) {
return $object->getName();

View File

@ -129,7 +129,7 @@ class StorageLocationsController extends AbstractAdminApiCrudController
}
/** @inheritDoc */
protected function viewRecord($record, ServerRequest $request)
protected function viewRecord($record, ServerRequest $request): mixed
{
/** @var Entity\StorageLocation $record */
$original = parent::viewRecord($record, $request);

View File

@ -97,7 +97,7 @@ class RequestsController
->addOrderBy('sm.title', 'ASC');
}
$search_phrase = trim($params['searchPhrase']);
$search_phrase = trim($params['searchPhrase'] ?? '');
if (!empty($search_phrase)) {
$qb->andWhere('(sm.title LIKE :query OR sm.artist LIKE :query OR sm.album LIKE :query)')
->setParameter('query', '%' . $search_phrase . '%');

View File

@ -38,9 +38,8 @@ abstract class AbstractStationCrudController
* @param ServerRequest $request
* @param string|int|null $id
*
* @return object|bool|null
*/
protected function doEdit(ServerRequest $request, $id = null)
protected function doEdit(ServerRequest $request, $id = null): object|bool|null
{
$station = $request->getStation();
$this->form->setStation($station);

View File

@ -160,7 +160,7 @@ class OverviewController
for ($i = 0; $i < 24; $i++) {
$hourly_labels[] = $i . ':00';
$totals = $totals_by_hour[$i] ?: [0];
$totals = $totals_by_hour[$i] ?? [0];
$stat_value = round(array_sum($totals) / count($totals), 2);
$hourly_rows[] = $stat_value;
@ -197,11 +197,13 @@ class OverviewController
$song_totals = [];
foreach ($song_totals_raw as $total_type => $total_records) {
$song_totals[$total_type] = [];
foreach ($total_records as $total_record) {
$song_totals[$total_type][] = $total_record;
}
$song_totals[$total_type] = array_slice((array)$song_totals[$total_type], 0, 10, true);
$song_totals[$total_type] = array_slice($song_totals[$total_type], 0, 10, true);
}
/* Song "Deltas" (Changes in Listener Count) */

View File

@ -33,9 +33,8 @@ class DeferredCallable
}
/**
* @return mixed
*/
public function __invoke(...$args)
public function __invoke(...$args): mixed
{
/** @var callable $callable */
$callable = $this->callable;

View File

@ -145,9 +145,8 @@ final class BatchIteratorAggregate implements IteratorAggregate
/**
* @param mixed $value
*
* @return mixed|object
*/
private function getObjectFromValue($value)
private function getObjectFromValue($value): mixed
{
if ($this->customFetchFunction instanceof Closure) {
return ($this->customFetchFunction)($value, $this->entityManager);

View File

@ -134,9 +134,8 @@ class Relay
}
/**
* @return mixed|null
*/
public function getNowplaying()
public function getNowplaying(): mixed
{
return $this->nowplaying;
}

View File

@ -69,7 +69,12 @@ class RolePermissionRepository extends Repository
->execute();
foreach ($post_values as $post_key => $post_value) {
[$post_key_action, $post_key_id] = explode('_', $post_key);
if (str_contains($post_key, '_')) {
[$post_key_action, $post_key_id] = explode('_', $post_key);
} else {
$post_key_action = $post_key;
$post_key_id = null;
}
if ($post_key_action !== 'actions' || empty($post_value)) {
continue;

View File

@ -67,9 +67,8 @@ class StationRepository extends Repository
}
/**
* @return mixed
*/
public function fetchAll()
public function fetchAll(): mixed
{
return $this->em->createQuery(
<<<'DQL'

View File

@ -61,9 +61,8 @@ class StationStreamerRepository extends Repository
* @param Entity\Station $station
* @param string $username
*
* @return string|bool
*/
public function onConnect(Entity\Station $station, string $username = '')
public function onConnect(Entity\Station $station, string $username = ''): string|bool
{
// End all current streamer sessions.
$this->broadcastRepo->endAllActiveBroadcasts($station);

View File

@ -348,9 +348,8 @@ class SongHistory implements SongInterface
}
/**
* @return mixed
*/
public function getDeltaPoints()
public function getDeltaPoints(): mixed
{
return $this->delta_points;
}

View File

@ -211,9 +211,8 @@ class StationWebhook
* @param string $key
* @param mixed|null $default
*
* @return mixed|null
*/
public function getMetadataKey(string $key, $default = null)
public function getMetadataKey(string $key, $default = null): mixed
{
return $this->metadata[$key] ?? $default;
}

View File

@ -426,9 +426,9 @@ class StorageLocation
}
/**
* @return StationMedia[]|Collection
* @return Collection|StationMedia[]
*/
public function getMedia()
public function getMedia(): Collection
{
return $this->media;
}

View File

@ -21,9 +21,8 @@ trait UniqueId
protected $unique_id;
/**
* @return mixed
*/
public function getUniqueId()
public function getUniqueId(): mixed
{
return $this->unique_id;
}

View File

@ -42,7 +42,7 @@ abstract class AbstractSettingsForm extends EntityForm
}
/** @inheritDoc */
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
if (null === $record) {
$record = $this->settingsRepo->readSettings();

View File

@ -82,7 +82,7 @@ class EntityForm extends Form
*
* @return object|bool The modified object if edited/created, or `false` if not processed.
*/
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
if (!isset($this->entityClass)) {
throw new Exception('Entity class name is not specified.');
@ -169,9 +169,8 @@ class EntityForm extends Form
/**
* @param object $object
*
* @return mixed
*/
protected function displayShortenedObject($object)
protected function displayShortenedObject($object): mixed
{
if (method_exists($object, 'getName')) {
return $object->getName();

View File

@ -27,9 +27,8 @@ class PlaylistTime extends Time
}
/**
* @return string|int
*/
public function getValue()
public function getValue(): string|int
{
if (empty($this->value)) {
return '';

View File

@ -39,7 +39,7 @@ class PermissionsForm extends EntityForm
/**
* @inheritDoc
*/
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
if ($record instanceof Entity\Role && Entity\Role::SUPER_ADMINISTRATOR_ROLE_ID === $record->getId()) {
$this->set_permissions = false;

View File

@ -34,7 +34,7 @@ class SettingsForm extends AbstractSettingsForm
}
/** @inheritDoc */
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
if ('https' !== $request->getUri()->getScheme()) {
$alwaysUseSsl = $this->getField('always_use_ssl');

View File

@ -57,7 +57,7 @@ class StationCloneForm extends StationForm
/**
* @inheritDoc
*/
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
if (!$record instanceof Entity\Station) {
throw new InvalidArgumentException('Record must be a station.');

View File

@ -76,7 +76,7 @@ class StationForm extends EntityForm
/**
* @inheritDoc
*/
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
// Check for administrative permissions and hide admin fields otherwise.
$acl = $request->getAcl();

View File

@ -35,7 +35,7 @@ class StationMountForm extends EntityForm
/**
* @inheritDoc
*/
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
$record = parent::process($request, $record);

View File

@ -65,7 +65,7 @@ class StationWebhookForm extends EntityForm
/**
* @inheritDoc
*/
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
if (!$record instanceof Entity\StationWebhook) {
throw new InvalidArgumentException(

View File

@ -30,7 +30,7 @@ class UserForm extends EntityForm
/**
* @inheritDoc
*/
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
// Check for administrative permissions and hide admin fields otherwise.
$user = $request->getUser();

View File

@ -34,7 +34,7 @@ class UserProfileForm extends EntityForm
/**
* @inheritDoc
*/
public function process(ServerRequest $request, $record = null)
public function process(ServerRequest $request, $record = null): object|bool
{
$user = $request->getUser();

View File

@ -21,7 +21,7 @@ final class Response extends \Slim\Http\Response
* Send headers that expire the content immediately and prevent caching.
* @return static
*/
public function withNoCache()
public function withNoCache(): static
{
$response = $this->response
->withHeader('Pragma', 'no-cache')
@ -39,7 +39,7 @@ final class Response extends \Slim\Http\Response
*
* @return static
*/
public function withCacheLifetime(int $seconds = self::CACHE_ONE_MONTH)
public function withCacheLifetime(int $seconds = self::CACHE_ONE_MONTH): static
{
$response = $this->response
->withHeader('Pragma', '')
@ -86,7 +86,7 @@ final class Response extends \Slim\Http\Response
*
* @return static
*/
public function renderFile($file_path, $file_name = null)
public function renderFile($file_path, $file_name = null): static
{
set_time_limit(600);
@ -117,7 +117,7 @@ final class Response extends \Slim\Http\Response
*
* @return static
*/
public function renderStringAsFile($file_data, $content_type, $file_name = null)
public function renderStringAsFile($file_data, $content_type, $file_name = null): static
{
$response = $this->response
->withHeader('Pragma', 'public')
@ -147,7 +147,7 @@ final class Response extends \Slim\Http\Response
StreamInterface $fileStream,
string $contentType,
?string $fileName = null
) {
): static {
set_time_limit(600);
$response = $this->response

View File

@ -124,10 +124,9 @@ final class ServerRequest extends \Slim\Http\ServerRequest
* @param string $attr
* @param string $class_name
*
* @return mixed
* @throws Exception\InvalidRequestAttribute
*/
protected function getAttributeOfClass($attr, $class_name)
protected function getAttributeOfClass($attr, $class_name): mixed
{
$object = $this->serverRequest->getAttribute($attr);

View File

@ -94,9 +94,8 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
* @param string|null $format
* @param array $context
*
* @return mixed
*/
public function normalize($object, string $format = null, array $context = [])
public function normalize($object, string $format = null, array $context = []): mixed
{
if ($this->isCircularReference($object, $context)) {
return $this->handleCircularReference($object, $format, $context);
@ -214,7 +213,7 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
*
* @return bool|string[]|AttributeMetadataInterface[]
*/
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false): bool|array
{
$meta = $this->classMetadataFactory->getMetadataFor($classOrObject)->getAttributesMetadata();
@ -251,9 +250,8 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
* @param null $format
* @param array $context
*
* @return mixed
*/
protected function getAttributeValue($object, $prop_name, $format = null, array $context = [])
protected function getAttributeValue($object, $prop_name, $format = null, array $context = []): mixed
{
$form_mode = $context[self::NORMALIZE_TO_IDENTIFIERS] ?? false;
@ -310,9 +308,8 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
* @param object $entity
* @param string $key
*
* @return mixed|null
*/
protected function getProperty($entity, $key)
protected function getProperty($entity, $key): mixed
{
// Default to "getStatus", "getConfig", etc...
$getter_method = $this->getMethodName($key, 'get');
@ -385,9 +382,8 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
* @param string $key
* @param mixed $value
*
* @return mixed|null
*/
protected function setProperty($entity, $key, $value)
protected function setProperty($entity, $key, $value): mixed
{
$method_name = $this->getMethodName($key, 'set');

View File

@ -185,7 +185,7 @@ abstract class AbstractFrontend extends AbstractAdapter
*
* @return mixed[]|bool
*/
protected function processCustomConfig(?string $custom_config_raw)
protected function processCustomConfig(?string $custom_config_raw): array|bool
{
$custom_config = [];

View File

@ -53,7 +53,7 @@ class Flow
ServerRequest $request,
Response $response,
string $temp_dir = null
) {
): array|ResponseInterface|null {
if (null === $temp_dir) {
$temp_dir = sys_get_temp_dir() . '/uploads/';
}

View File

@ -10,7 +10,7 @@ trait AvailableStaticallyTrait
/**
* @return static
*/
public static function getInstance()
public static function getInstance(): static
{
return self::$instance;
}

View File

@ -34,9 +34,8 @@ class Xml
*
* @param array $array
*
* @return mixed
*/
public static function arrayToXml($array)
public static function arrayToXml($array): mixed
{
$xml_info = new SimpleXMLElement('<?xml version="1.0"?><return></return>');
self::arrToXml($array, $xml_info);

View File

@ -25,7 +25,7 @@ $assets
</div>
<div class="list-group list-group-flush">
<?php foreach ($category['items'] as $item): ?>
<a class="list-group-item list-group-item-action" href="<?=$item['url']?>" title="<?=$item['title']?>">
<a class="list-group-item list-group-item-action" href="<?=$item['url']?>" title="<?=($item['title'] ?? '')?>">
<?=$item['label']?>
</a>
<?php endforeach; ?>

View File

@ -46,6 +46,7 @@ $page_class .= ' theme-' . $customization->getPublicTheme();
<?=$this->section('content')?>
<?php
$hide_footer ??= false;
if (!$customization->hideProductName() && !$hide_footer): ?>
<footer id="footer" class="footer-alt" role="contentinfo">
<?=sprintf(

View File

@ -1,4 +1,5 @@
<?php
/** @var \App\Assets $assets */
$assets->addInlineJs($this->fetch('partials/sidebar_menu.js'), 99);
@ -7,11 +8,14 @@ $assets->addInlineJs($this->fetch('partials/sidebar_menu.js'), 99);
* @var string $active
* @var \App\Http\Router $router
*/
$active ??= null;
?>
<ul class="navdrawer-nav">
<?php foreach ($menu as $category_id => $category): ?>
<?php
foreach ($menu as $category_id => $category): ?>
<li class="nav-item">
<a class="nav-link <?=$category['class']?> <?php
<a class="nav-link <?=($category['class'] ?? '')?> <?php
if ($active === $category_id): ?>active<?php
endif; ?>"
<?php
@ -19,7 +23,7 @@ $assets->addInlineJs($this->fetch('partials/sidebar_menu.js'), 99);
else: ?>data-toggle="collapse" href="#sidebar-submenu-<?=$category_id?>"<?php
endif; ?>
<?php
if ($category['external']): ?>target="_blank"<?php
if ($category['external'] ?? false): ?>target="_blank"<?php
endif; ?>
<?php
if (isset($category['confirm'])): ?>data-confirm-title="<?=$this->e($category['confirm'])?>"<?php
@ -30,7 +34,7 @@ $assets->addInlineJs($this->fetch('partials/sidebar_menu.js'), 99);
<i class="navdrawer-nav-icon material-icons" aria-hidden="true"><?=$category['icon']?></i>
<?=$category['label']?>
<?php
if ($category['external']): ?>
if ($category['external'] ?? false): ?>
<i class="material-icons sm">open_in_new</i>
<?php
endif; ?>
@ -42,11 +46,19 @@ $assets->addInlineJs($this->fetch('partials/sidebar_menu.js'), 99);
<?php
foreach ($category['items'] as $item_id => $item): ?>
<li class="nav-item">
<a class="nav-link pl-4 py-2 text-muted <?=$item['class']?>"
<a class="nav-link pl-4 py-2 text-muted <?=($item['class'] ?? '')?>"
href="<?=$item['url']?>"
<?php if ($item['external']): ?>target="_blank"<?php endif; ?>
<?php if (isset($item['confirm'])): ?>data-confirm-title="<?=$this->e($item['confirm'])?>"<?php endif; ?>
<?php if (isset($item['title'])): ?>title="<?=$this->e($item['title'])?>"<?php endif; ?>>
<?php
if ($item['external'] ?? false): ?>target="_blank"<?php
endif; ?>
<?php
if (isset($item['confirm'])): ?>data-confirm-title="<?=$this->e(
$item['confirm']
)?>"<?php
endif; ?>
<?php
if (isset($item['title'])): ?>title="<?=$this->e($item['title'])?>"<?php
endif; ?>>
<?=$item['label']?>
</a>
</li>

View File

@ -8,4 +8,11 @@
$assets->addInlineJs($this->fetch('partials/station_form.js'), 99);
echo $this->fetch('system/form_page', ['title' => $title, 'header' => $header, 'form' => $form]);
echo $this->fetch(
'system/form_page',
[
'title' => $title ?? null,
'header' => $header ?? null,
'form' => $form,
]
);

View File

@ -4,8 +4,8 @@ $assets
->addInlineJs($this->fetch('stations/mounts/edit.js'), 99);
echo $this->fetch('system/form_page', [
'title' => $title,
'header' => $header,
'title' => $title ?? null,
'header' => $header ?? null,
'form' => $form,
'render_mode' => 'edit'
'render_mode' => 'edit',
]);

View File

@ -4,8 +4,8 @@ $assets
->addInlineJs($this->fetch('stations/remotes/edit.js'), 99);
echo $this->fetch('system/form_page', [
'title' => $title,
'header' => $header,
'title' => $title ?? null,
'header' => $header ?? null,
'form' => $form,
'render_mode' => 'edit'
'render_mode' => 'edit',
]);

View File

@ -9,8 +9,8 @@
*/
$this->layout('main', [
'title' => $title,
'header' => $header,
'title' => $title ?? null,
'header' => $header ?? null,
'manual' => true,
]);

View File

@ -28,7 +28,7 @@
- name: Install Composer Dependencies (Development)
become: true
become_user: azuracast
shell: composer install
shell : composer install --ignore-platform-req=php
args:
chdir: "{{ www_base }}"
when: app_env == "development"
@ -36,7 +36,7 @@
- name: Install Composer Dependencies (Production)
become: true
become_user: azuracast
shell: composer install --no-dev --optimize-autoloader
shell : composer install --ignore-platform-req=php --no-dev --optimize-autoloader
args:
chdir: "{{ www_base }}"
when: app_env == "production"

View File

@ -44,33 +44,46 @@
- php7.2-mbstring
- php7.2-intl
- php7.2-redis
- name: Install PHP 7.4
apt:
name: "{{ packages }}"
state: latest
vars:
packages:
- php7.4-fpm
- php7.4-cli
- php7.4-gd
- php7.4-curl
- php7.4-xml # IceCast XML config
- php7.4-zip # Composer installs
- php7.4-mysqlnd # MySQL Native Driver (Doctrine)
- php7.4-mbstring # Codeception Tests
- php7.4-intl # Localization
- php7.4-redis # Cache
- php7.4-bcmath # BigInteger
- php7.4-gmp # BigInteger and PHP-IP
- php7.4-maxminddb # Maxmind (GeoIP) DB native ext
- php7.4-xml
- php7.4-zip
- php7.4-mysqlnd
- php7.4-mbstring
- php7.4-intl
- php7.4-redis
- php7.4-bcmath
- php7.4-gmp
- php7.4-maxminddb
- name : Install PHP 8.0
apt :
name : "{{ packages }}"
state : latest
vars :
packages :
- php8.0-fpm
- php8.0-cli
- php8.0-gd
- php8.0-curl
- php8.0-xml # IceCast XML config
- php8.0-zip # Composer installs
- php8.0-mysqlnd # MySQL Native Driver (Doctrine)
- php8.0-mbstring # Codeception Tests
- php8.0-intl # Localization
- php8.0-redis # Cache
- php8.0-bcmath # BigInteger
- php8.0-gmp # BigInteger and PHP-IP
- php8.0-maxminddb # Maxmind (GeoIP) DB native ext
- name: Configure PHP FPM Pool
template: src=fpmpool.j2 dest=/etc/php/7.4/fpm/pool.d/www.conf force=true
template : src=fpmpool.j2 dest=/etc/php/8.0/fpm/pool.d/www.conf force=true
- name: Configure php-fpm php.ini
ini_file:
dest: /etc/php/7.4/fpm/php.ini
dest : /etc/php/8.0/fpm/php.ini
section: PHP
option: "{{ item.option }}"
value: "{{ item.value }}"
@ -81,7 +94,7 @@
- name: Configure php-cli php.ini
ini_file:
dest: /etc/php/7.4/cli/php.ini
dest : /etc/php/8.0/cli/php.ini
section: PHP
option: "{{ item.option }}"
value: "{{ item.value }}"

View File

@ -1,4 +1,4 @@
export LC_ALL=C
export DEBIAN_FRONTEND=noninteractive
minimal_apt_get_install='apt-get install -y --no-install-recommends'
minimal_apt_get_install='apt-get install -y --no-install-recommends'

View File

@ -1,3 +1,5 @@
#!/bin/bash
/usr/sbin/php-fpm7.4 -F --fpm-config /etc/php/7.4/fpm/php-fpm.conf -c /etc/php/7.4/fpm/
source /etc/php/.version
/usr/sbin/php-fpm${PHP_VERSION} -F --fpm-config /etc/php/${PHP_VERSION}/fpm/php-fpm.conf -c /etc/php/${PHP_VERSION}/fpm/

View File

@ -3,27 +3,31 @@ set -e
source /bd_build/buildconfig
set -x
PHP_VERSION=8.0
add-apt-repository -y ppa:ondrej/php
apt-get update
$minimal_apt_get_install php7.4-fpm php7.4-cli php7.4-gd \
php7.4-curl php7.4-xml php7.4-zip php7.4-bcmath php7.4-gmp \
php7.4-mysqlnd php7.4-mbstring php7.4-intl php7.4-redis \
php7.4-maxminddb php7.4-xdebug \
mariadb-client
$minimal_apt_get_install php${PHP_VERSION}-fpm php${PHP_VERSION}-cli php${PHP_VERSION}-gd \
php${PHP_VERSION}-curl php${PHP_VERSION}-xml php${PHP_VERSION}-zip php${PHP_VERSION}-bcmath \
php${PHP_VERSION}-gmp php${PHP_VERSION}-mysqlnd php${PHP_VERSION}-mbstring php${PHP_VERSION}-intl \
php${PHP_VERSION}-redis php${PHP_VERSION}-maxminddb php${PHP_VERSION}-xdebug \
mariadb-client
# Copy PHP configuration
mkdir -p /run/php
touch /run/php/php7.4-fpm.pid
touch /run/php/php${PHP_VERSION}-fpm.pid
cp /bd_build/php/php.ini.tmpl /etc/php/7.4/fpm/05-azuracast.ini.tmpl
cp /bd_build/php/www.conf.tmpl /etc/php/7.4/fpm/www.conf.tmpl
echo "PHP_VERSION=${PHP_VERSION}" >>/etc/php/.version
cp /bd_build/php/php.ini.tmpl /etc/php/${PHP_VERSION}/fpm/05-azuracast.ini.tmpl
cp /bd_build/php/www.conf.tmpl /etc/php/${PHP_VERSION}/fpm/www.conf.tmpl
# Install Composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
# Install PHP SPX profiler
$minimal_apt_get_install php7.4-dev zlib1g-dev build-essential
$minimal_apt_get_install php${PHP_VERSION}-dev zlib1g-dev build-essential
cd /bd_build
git clone https://github.com/NoiseByNorthwest/php-spx.git
@ -33,7 +37,7 @@ phpize
make
sudo make install
apt-get remove --purge -y php7.4-dev zlib1g-dev build-essential
apt-get remove --purge -y php${PHP_VERSION}-dev zlib1g-dev build-essential
echo "extension=spx.so" > /etc/php/7.4/cli/conf.d/30-spx.ini
echo "extension=spx.so" > /etc/php/7.4/fpm/conf.d/30-spx.ini
echo "extension=spx.so" >/etc/php/${PHP_VERSION}/cli/conf.d/30-spx.ini
echo "extension=spx.so" >/etc/php/${PHP_VERSION}/fpm/conf.d/30-spx.ini

View File

@ -1,4 +1,8 @@
#!/bin/bash
# Copy the php.ini template to its destination.
dockerize -template "/etc/php/7.4/fpm/05-azuracast.ini.tmpl:/etc/php/7.4/fpm/conf.d/05-azuracast.ini" -template "/etc/php/7.4/fpm/www.conf.tmpl:/etc/php/7.4/fpm/pool.d/www.conf" cp /etc/php/7.4/fpm/conf.d/05-azuracast.ini /etc/php/7.4/cli/conf.d/05-azuracast.ini
source /etc/php/.version
dockerize -template "/etc/php/${PHP_VERSION}/fpm/05-azuracast.ini.tmpl:/etc/php/${PHP_VERSION}/fpm/conf.d/05-azuracast.ini" \
-template "/etc/php/${PHP_VERSION}/fpm/www.conf.tmpl:/etc/php/${PHP_VERSION}/fpm/pool.d/www.conf" \
cp /etc/php/${PHP_VERSION}/fpm/conf.d/05-azuracast.ini /etc/php/${PHP_VERSION}/cli/conf.d/05-azuracast.ini