sintonia/legacy/application/check.php
renovate[bot] 4827dbce71
fix(deps): update dependency friendsofphp/php-cs-fixer to <3.46.1 (main) (#2868)
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[friendsofphp/php-cs-fixer](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer)
| `<3.45.1` -> `<3.46.1` |
[![age](https://developer.mend.io/api/mc/badges/age/packagist/friendsofphp%2fphp-cs-fixer/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/friendsofphp%2fphp-cs-fixer/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/friendsofphp%2fphp-cs-fixer/3.45.0/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/friendsofphp%2fphp-cs-fixer/3.45.0/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>PHP-CS-Fixer/PHP-CS-Fixer (friendsofphp/php-cs-fixer)</summary>

###
[`v3.46.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3460)

[Compare
Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.45.0...v3.46.0)

- chore: fix internal typehints in Tokens
([#&#8203;7656](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7656))
- chore: reduce PHPStan baseline
([#&#8203;7643](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7643))
- docs: Show class with unit tests and BC promise info
([#&#8203;7667](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7667))
- feat: change default ruleset to `@PER-CS` (only behind
PHP_CS_FIXER_FUTURE_MODE=1)
([#&#8203;7650](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7650))
- feat: Support new/instanceof/use trait in
`fully_qualified_strict_types`
([#&#8203;7653](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7653))
- fix: FQCN parse phpdoc using full grammar regex
([#&#8203;7649](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7649))
- fix: Handle FQCN properly with `leading_backslash_in_global_namespace`
option enabled
([#&#8203;7654](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7654))
- fix: PhpdocToParamTypeFixerTest - support for arrow functions
([#&#8203;7647](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7647))
- fix: PHP_CS_FIXER_FUTURE_MODE - proper boolean validation
([#&#8203;7651](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7651))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/libretime/libretime).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: jo <ljonas@riseup.net>
2024-01-07 13:59:02 +01:00

196 lines
4.3 KiB
PHP

<?php
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Exception\AMQPRuntimeException;
function booleanReduce($a, $b)
{
return $a && $b;
}
/**
* Check to see if Airtime is properly configured.
*
* @return bool true if all Airtime dependencies and services are
* properly configured and running
*/
function checkConfiguration()
{
$r1 = array_reduce(checkPhpDependencies(), 'booleanReduce', true);
$r2 = array_reduce(checkExternalServices(), 'booleanReduce', true);
return $r1 && $r2;
}
/**
* Check for Airtime's PHP dependencies and return an associative
* array with the results.
*
* @return array associative array of dependency check results
*/
function checkPhpDependencies()
{
return [
'postgres' => checkDatabaseDependencies(),
];
}
/**
* Check that the PHP dependencies for the database exist.
*
* @return bool true if the database dependencies exist
*/
function checkDatabaseDependencies()
{
global $extensions;
// Check the PHP extension list for the Postgres db extensions
return in_array('pdo_pgsql', $extensions)
&& in_array('pgsql', $extensions);
}
function with_systemd()
{
return !empty(shell_exec('which systemctl'));
}
/**
* Check that all external services are configured correctly and return an associative
* array with the results.
*
* @return array associative array of external service check results
*/
function checkExternalServices()
{
$result = [
'database' => checkDatabaseConfiguration(),
'rabbitmq' => checkRMQConnection(),
];
if (with_systemd()) {
$result['analyzer'] = checkAnalyzerService();
$result['pypo'] = checkPlayoutService();
$result['liquidsoap'] = checkLiquidsoapService();
$result['celery'] = checkCeleryService();
$result['api'] = checkApiService();
}
return $result;
}
/**
* Check the database configuration by fetching a connection from Propel.
*
* @return bool true if a connection is made to the database
*/
function checkDatabaseConfiguration()
{
configureDatabase();
try {
// Try to establish a database connection. If something goes
// wrong, the database is improperly configured
Propel::getConnection();
Propel::close();
} catch (Exception $exc) {
Logging::error($exc->getMessage());
return false;
}
return true;
}
/**
* Initialize Propel to configure the Airtime database.
*/
function configureDatabase()
{
Propel::init(PROPEL_CONFIG_FILEPATH);
}
/**
* Check that we can connect to RabbitMQ.
*
* @return true if the RabbitMQ connection can be established
*/
function checkRMQConnection()
{
$config = Config::getConfig();
try {
$conn = new AMQPStreamConnection(
$config['rabbitmq']['host'],
$config['rabbitmq']['port'],
$config['rabbitmq']['user'],
$config['rabbitmq']['password'],
$config['rabbitmq']['vhost']
);
return isset($conn);
} catch (AMQPRuntimeException $exc) {
Logging::error($exc->getMessage());
return false;
}
}
/**
* Check if airtime-analyzer is currently running.
*
* @return bool true if airtime-analyzer is running
*/
function checkAnalyzerService()
{
exec('systemctl is-active libretime-analyzer --quiet', $out, $status);
return $status == 0;
}
/**
* Check if libretime-playout is currently running.
*
* @return bool true if libretime-playout is running
*/
function checkPlayoutService()
{
exec('systemctl is-active libretime-playout --quiet', $out, $status);
return $status == 0;
}
/**
* Check if libretime-liquidsoap is currently running.
*
* @return bool true if libretime-liquidsoap is running
*/
function checkLiquidsoapService()
{
exec('systemctl is-active libretime-liquidsoap --quiet', $out, $status);
return $status == 0;
}
/**
* Check if libretime-worker is currently running.
*
* @return bool true if libretime-worker is running
*/
function checkCeleryService()
{
exec('systemctl is-active libretime-worker --quiet', $out, $status);
return $status == 0;
}
/**
* Check if libretime-api is currently running.
*
* @return bool true if libretime-api is running
*/
function checkApiService()
{
exec('systemctl status libretime-api --quiet', $out, $status);
return $status == 0;
}