1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Add suppressions for using a deprecated property

This commit is contained in:
Alies Lapatsin 2023-01-16 23:13:52 +01:00
parent 9271946dd6
commit 76c1e413a1
2 changed files with 15 additions and 6 deletions

View File

@ -306,7 +306,7 @@ final class Psalm
? $options['find-references-to']
: null;
self::configureShepherd($options, $plugins);
self::configureShepherd($config, $options, $plugins);
if (isset($options['clear-cache'])) {
self::clearCache($config);
@ -1164,14 +1164,16 @@ final class Psalm
$plugins[] = Path::canonicalize(__DIR__ . '/../../Plugin/Shepherd.php');
$custom_shepherd_endpoint = $options['shepherd'] ?? getenv('PSALM_SHEPHERD');
/** @psalm-suppress MixedAssignment */
$custom_shepherd_endpoint = ($options['shepherd'] ?? getenv('PSALM_SHEPHERD'));
if (is_string($custom_shepherd_endpoint) && strlen($custom_shepherd_endpoint) > 2) {
if (parse_url($custom_shepherd_endpoint, PHP_URL_SCHEME) === null) {
$custom_shepherd_endpoint = 'https://' . $custom_shepherd_endpoint;
}
$config->shepherd_endpoint = $custom_shepherd_endpoint;
/** @psalm-suppress DeprecatedProperty */
$config->shepherd_host = str_replace('/hooks/psalm', '', $custom_shepherd_endpoint);
$config->shepherd_endpoint = $custom_shepherd_endpoint;
return;
}
@ -1179,14 +1181,14 @@ final class Psalm
// Legacy part, will be removed in Psalm 6
$custom_shepherd_host = getenv('PSALM_SHEPHERD_HOST');
$is_valid_custom_shepherd_endpoint = is_string($custom_shepherd_host);
if ($is_valid_custom_shepherd_endpoint) {
if (is_string($custom_shepherd_host)) {
if (parse_url($custom_shepherd_host, PHP_URL_SCHEME) === null) {
$custom_shepherd_host = 'https://' . $custom_shepherd_host;
}
$config->shepherd_endpoint = $custom_shepherd_host . '/hooks/psalm';
/** @psalm-suppress DeprecatedProperty */
$config->shepherd_host = $custom_shepherd_host;
$config->shepherd_endpoint = $custom_shepherd_host . '/hooks/psalm';
}
}

View File

@ -80,6 +80,13 @@ final class Shepherd implements AfterAnalysisInterface
$payload = json_encode($data, JSON_THROW_ON_ERROR);
/** @psalm-suppress DeprecatedProperty */
$base_address = $codebase->config->shepherd_host;
if (parse_url($base_address, PHP_URL_SCHEME) === null) {
$base_address = 'https://' . $base_address;
}
// Prepare new cURL resource
$ch = curl_init($base_address . '/hooks/psalm');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);