Skip to content

Commit e1f492c

Browse files
committed
Updated phpstorm-stubs
1 parent f5a3df6 commit e1f492c

File tree

10 files changed

+112
-43
lines changed

10 files changed

+112
-43
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--- SimpleXML/SimpleXML.stub 2020-07-17 13:50:32.000000000 +0200
2+
+++ SimpleXML/SimpleXML2.stub 2020-07-17 13:51:37.000000000 +0200
3+
@@ -6,7 +6,7 @@
4+
* Represents an element in an XML document.
5+
* @link https://php.net/manual/en/class.simplexmlelement.php
6+
*/
7+
-class SimpleXMLElement implements Traversable, ArrayAccess, Countable, Iterator {
8+
+class SimpleXMLElement implements Traversable, ArrayAccess, Countable {
9+
10+
/**
11+
* Creates a new SimpleXMLElement object
12+
@@ -244,41 +244,6 @@
13+
* @return void
14+
*/
15+
private function offsetUnset ($offset) {}
16+
-
17+
- /**
18+
- * Rewind to the first element
19+
- * @link https://php.net/manual/en/simplexmliterator.rewind.php
20+
- * @return void No value is returned.
21+
- */
22+
- private function rewind () {}
23+
-
24+
- /**
25+
- * Check whether the current element is valid
26+
- * @link https://php.net/manual/en/simplexmliterator.valid.php
27+
- * @return bool <b>TRUE</b> if the current element is valid, otherwise <b>FALSE</b>
28+
- */
29+
- private function valid () {}
30+
-
31+
- /**
32+
- * Returns the current element
33+
- * @link https://php.net/manual/en/simplexmliterator.current.php
34+
- * @return static|null the current element as a <b>SimpleXMLElement</b> object or <b>NULL</b> on failure.
35+
- */
36+
- private function current () {}
37+
-
38+
- /**
39+
- * Return current key
40+
- * @link https://php.net/manual/en/simplexmliterator.key.php
41+
- * @return string|false the XML tag name of the element referenced by the current <b>SimpleXMLIterator</b> object or <b>FALSE</b>
42+
- */
43+
- private function key () {}
44+
-
45+
- /**
46+
- * Move to next element
47+
- * @link https://php.net/manual/en/simplexmliterator.next.php
48+
- * @return void No value is returned.
49+
- */
50+
- private function next () {}
51+
}
52+
53+
/**

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"hoa/exception": "^1.0",
1313
"hoa/regex": "1.17.01.13",
1414
"jean85/pretty-package-versions": "^1.0.3",
15-
"jetbrains/phpstorm-stubs": "dev-master#11e2d07705b8b7063a984f49a27d8c3120288e31",
15+
"jetbrains/phpstorm-stubs": "dev-master#d4db4b4834d8a9c8fc3c0aa6dc3c9bae723bbc9c",
1616
"nette/bootstrap": "^3.0",
1717
"nette/di": "dev-master#4e1e2d1747d61b5da5d84ba77a28b726b6d7744c",
1818
"nette/finder": "^2.5",
@@ -21,7 +21,7 @@
2121
"nette/utils": "^3.1.1",
2222
"nikic/php-parser": "dev-master",
2323
"ondram/ci-detector": "^3.4.0",
24-
"ondrejmirtes/better-reflection": "^4.3.17",
24+
"ondrejmirtes/better-reflection": "4.3.18",
2525
"phpdocumentor/type-resolver": "1.0.1",
2626
"phpstan/phpdoc-parser": "^0.4.8",
2727
"react/child-process": "^0.6.1",

src/Reflection/Annotations/AnnotationsMethodsClassReflectionExtension.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,26 @@
55
use PHPStan\Reflection\ClassReflection;
66
use PHPStan\Reflection\MethodReflection;
77
use PHPStan\Reflection\MethodsClassReflectionExtension;
8-
use PHPStan\Type\FileTypeMapper;
8+
use PHPStan\Type\Generic\TemplateTypeHelper;
99

1010
class AnnotationsMethodsClassReflectionExtension implements MethodsClassReflectionExtension
1111
{
1212

13-
private FileTypeMapper $fileTypeMapper;
14-
1513
/** @var MethodReflection[][] */
1614
private array $methods = [];
1715

18-
public function __construct(FileTypeMapper $fileTypeMapper)
19-
{
20-
$this->fileTypeMapper = $fileTypeMapper;
21-
}
22-
2316
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
2417
{
25-
if (!isset($this->methods[$classReflection->getName()])) {
26-
$this->methods[$classReflection->getName()] = $this->createMethods($classReflection, $classReflection);
18+
if (!isset($this->methods[$classReflection->getCacheKey()])) {
19+
$this->methods[$classReflection->getCacheKey()] = $this->createMethods($classReflection, $classReflection);
2720
}
2821

29-
return isset($this->methods[$classReflection->getName()][$methodName]);
22+
return isset($this->methods[$classReflection->getCacheKey()][$methodName]);
3023
}
3124

3225
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
3326
{
34-
return $this->methods[$classReflection->getName()][$methodName];
27+
return $this->methods[$classReflection->getCacheKey()][$methodName];
3528
}
3629

3730
/**
@@ -68,8 +61,8 @@ private function createMethods(
6861
return $methods;
6962
}
7063

71-
$resolvedPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc($fileName, $classReflection->getName(), null, null, $docComment);
72-
foreach ($resolvedPhpDoc->getMethodTags() as $methodName => $methodTag) {
64+
$methodTags = $classReflection->getMethodTags();
65+
foreach ($methodTags as $methodName => $methodTag) {
7366
$parameters = [];
7467
foreach ($methodTag->getParameters() as $parameterName => $parameterTag) {
7568
$parameters[] = new AnnotationsMethodParameterReflection(
@@ -85,7 +78,10 @@ private function createMethods(
8578
$methods[$methodName] = new AnnotationMethodReflection(
8679
$methodName,
8780
$declaringClass,
88-
$methodTag->getReturnType(),
81+
TemplateTypeHelper::resolveTemplateTypes(
82+
$methodTag->getReturnType(),
83+
$classReflection->getActiveTemplateTypeMap()
84+
),
8985
$parameters,
9086
$methodTag->isStatic(),
9187
$this->detectMethodVariadic($parameters)

src/Reflection/Annotations/AnnotationsPropertiesClassReflectionExtension.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,26 @@
55
use PHPStan\Reflection\ClassReflection;
66
use PHPStan\Reflection\PropertiesClassReflectionExtension;
77
use PHPStan\Reflection\PropertyReflection;
8-
use PHPStan\Type\FileTypeMapper;
8+
use PHPStan\Type\Generic\TemplateTypeHelper;
99

1010
class AnnotationsPropertiesClassReflectionExtension implements PropertiesClassReflectionExtension
1111
{
1212

13-
private \PHPStan\Type\FileTypeMapper $fileTypeMapper;
14-
1513
/** @var \PHPStan\Reflection\PropertyReflection[][] */
1614
private array $properties = [];
1715

18-
public function __construct(FileTypeMapper $fileTypeMapper)
19-
{
20-
$this->fileTypeMapper = $fileTypeMapper;
21-
}
22-
2316
public function hasProperty(ClassReflection $classReflection, string $propertyName): bool
2417
{
25-
if (!isset($this->properties[$classReflection->getName()])) {
26-
$this->properties[$classReflection->getName()] = $this->createProperties($classReflection, $classReflection);
18+
if (!isset($this->properties[$classReflection->getCacheKey()])) {
19+
$this->properties[$classReflection->getCacheKey()] = $this->createProperties($classReflection, $classReflection);
2720
}
2821

29-
return isset($this->properties[$classReflection->getName()][$propertyName]);
22+
return isset($this->properties[$classReflection->getCacheKey()][$propertyName]);
3023
}
3124

3225
public function getProperty(ClassReflection $classReflection, string $propertyName): PropertyReflection
3326
{
34-
return $this->properties[$classReflection->getName()][$propertyName];
27+
return $this->properties[$classReflection->getCacheKey()][$propertyName];
3528
}
3629

3730
/**
@@ -69,11 +62,14 @@ private function createProperties(
6962
return $properties;
7063
}
7164

72-
$resolvedPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc($fileName, $classReflection->getName(), null, null, $docComment);
73-
foreach ($resolvedPhpDoc->getPropertyTags() as $propertyName => $propertyTag) {
65+
$propertyTags = $classReflection->getPropertyTags();
66+
foreach ($propertyTags as $propertyName => $propertyTag) {
7467
$properties[$propertyName] = new AnnotationPropertyReflection(
7568
$declaringClass,
76-
$propertyTag->getType(),
69+
TemplateTypeHelper::resolveTemplateTypes(
70+
$propertyTag->getType(),
71+
$classReflection->getActiveTemplateTypeMap()
72+
),
7773
$propertyTag->isReadable(),
7874
$propertyTag->isWritable()
7975
);

src/Reflection/ClassReflection.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use PHPStan\PhpDoc\ResolvedPhpDocBlock;
66
use PHPStan\PhpDoc\Tag\ExtendsTag;
77
use PHPStan\PhpDoc\Tag\ImplementsTag;
8+
use PHPStan\PhpDoc\Tag\MethodTag;
89
use PHPStan\PhpDoc\Tag\MixinTag;
10+
use PHPStan\PhpDoc\Tag\PropertyTag;
911
use PHPStan\PhpDoc\Tag\TemplateTag;
1012
use PHPStan\Reflection\Php\PhpClassReflectionExtension;
1113
use PHPStan\Reflection\Php\PhpPropertyReflection;
@@ -979,6 +981,32 @@ public function getMixinTags(): array
979981
return $resolvedPhpDoc->getMixinTags();
980982
}
981983

984+
/**
985+
* @return array<PropertyTag>
986+
*/
987+
public function getPropertyTags(): array
988+
{
989+
$resolvedPhpDoc = $this->getResolvedPhpDoc();
990+
if ($resolvedPhpDoc === null) {
991+
return [];
992+
}
993+
994+
return $resolvedPhpDoc->getPropertyTags();
995+
}
996+
997+
/**
998+
* @return array<MethodTag>
999+
*/
1000+
public function getMethodTags(): array
1001+
{
1002+
$resolvedPhpDoc = $this->getResolvedPhpDoc();
1003+
if ($resolvedPhpDoc === null) {
1004+
return [];
1005+
}
1006+
1007+
return $resolvedPhpDoc->getMethodTags();
1008+
}
1009+
9821010
/**
9831011
* @return array<Type>
9841012
*/

src/Testing/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ public function create(
332332

333333
};
334334
$phpDocInheritanceResolver = new PhpDocInheritanceResolver($fileTypeMapper);
335-
$annotationsMethodsClassReflectionExtension = new AnnotationsMethodsClassReflectionExtension($fileTypeMapper);
336-
$annotationsPropertiesClassReflectionExtension = new AnnotationsPropertiesClassReflectionExtension($fileTypeMapper);
335+
$annotationsMethodsClassReflectionExtension = new AnnotationsMethodsClassReflectionExtension();
336+
$annotationsPropertiesClassReflectionExtension = new AnnotationsPropertiesClassReflectionExtension();
337337
$signatureMapProvider = self::getContainer()->getByType(SignatureMapProvider::class);
338338
$methodReflectionFactory->reflectionProvider = $actualReflectionProvider;
339339
$phpExtension = new PhpClassReflectionExtension(self::getContainer()->getByType(ScopeFactory::class), self::getContainer()->getByType(NodeScopeResolver::class), $methodReflectionFactory, $phpDocInheritanceResolver, $annotationsMethodsClassReflectionExtension, $annotationsPropertiesClassReflectionExtension, $signatureMapProvider, $parser, self::getContainer()->getByType(StubPhpDocProvider::class), $actualReflectionProvider, true, []);

src/Type/Php/FilterVarDynamicReturnTypeExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ public function __construct(ReflectionProvider $reflectionProvider)
6060
$this->getConstant('FILTER_VALIDATE_REGEXP') => $stringType,
6161
$this->getConstant('FILTER_VALIDATE_URL') => $stringType,
6262
$this->getConstant('FILTER_SANITIZE_MAGIC_QUOTES') => $stringType,
63-
$this->getConstant('FILTER_SANITIZE_ADD_SLASHES') => $stringType,
6463
];
6564

65+
if ($this->reflectionProvider->hasConstant(new Node\Name('FILTER_SANITIZE_ADD_SLASHES'), null)) {
66+
$this->filterTypeMap[$this->getConstant('FILTER_SANITIZE_ADD_SLASHES')] = $stringType;
67+
}
68+
6669
$this->flagsString = new ConstantStringType('flags');
6770
}
6871

stubs/ReflectionClass.stub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/**
44
* @template-covariant T of object
5+
* @property-read class-string<T> $name
56
*/
67
class ReflectionClass
78
{

tests/PHPStan/Analyser/data/generics.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,6 @@ function () {
11021102
class GenericReflectionClass extends \ReflectionClass
11031103
{
11041104

1105-
public $name;
1106-
11071105
public function newInstanceWithoutConstructor()
11081106
{
11091107
return parent::newInstanceWithoutConstructor();
@@ -1117,8 +1115,6 @@ public function newInstanceWithoutConstructor()
11171115
class SpecificReflectionClass extends \ReflectionClass
11181116
{
11191117

1120-
public $name;
1121-
11221118
public function newInstanceWithoutConstructor()
11231119
{
11241120
return parent::newInstanceWithoutConstructor();

tests/PHPStan/Rules/Variables/NullCoalesceRuleTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ public function testCoalesceRule(): void
8888
'Static property CoalesceRule\FooCoalesce::$staticString (string) on left side of ?? is not nullable.',
8989
131,
9090
],
91-
[
92-
'Property ReflectionClass<object>::$name (class-string<object>) on left side of ?? is not nullable.',
93-
136,
94-
],
9591
]);
9692
}
9793

0 commit comments

Comments
 (0)