Skip to content

Commit a8ab101

Browse files
committed
First working version
1 parent 4f5fccb commit a8ab101

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor

composer.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{
22
"name": "phpstan/phpstan-dibi",
33
"description": "Dibi class reflection extension for PHPStan",
4-
"license": ["MIT"]
4+
"license": ["MIT"],
5+
"minimum-stability": "dev",
6+
"prefer-stable": true,
7+
"require": {
8+
"php": "~7.0",
9+
"phpstan/phpstan": "dev-dev#8bb7f234a2",
10+
"dibi/dibi": "~3.0"
11+
},
12+
"autoload": {
13+
"psr-4": {
14+
"PHPStan\\": "src/"
15+
}
16+
}
517
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PHPStan\Reflection\Dibi;
4+
5+
use PHPStan\Reflection\ClassReflection;
6+
use PHPStan\Reflection\MethodReflection;
7+
use PHPStan\Reflection\MethodsClassReflectionExtension;
8+
use PHPStan\Reflection\PropertiesClassReflectionExtension;
9+
use PHPStan\Reflection\PropertyReflection;
10+
11+
class DibiFluentClassReflectionExtension implements MethodsClassReflectionExtension
12+
{
13+
14+
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
15+
{
16+
return $classReflection->getName() === \Dibi\Fluent::class;
17+
}
18+
19+
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
20+
{
21+
return new DibiFluentMethodReflection($methodName, $classReflection);
22+
}
23+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PHPStan\Reflection\Dibi;
4+
5+
use PHPStan\Reflection\ClassReflection;
6+
use PHPStan\Reflection\MethodReflection;
7+
use PHPStan\Type\NullType;
8+
use PHPStan\Type\ObjectType;
9+
use PHPStan\Type\Type;
10+
11+
class DibiFluentMethodReflection implements MethodReflection
12+
{
13+
14+
/** @var string */
15+
private $name;
16+
17+
/** @var \PHPStan\Reflection\ClassReflection */
18+
private $dibiFluent;
19+
20+
public function __construct(string $name, ClassReflection $dibiFluent)
21+
{
22+
$this->name = $name;
23+
$this->dibiFluent = $dibiFluent;
24+
}
25+
26+
public function getName(): string
27+
{
28+
return $this->name;
29+
}
30+
31+
public function getDeclaringClass(): ClassReflection
32+
{
33+
return $this->dibiFluent;
34+
}
35+
36+
public function isStatic(): bool
37+
{
38+
return false;
39+
}
40+
41+
/**
42+
* @return \PHPStan\Reflection\ParameterReflection[]
43+
*/
44+
public function getParameters(): array
45+
{
46+
return [];
47+
}
48+
49+
public function isVariadic(): bool
50+
{
51+
return true;
52+
}
53+
54+
public function isPrivate(): bool
55+
{
56+
return false;
57+
}
58+
59+
public function isPublic(): bool
60+
{
61+
return true;
62+
}
63+
64+
public function getReturnType(): Type
65+
{
66+
return new ObjectType(\Dibi\Fluent::class, false);
67+
}
68+
69+
}

0 commit comments

Comments
 (0)