-
-
Notifications
You must be signed in to change notification settings - Fork 448
Expand file tree
/
Copy pathNotifier.php
More file actions
53 lines (42 loc) · 1.59 KB
/
Copy pathNotifier.php
File metadata and controls
53 lines (42 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace Rector\Console;
use Rector\Exception\Configuration\InvalidConfigurationException;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
final class Notifier
{
public static function notifyNotSuitableMethodForPHP74(string $calledMethod): void
{
if (PHP_VERSION_ID >= 80000) {
return;
}
$message = sprintf(
'The "%s()" method uses named arguments. Its suitable for PHP 8.0+. In lower PHP versions, use "withSets([...])" method instead',
$calledMethod
);
$symfonyStyle = new SymfonyStyle(new ArgvInput(), new ConsoleOutput());
$symfonyStyle->warning($message);
sleep(3);
}
public static function notifyDeprecatedPhpSet(string $set): void
{
$message = sprintf(
'The per-version PHP set "%s" is deprecated. Use "withPhpSets()" or "withPhpLevel()" instead, '
. 'they pick the rules by your PHP version automatically.',
$set
);
$symfonyStyle = new SymfonyStyle(new ArgvInput(), new ConsoleOutput());
$symfonyStyle->warning($message);
}
public static function errorWithPhpSetsNotSuitableForPHP74AndLower(): void
{
if (PHP_VERSION_ID >= 80000) {
return;
}
throw new InvalidConfigurationException(
'The "->withPhpSets()" method uses named arguments. Its suitable for PHP 8.0+. Use "->withPhpLevel()" in lower PHP versions instead.'
);
}
}