From b4dce53e603574eed75874270e049c46405d1545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 15 Oct 2018 15:53:25 +0200 Subject: [PATCH] Adding bitly links for arrays --- .../TypeHints/AbstractMissingTypeHintRule.php | 16 +++++------ .../MissingTypeHintRuleInFunctionTest.php | 28 +++++++++---------- .../MissingTypeHintRuleInMethodTest.php | 4 +-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Rules/TypeHints/AbstractMissingTypeHintRule.php b/src/Rules/TypeHints/AbstractMissingTypeHintRule.php index 59267be..c451e33 100644 --- a/src/Rules/TypeHints/AbstractMissingTypeHintRule.php +++ b/src/Rules/TypeHints/AbstractMissingTypeHintRule.php @@ -178,9 +178,9 @@ private function analyzeWithTypehint(DebugContextInterface $debugContext, Type $ if ($phpTypeHint instanceof ArrayType) { if ($docblockWithoutNullable instanceof MixedType && !$docblockWithoutNullable->isExplicitMixed()) { if ($debugContext instanceof ParameterDebugContext) { - return sprintf('%s type is "array". Please provide a @param annotation to further specify the type of the array. For instance: @param int[] $%s', (string) $debugContext, $debugContext->getName()); + return sprintf('%s type is "array". Please provide a @param annotation to further specify the type of the array. For instance: @param int[] $%s. More info: http://bit.ly/typehintarray', (string) $debugContext, $debugContext->getName()); } else { - return sprintf('%s return type is "array". Please provide a @return annotation to further specify the type of the array. For instance: @return int[]', (string) $debugContext); + return sprintf('%s return type is "array". Please provide a @return annotation to further specify the type of the array. For instance: @return int[]. More info: http://bit.ly/typehintarray', (string) $debugContext); } } else { if ($docblockWithoutNullable instanceof UnionType) { @@ -199,9 +199,9 @@ private function analyzeWithTypehint(DebugContextInterface $debugContext, Type $ if ($docblockTypehint instanceof ArrayType && $docblockTypehint->getKeyType() instanceof MixedType && $docblockTypehint->getItemType() instanceof MixedType && $docblockTypehint->getKeyType()->isExplicitMixed() && $docblockTypehint->getItemType()->isExplicitMixed()) { if ($debugContext instanceof ParameterDebugContext) { - return sprintf('%s type is "array". Please provide a more specific @param annotation in the docblock. For instance: @param int[] $%s. Use @param mixed[] $%s if this is really an array of mixed values.', (string) $debugContext, $debugContext->getName(), $debugContext->getName()); + return sprintf('%s type is "array". Please provide a more specific @param annotation in the docblock. For instance: @param int[] $%s. Use @param mixed[] $%s if this is really an array of mixed values. More info: http://bit.ly/typehintarray', (string) $debugContext, $debugContext->getName(), $debugContext->getName()); } else { - return sprintf('%s return type is "array". Please provide a more specific @return annotation. For instance: @return int[]. Use @return mixed[] if this is really an array of mixed values.', (string) $debugContext); + return sprintf('%s return type is "array". Please provide a more specific @return annotation. For instance: @return int[]. Use @return mixed[] if this is really an array of mixed values. More info: http://bit.ly/typehintarray', (string) $debugContext); } } } @@ -242,9 +242,9 @@ private function analyzeWithoutTypehint(DebugContextInterface $debugContext, Typ { if ($docBlockTypeHints instanceof MixedType && $docBlockTypeHints->isExplicitMixed() === false) { if ($debugContext instanceof ParameterDebugContext) { - return sprintf('%s has no type-hint and no @param annotation.', (string) $debugContext); + return sprintf('%s has no type-hint and no @param annotation. More info: http://bit.ly/usetypehint', (string) $debugContext); } else { - return sprintf('%s there is no return type and no @return annotation.', (string) $debugContext); + return sprintf('%s there is no return type and no @return annotation. More info: http://bit.ly/usetypehint', (string) $debugContext); } } @@ -252,9 +252,9 @@ private function analyzeWithoutTypehint(DebugContextInterface $debugContext, Typ if ($nativeTypehint !== null) { if ($debugContext instanceof ParameterDebugContext) { - return sprintf('%s can be type-hinted to "%s".', (string) $debugContext, $nativeTypehint); + return sprintf('%s can be type-hinted to "%s". More info: http://bit.ly/usetypehint', (string) $debugContext, $nativeTypehint); } else { - return sprintf('%s a "%s" return type can be added.', (string) $debugContext, $nativeTypehint); + return sprintf('%s a "%s" return type can be added. More info: http://bit.ly/usetypehint', (string) $debugContext, $nativeTypehint); } } diff --git a/tests/Rules/TypeHints/MissingTypeHintRuleInFunctionTest.php b/tests/Rules/TypeHints/MissingTypeHintRuleInFunctionTest.php index 1faa599..983a2d0 100644 --- a/tests/Rules/TypeHints/MissingTypeHintRuleInFunctionTest.php +++ b/tests/Rules/TypeHints/MissingTypeHintRuleInFunctionTest.php @@ -19,43 +19,43 @@ public function testCheckCatchedException() $this->analyse([__DIR__ . '/data/typehints.php'], [ [ - 'In function "test", parameter $no_type_hint has no type-hint and no @param annotation.', + 'In function "test", parameter $no_type_hint has no type-hint and no @param annotation. More info: http://bit.ly/usetypehint', 3, ], [ - 'In function "test", there is no return type and no @return annotation.', + 'In function "test", there is no return type and no @return annotation. More info: http://bit.ly/usetypehint', 3, ], [ - 'In function "test2", parameter $type_hintable can be type-hinted to "?string".', + 'In function "test2", parameter $type_hintable can be type-hinted to "?string". More info: http://bit.ly/usetypehint', 11, ], [ - 'In function "test2", a "string" return type can be added.', + 'In function "test2", a "string" return type can be added. More info: http://bit.ly/usetypehint', 11, ], [ - 'In function "test3", parameter $type_hintable can be type-hinted to "\DateTimeInterface".', + 'In function "test3", parameter $type_hintable can be type-hinted to "\DateTimeInterface". More info: http://bit.ly/usetypehint', 19, ], [ - 'In function "test3", a "\DateTimeInterface" return type can be added.', + 'In function "test3", a "\DateTimeInterface" return type can be added. More info: http://bit.ly/usetypehint', 19, ], [ - 'In function "test4", parameter $type_hintable can be type-hinted to "array".', + 'In function "test4", parameter $type_hintable can be type-hinted to "array". More info: http://bit.ly/usetypehint', 27, ], [ - 'In function "test4", a "array" return type can be added.', + 'In function "test4", a "array" return type can be added. More info: http://bit.ly/usetypehint', 27, ], [ - 'In function "test6", parameter $better_type_hint type is "array". Please provide a @param annotation to further specify the type of the array. For instance: @param int[] $better_type_hint', + 'In function "test6", parameter $better_type_hint type is "array". Please provide a @param annotation to further specify the type of the array. For instance: @param int[] $better_type_hint. More info: http://bit.ly/typehintarray', 38, ], [ - 'In function "test6", return type is "array". Please provide a @return annotation to further specify the type of the array. For instance: @return int[]', + 'In function "test6", return type is "array". Please provide a @return annotation to further specify the type of the array. For instance: @return int[]. More info: http://bit.ly/typehintarray', 38, ], [ @@ -67,15 +67,15 @@ public function testCheckCatchedException() 46, ], [ - 'In function "test8", parameter $any_array type is "array". Please provide a more specific @param annotation in the docblock. For instance: @param int[] $any_array. Use @param mixed[] $any_array if this is really an array of mixed values.', + 'In function "test8", parameter $any_array type is "array". Please provide a more specific @param annotation in the docblock. For instance: @param int[] $any_array. Use @param mixed[] $any_array if this is really an array of mixed values. More info: http://bit.ly/typehintarray', 62, ], [ - 'In function "test8", return type is "array". Please provide a more specific @return annotation. For instance: @return int[]. Use @return mixed[] if this is really an array of mixed values.', + 'In function "test8", return type is "array". Please provide a more specific @return annotation. For instance: @return int[]. Use @return mixed[] if this is really an array of mixed values. More info: http://bit.ly/typehintarray', 62, ], [ - 'In function "test10", parameter $id has no type-hint and no @param annotation.', + 'In function "test10", parameter $id has no type-hint and no @param annotation. More info: http://bit.ly/usetypehint', 76, ], [ @@ -83,7 +83,7 @@ public function testCheckCatchedException() 97, ], [ - 'In function "test15", parameter $foo type is "array". Please provide a @param annotation to further specify the type of the array. For instance: @param int[] $foo', + 'In function "test15", parameter $foo type is "array". Please provide a @param annotation to further specify the type of the array. For instance: @param int[] $foo. More info: http://bit.ly/typehintarray', 110, ], [ diff --git a/tests/Rules/TypeHints/MissingTypeHintRuleInMethodTest.php b/tests/Rules/TypeHints/MissingTypeHintRuleInMethodTest.php index 5493dbf..6e2db8c 100644 --- a/tests/Rules/TypeHints/MissingTypeHintRuleInMethodTest.php +++ b/tests/Rules/TypeHints/MissingTypeHintRuleInMethodTest.php @@ -19,11 +19,11 @@ public function testCheckCatchedException() $this->analyse([__DIR__ . '/data/typehints_in_methods.php'], [ [ - 'In method "TheCodingMachine\PHPStan\Rules\TypeHints\data\Foo::test", parameter $no_type_hint has no type-hint and no @param annotation.', + 'In method "TheCodingMachine\PHPStan\Rules\TypeHints\data\Foo::test", parameter $no_type_hint has no type-hint and no @param annotation. More info: http://bit.ly/usetypehint', 9, ], [ - 'In method "TheCodingMachine\PHPStan\Rules\TypeHints\data\BazClass::notInherited", parameter $no_type_hint has no type-hint and no @param annotation.', + 'In method "TheCodingMachine\PHPStan\Rules\TypeHints\data\BazClass::notInherited", parameter $no_type_hint has no type-hint and no @param annotation. More info: http://bit.ly/usetypehint', 37, ],