forked from hhvm/hhast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunctionNamingLintError.hack
43 lines (39 loc) · 1 KB
/
FunctionNamingLintError.hack
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
/*
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
namespace Facebook\HHAST;
use type Facebook\HHAST\{FunctionDeclarationHeader, NameToken};
final class FunctionNamingLintError extends ASTLintError {
private string $old;
private string $new;
<<__Override>>
public function __construct(
FunctionNamingLinter $linter,
string $description,
?string $ns,
?string $class,
string $old,
string $new,
FunctionDeclarationHeader $node,
) {
$ns = $ns === null ? '' : $ns.'\\';
if ($class === null) {
$this->old = $ns.$old;
$this->new = $ns.$new;
} else {
$this->old = $ns.$class.'::'.$old;
$this->new = $ns.$class.'::'.$new;
}
parent::__construct(
$linter,
$description,
$node,
() ==> $node->withName(($node->getName() as NameToken)->withText($new)),
);
}
}