Skip to content

Commit e52c390

Browse files
committed
Merge remote-tracking branch 'remotes/origin/fixtures'
2 parents fc41ed5 + 8a34418 commit e52c390

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

tests/Core/CodeElement/CodeElementDetectorTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
namespace Gskema\TypeSniff\Core\CodeElement;
44

5+
use Gskema\TypeSniff\Core\CodeElement\Element\InterfaceConstElement;
6+
use Gskema\TypeSniff\Core\CodeElement\Element\InterfaceElement;
7+
use Gskema\TypeSniff\Core\CodeElement\Element\InterfaceMethodElement;
8+
use Gskema\TypeSniff\Core\CodeElement\Element\TraitElement;
9+
use Gskema\TypeSniff\Core\CodeElement\Element\TraitMethodElement;
10+
use Gskema\TypeSniff\Core\CodeElement\Element\TraitPropElement;
511
use Gskema\TypeSniff\Core\Type\Common\BoolType;
612
use Gskema\TypeSniff\Core\Type\Common\FloatType;
13+
use Gskema\TypeSniff\Core\Type\Common\VoidType;
714
use PHP_CodeSniffer\Config;
815
use PHP_CodeSniffer\Files\LocalFile;
916
use PHP_CodeSniffer\Ruleset;
@@ -317,6 +324,46 @@ public function dataDetectFromTokens(): array
317324
]
318325
];
319326

327+
// #3
328+
$dataSets[] = [
329+
__DIR__.'/fixtures/TestInterface0.php.txt',
330+
[
331+
new FileElement(1, new UndefinedDocBlock(), __DIR__.'/fixtures/TestInterface0.php.txt'),
332+
new InterfaceElement(3, new UndefinedDocBlock(), 'TestInterface0'),
333+
new InterfaceConstElement(5, new UndefinedDocBlock(), 'TestInterface0', 'C1', new IntType()),
334+
new InterfaceMethodElement(
335+
new UndefinedDocBlock(),
336+
'TestInterface0',
337+
new FunctionSignature(7, 'func1', [], new VoidType(), 7),
338+
null
339+
),
340+
]
341+
];
342+
343+
// #4
344+
$dataSets[] = [
345+
__DIR__.'/fixtures/TestTrait0.php.txt',
346+
[
347+
new FileElement(1, new UndefinedDocBlock(), __DIR__.'/fixtures/TestTrait0.php.txt'),
348+
new TraitElement(3, new UndefinedDocBlock(), 'TestTrait0'),
349+
new TraitPropElement(5, new UndefinedDocBlock(), 'TestTrait0', 'prop1', new IntType()),
350+
new TraitMethodElement(
351+
new UndefinedDocBlock(),
352+
'TestTrait0',
353+
new FunctionSignature(
354+
7,
355+
'func1',
356+
[
357+
new FunctionParam(7, 'arg1', new IntType())
358+
],
359+
new IntType(),
360+
7
361+
),
362+
null
363+
),
364+
]
365+
];
366+
320367
return $dataSets;
321368
}
322369

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
interface TestInterface0
4+
{
5+
const C1 = 1;
6+
7+
public function func1(): void;
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
trait TestTrait0
4+
{
5+
public $prop1 = 1;
6+
7+
public function func1(int $arg1): int
8+
{
9+
}
10+
}

0 commit comments

Comments
 (0)