Skip to content

Commit e37d966

Browse files
committed
add editorconfig to keep tabs tabs
1 parent 529d436 commit e37d966

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

Diff for: .editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.php]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = tab
9+
indent_size = 4

Diff for: src/Ast/BaseNode.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ abstract class BaseNode implements Node
88
/** @var array<string, mixed> */
99
private $attributes = [];
1010

11-
/**
12-
* @param mixed $value
13-
*/
11+
/**
12+
* @param mixed $value
13+
*/
1414
public function setAttribute(string $key, $value): void
1515
{
1616
$this->attributes[$key] = $value;

Diff for: tests/PHPStan/Ast/Attributes/AttributesTest.php

+27-11
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,47 @@
22

33
namespace PHPStan\PhpDocParser\Ast\Attributes;
44

5+
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
56
use PHPStan\PhpDocParser\Lexer\Lexer;
67
use PHPStan\PhpDocParser\Parser\ConstExprParser;
78
use PHPStan\PhpDocParser\Parser\PhpDocParser;
9+
use PHPStan\PhpDocParser\Parser\TokenIterator;
810
use PHPStan\PhpDocParser\Parser\TypeParser;
911
use PHPUnit\Framework\TestCase;
1012

1113
final class AttributesTest extends TestCase
1214
{
1315

14-
/**
15-
* @var Lexer
16-
*/
17-
private $lexer;
18-
19-
/**
20-
* @var PhpDocParser
21-
*/
22-
private $phpDocParser;
16+
/** @var PhpDocNode */
17+
private $phpDocNode;
2318

2419
protected function setUp(): void
2520
{
2621
parent::setUp();
27-
$this->lexer = new Lexer();
22+
$lexer = new Lexer();
2823
$constExprParser = new ConstExprParser();
29-
$this->phpDocParser = new PhpDocParser(new TypeParser($constExprParser), $constExprParser);
24+
$phpDocParser = new PhpDocParser(new TypeParser($constExprParser), $constExprParser);
25+
26+
$input = '/** @var string */';
27+
$tokens = new TokenIterator($lexer->tokenize($input));
28+
$this->phpDocNode = $phpDocParser->parse($tokens);
29+
}
30+
31+
public function testGetAttribute(): void
32+
{
33+
$defaultValue = $this->phpDocNode->getAttribute('unknown_with_default', 100);
34+
$this->assertSame(100, $defaultValue);
35+
36+
$unKnownValue = $this->phpDocNode->getAttribute('unknown');
37+
$this->assertNull($unKnownValue);
38+
}
39+
40+
public function testSetAttribute(): void
41+
{
42+
$this->phpDocNode->setAttribute('key', 'value');
43+
44+
$attributeValue = $this->phpDocNode->getAttribute('key');
45+
$this->assertSame('value', $attributeValue);
3046
}
3147

3248
}

0 commit comments

Comments
 (0)