-
Notifications
You must be signed in to change notification settings - Fork 159
[New Rule] Implement sniff for functions PHPDoc formatting #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
<?php
namespace Foo\Bar;
interface TestInterface
{
/**
* Test Function with nice Doc
*
* @param $int
* @param $string
* @return string
*/
public function test($int, $string);
}
class Test implements TestInterface
{
/**
* @inheritDoc
*/
public function test($int, $string)
{
return '';
}
/**
* Test Function with nice Doc.
*
* @param $string
* @return string
*/
public function test2($string)
{
return '';
}
}
class TestExtend extends Test implements TestInterface
{
/**
* Test Function with a better Function.
*
* {@inheritDoc}
*/
public function test($int, $string)
{
return '';
}
/**
* Sniff will find doc error there because you define inherit wrong.
* @inheritDoc
*/
public function test2($string)
{
return '';
}
} |
@larsroettig, few comments to your example:
|
Test should NOT fail. <?php
class EverythingIsGoodHere
{
/**
* @param string $arg1
* @param bool $arg2
*/
private function missingArgumentTypeSoParamsNeedToBeAdded($arg1, $arg2): bool
{
}
/**
* @return bool
*/
private function presentArgumentTypeSoAnnotationNotNeededButMissingReturnType(string $arg1, bool $arg2)
{
}
private function presentArgumentAndReturnTypes(string $arg1, bool $arg2): bool
{
}
/**
* @throws Exception
*/
private function throwsAnException(): void
{
throw new \Exception();
}
/**
* We have an additional wonderful message here.
*
* @return void
*/
private function presentGoodDescription(string $arg1, bool $arg2)
{
}
} Test should fail: <?php
class EverythingIsBadHere
{
/**
* @param bool $arg2
* @param string $arg1
*/
private function wrongParamOrder($arg1, $arg2): bool
{
}
/**
* @param bool $arg2
*/
private function missingParamAnnotation($arg1, $arg2): bool
{
}
private function missingArgumentAnnotations($arg1, $arg2): bool
{
}
/**
* @param string $arg1
* @param bool $arg2
* @param bool $arg2
*/
private function paramDuplication($arg1, $arg2): bool
{
}
/**
* @inheritdoc
*/
private function inheritDocShouldNotBeUsed(string $arg1, bool $arg2)
{
}
/**
* @param $arg1
* @param $arg2
*/
private function missingParamType($arg1, $arg2): bool
{
}
/**
* Useless description
*/
private function uselessDescription(string $arg1, bool $arg2): bool
{
}
/**
*
*/
private function dockBlockIsEmpty(string $arg1, bool $arg2): bool
{
}
/**
*
*
* @param string $arg1
* @param bool $arg2
*
*/
private function redundantLines($arg1, $arg2): bool
{
}
} @Vinai would appreciate much if you could review these examples. |
…-coding-standard-258 [Imported] AC-1100 Catch badly put newlines in LESS files
Rule
PHPDoc formatting for functions and methods.
Acceptance Criteria:
The text was updated successfully, but these errors were encountered: