| Subject |
Details |
| Rector version |
v0.5.20 (invoke vendor/bin/rector --version) |
| PHP version |
PHP 7.2.9 (invoke php -v) |
| Full Command |
rector process lib --set php70 |
Current Behaviour
Existing code:
class ConnectApi
{
/**
* @var Service[]
*/
private static $registry = [];
/**
* register an Service for using.
*
* @param Service $service
*/
public static function register(Service $service)
{
self::$registry[$service->getLabel()] = $service;
}
/**
* find registered Service.
*
* @return Service[]
*/
public static function getRegisteredServices()
{
return self::$registry;
}
}
running this code thru rector with CompleteVarDocTypePropertyRector enabled leads to
diff --git a/lib/dsl_connect/ConnectApi.php b/lib/dsl_connect/ConnectApi.php
index 151d5e7d..7a5b10ea 100644
--- a/lib/dsl_connect/ConnectApi.php
+++ b/lib/dsl_connect/ConnectApi.php
@@ -5,7 +5,7 @@
class ConnectApi
{
/**
- * @var Service[]
+ * @var mixed[]
*/
private static $registry = [];
IMO rector is wrong because it changes a more specialized phpdoc type with a generic one.
It should be able to infer by the already existing setters/getters that Service[] is the correct type
vendor/bin/rector --version)php -v)rector process lib --set php70Current Behaviour
Existing code:
running this code thru rector with
CompleteVarDocTypePropertyRectorenabled leads toIMO rector is wrong because it changes a more specialized phpdoc type with a generic one.
It should be able to infer by the already existing setters/getters that
Service[]is the correct type