diff --git a/rector.php b/rector.php index 6070321..1cb8628 100644 --- a/rector.php +++ b/rector.php @@ -25,7 +25,7 @@ SetList::CODE_QUALITY, SetList::CODING_STYLE, //SetList::NAMING, - //SetList::TYPE_DECLARATION, + SetList::TYPE_DECLARATION, //SetList::PRIVATIZATION, //SetList::EARLY_RETURN, //SetList::TYPE_DECLARATION, diff --git a/src/CodeClone.php b/src/CodeClone.php index 4d4461a..61b6cd4 100644 --- a/src/CodeClone.php +++ b/src/CodeClone.php @@ -63,7 +63,7 @@ public function lines(string $indent = ''): string $this->lines = implode( '', array_map( - static function (string $line) use ($indent) { + static function (string $line) use ($indent): string { return $indent.$line; }, \array_slice( diff --git a/src/Detector/Strategy/SuffixTree/ApproximateCloneDetectingSuffixTree.php b/src/Detector/Strategy/SuffixTree/ApproximateCloneDetectingSuffixTree.php index 82f5f92..a552bee 100644 --- a/src/Detector/Strategy/SuffixTree/ApproximateCloneDetectingSuffixTree.php +++ b/src/Detector/Strategy/SuffixTree/ApproximateCloneDetectingSuffixTree.php @@ -37,43 +37,37 @@ class ApproximateCloneDetectingSuffixTree extends SuffixTree * * @var int[] */ - private $leafCount = []; + private array $leafCount = []; /** * This is the distance between two entries in the {@link #cloneInfos} map. - * - * @var int */ - private $INDEX_SPREAD = 10; + private int $INDEX_SPREAD = 10; /** * This map stores for each position the relevant clone infos. * * @var array */ - private $cloneInfos = []; + private array $cloneInfos = []; /** * The maximal length of a clone. This influences the size of the * (quadratic) {@link #edBuffer}. - * - * @var int */ - private $MAX_LENGTH = 1024; + private int $MAX_LENGTH = 1024; /** * Buffer used for calculating edit distance. * * @var array */ - private $edBuffer = []; + private array $edBuffer = []; /** * Number of units that must be equal at the start of a clone. - * - * @var int */ - private $headEquality = 10; + private int $headEquality = 10; /** * Create a new suffix tree from a given word. The word given as parameter diff --git a/src/Detector/Strategy/SuffixTree/CloneInfo.php b/src/Detector/Strategy/SuffixTree/CloneInfo.php index 05507d2..e9ffbc9 100644 --- a/src/Detector/Strategy/SuffixTree/CloneInfo.php +++ b/src/Detector/Strategy/SuffixTree/CloneInfo.php @@ -44,10 +44,8 @@ class CloneInfo /** * Number of occurrences of the clone. - * - * @var int */ - private $occurrences; + private int $occurrences; /** Constructor. */ public function __construct(int $length, int $position, int $occurrences, AbstractToken $token, PairList $otherClones) diff --git a/src/Detector/Strategy/SuffixTree/PairList.php b/src/Detector/Strategy/SuffixTree/PairList.php index cf0bdc2..196c317 100644 --- a/src/Detector/Strategy/SuffixTree/PairList.php +++ b/src/Detector/Strategy/SuffixTree/PairList.php @@ -31,24 +31,22 @@ class PairList { /** * The current size. - * - * @var int */ - private $size = 0; + private int $size = 0; /** * The array used for storing the S. * * @var S[] */ - private $firstElements; + private array $firstElements; /** * The array used for storing the T. * * @var T[] */ - private $secondElements; + private array $secondElements; public function __construct(int $initialCapacity) { diff --git a/src/Detector/Strategy/SuffixTree/Sentinel.php b/src/Detector/Strategy/SuffixTree/Sentinel.php index f679551..ac29fa6 100644 --- a/src/Detector/Strategy/SuffixTree/Sentinel.php +++ b/src/Detector/Strategy/SuffixTree/Sentinel.php @@ -22,7 +22,7 @@ class Sentinel extends AbstractToken { /** @var int The hash value used. */ - private $hash; + private int $hash; public function __construct() { diff --git a/src/Detector/Strategy/SuffixTree/SuffixTree.php b/src/Detector/Strategy/SuffixTree/SuffixTree.php index 728690c..68dd45b 100644 --- a/src/Detector/Strategy/SuffixTree/SuffixTree.php +++ b/src/Detector/Strategy/SuffixTree/SuffixTree.php @@ -47,10 +47,8 @@ class SuffixTree { /** * Infinity in this context. - * - * @var int */ - protected $INFTY; + protected int $INFTY; /** * The word we are working on. @@ -91,10 +89,8 @@ class SuffixTree /** * The next node function realized as a hash table. This corresponds to the * g function used in Ukkonen's paper. - * - * @var SuffixTreeHashTable */ - protected $nextNode; + protected \SebastianBergmann\PHPCPD\Detector\Strategy\SuffixTree\SuffixTreeHashTable $nextNode; /** * An array giving for each node the index where the first child will be @@ -130,19 +126,15 @@ class SuffixTree /** * The node we are currently at as a "global" variable (as it is always * passed unchanged). This is called s in Ukkonen's paper. - * - * @var int */ - private $currentNode = 0; + private int $currentNode = 0; /** * Beginning of the word part of the reference pair. This is kept "global" * (in constrast to the end) as this is passed unchanged to all functions. * Ukkonen calls this k. - * - * @var int */ - private $refWordBegin = 0; + private int $refWordBegin = 0; /** * This is the new (or old) explicit state as returned by diff --git a/src/Detector/Strategy/SuffixTree/SuffixTreeHashTable.php b/src/Detector/Strategy/SuffixTree/SuffixTreeHashTable.php index 98eedfc..cc732ce 100644 --- a/src/Detector/Strategy/SuffixTree/SuffixTreeHashTable.php +++ b/src/Detector/Strategy/SuffixTree/SuffixTreeHashTable.php @@ -37,7 +37,7 @@ class SuffixTreeHashTable * * @var int[] */ - private $allowedSizes = [53, 97, 193, 389, 769, 1543, + private array $allowedSizes = [53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843, 50331653, 100663319, 201326611, 402653189, 805306457, 1610612741, ]; @@ -54,42 +54,36 @@ class SuffixTreeHashTable * * @var int[] */ - private $keyNodes; + private array $keyNodes; /** * Storage space for the character part of the key. * * @var array */ - private $keyChars; + private array $keyChars; /** * Storage space for the result node. * * @var int[] */ - private $resultNodes; + private array $resultNodes; /** * Debug info: number of stored nodes. - * - * @var int */ - private $_numStoredNodes = 0; + private int $_numStoredNodes = 0; /** * Debug info: number of calls to find so far. - * - * @var int */ - private $_numFind = 0; + private int $_numFind = 0; /** * Debug info: number of collisions (i.e. wrong finds) during find so far. - * - * @var int */ - private $_numColl = 0; + private int $_numColl = 0; /** * Creates a new hash table for the given number of nodes. Trying to add