Skip to content

Commit

Permalink
Merge branch 'feature/58' into develop
Browse files Browse the repository at this point in the history
Close #58
  • Loading branch information
michalbundyra committed Nov 13, 2019
2 parents 47d48df + 40681d1 commit b58f941
Show file tree
Hide file tree
Showing 12 changed files with 625 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ All notable changes to this project will be documented in this file, in reverse

- [#53](https://github.com/webimpress/coding-standard/pull/53) adds support for use groups in `Namespaces\UnusedUseStatement` sniff

- [#58](https://github.com/webimpress/coding-standard/pull/58) adds property type declaration (PHP 7.4+). The following sniffs are affected:
- `Commenting\PropertyAnnotation` - ensure that type is skipped when detecting the comment before property,
- `Commenting\VariableComment` - add multiple checks to ensure type declaration is consistent with type provided in PHPDoc (`@var` tag). In case type declaration is provided and PHPDoc does not contain any additional information, `@var` tag can be omitted.

### Changed

- [#42](https://github.com/webimpress/coding-standard/pull/42) changes `NamingConventions\ValidVariableName` to require variable names be in strict camelCase. It means two capital letters next to each other are not allowed.
Expand Down
8 changes: 8 additions & 0 deletions src/WebimpressCodingStandard/Helper/AnnotationsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
use function trim;

use const T_ABSTRACT;
use const T_CALLABLE;
use const T_DOC_COMMENT_CLOSE_TAG;
use const T_DOC_COMMENT_STRING;
use const T_DOC_COMMENT_TAG;
use const T_FINAL;
use const T_NS_SEPARATOR;
use const T_NULLABLE;
use const T_PRIVATE;
use const T_PROTECTED;
use const T_PUBLIC;
use const T_STATIC;
use const T_STRING;
use const T_VAR;
use const T_WHITESPACE;

Expand Down Expand Up @@ -61,6 +65,10 @@ private function processAnnotations(File $phpcsFile, int $stackPtr) : void
T_FINAL,
T_WHITESPACE,
T_VAR,
T_STRING,
T_NS_SEPARATOR,
T_NULLABLE,
T_CALLABLE,
];

$tokens = $phpcsFile->getTokens();
Expand Down
5 changes: 4 additions & 1 deletion src/WebimpressCodingStandard/Helper/MethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use const T_DOC_COMMENT_TAG;
use const T_DOC_COMMENT_WHITESPACE;
use const T_INTERFACE;
use const T_VARIABLE;
use const T_WHITESPACE;

/**
Expand Down Expand Up @@ -121,7 +122,9 @@ private function initScope(File $phpcsFile, int $stackPtr) : void

$tokens = $phpcsFile->getTokens();

if ($tokens[$stackPtr]['code'] !== T_DOC_COMMENT_TAG) {
if ($tokens[$stackPtr]['code'] !== T_DOC_COMMENT_TAG
&& $tokens[$stackPtr]['code'] !== T_VARIABLE
) {
$this->methodName = $phpcsFile->getDeclarationName($stackPtr);
$this->isSpecialMethod = $this->methodName === '__construct' || $this->methodName === '__destruct';
}
Expand Down
Loading

0 comments on commit b58f941

Please sign in to comment.