Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
[CodingStandard] fixer temp
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 15, 2017
1 parent e791885 commit 93d4622
Show file tree
Hide file tree
Showing 17 changed files with 97 additions and 37 deletions.
8 changes: 2 additions & 6 deletions easy-coding-standard.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
checkers:
# Classes
- PHP_CodeSniffer\Standards\Generic\Sniffs\Classes\DuplicateClassNameSniff
- PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff
- PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\LowercaseClassKeywordsSniff
- Symplify\CodingStandard\Fixer\Property\ArrayPropertyDefaultValueFixer

# Code Analysis
- PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff
Expand Down Expand Up @@ -271,4 +267,4 @@ parameters:

Symplify\CodingStandard\Sniffs\Classes\EqualInterfaceImplementationSniff:
- packages/EasyCodingStandard/packages/SniffRunner/src/Application/SniffFileProcessor.php
- packages/EasyCodingStandard/packages/FixerRunner/src/Application/FixerFileProcessor.php
- packages/EasyCodingStandard/packages/FixerRunner/src/Application/FixerFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class ClassWrapper
/**
* @var mixed[]
*/
private $tokens;
private $tokens = [];

/**
* @var MethodWrapper[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ final class DocBlockWrapper
private $indentationType = 'spaces';

/**
* @var string[]
* @var mixed[]
*/
private $tokens;
private $tokens = [];

/**
* @var Fixer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ final class MethodWrapper
/**
* @var ParameterWrapper[]
*/
private $parameters;
private $parameters = [];

/**
* @var mixed[]
*/
private $methodToken;
private $methodToken = [];

/**
* @var int
Expand All @@ -47,7 +47,7 @@ final class MethodWrapper
/**
* @var mixed[]
*/
private $tokens;
private $tokens = [];

private function __construct(File $file, int $position)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class ParameterWrapper
/**
* @var mixed[]
*/
private $tokens;
private $tokens = [];

private function __construct(File $file, int $position)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ final class PropertyWrapper
/**
* @var mixed[]
*/
private $propertyToken;
private $propertyToken = [];

/**
* @var mixed[]
*/
private $tokens;
private $tokens = [];

/**
* @var ?int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private function isArrayPropertyDocComment(Token $token): bool

private function addDefaultValueForArrayProperty(Tokens $tokens, int $semicolonPosition): void
{
// todo: prepare nicer api
$tokens->insertAt($semicolonPosition, new Token([CT::T_ARRAY_SQUARE_BRACE_CLOSE, ']']));
$tokens->insertAt($semicolonPosition, new Token([CT::T_ARRAY_SQUARE_BRACE_OPEN, '[']));
$tokens->insertAt($semicolonPosition, new Token([T_WHITESPACE, ' ']));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class ClassMetrics
/**
* @var mixed[]
*/
private $tokens;
private $tokens = [];

public function __construct(File $file, int $classPosition)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class NewClassSniff implements Sniff
/**
* @var mixed[]
*/
private $tokens;
private $tokens = [];

/**
* @return int[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class ArrayPropertyDefaultValueFixerTest extends AbstractFixerTestCase
/**
* @dataProvider provideFixCases()
*/
public function testFix(string $expected, string $input)
public function testFix(string $expected, string $input): void
{
$this->doTest($expected, $input);
}
Expand All @@ -28,24 +28,12 @@ public function provideFixCases(): array
{
return [
[
'<?php
class SomeClass
{
/**
* @var int[]
*/
public $property = [];
}',
'<?php
class SomeClass
{
/**
* @var int[]
*/
public $property;
}',
file_get_contents(__DIR__ . '/fixed/fixed.php.inc'),
file_get_contents(__DIR__ . '/wrong/wrong.php.inc')
],
[
file_get_contents(__DIR__ . '/fixed/fixed2.php.inc'),
file_get_contents(__DIR__ . '/wrong/wrong2.php.inc')
]
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class SomeClass
{
/**
* @var int[]
*/
public $property = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class SomeClass
{
/**
* @var int[]
*/
public static $property = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class SomeClass
{
/**
* @var int[]
*/
public $property;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class SomeClass
{
/**
* @var int[]
*/
public static $property;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class TokenDispatcher
/**
* @var Sniff[][]
*/
private $tokenListeners;
private $tokenListeners = [];

public function __construct(Skipper $skipper)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php declare(strict_types=1);

namespace Symplify\SymfonyEventDispatcher\Tests\Adapter\Nette\NetteEvent;

use Symfony\Component\EventDispatcher\Event;

final class EventStateStorage
{
/**
* @var Event[]
*/
private $storage = [];

public function addEventState(string $event, Event $state): void
{
$this->storage[$event] = $state;
}

/**
* @return bool|Event
*/
public function getEventState(string $event)
{
if (isset($this->storage[$event])) {
return $this->storage[$event];
}

return false;
}
}
9 changes: 9 additions & 0 deletions src/UndefinedArray.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class UndefinedArray
{
/**
* @var int[]
*/
public $array = [];
}

0 comments on commit 93d4622

Please sign in to comment.