From e6bbc19a8ce4bdec71371bb5808e0dbd19034f8a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 23:41:20 +0200 Subject: [PATCH] [rector] Enable type declaration set for rector (#23) Please merge these changes into the rector-enable-type-declaration branch to fix coding standard violations. Co-authored-by: rector --- src/CodeClone.php | 2 +- .../ApproximateCloneDetectingSuffixTree.php | 18 ++++++----------- .../Strategy/SuffixTree/CloneInfo.php | 4 +--- src/Detector/Strategy/SuffixTree/PairList.php | 8 +++----- src/Detector/Strategy/SuffixTree/Sentinel.php | 2 +- .../Strategy/SuffixTree/SuffixTree.php | 16 ++++----------- .../SuffixTree/SuffixTreeHashTable.php | 20 +++++++------------ 7 files changed, 23 insertions(+), 47 deletions(-) diff --git a/src/CodeClone.php b/src/CodeClone.php index 4d4461ad..61b6cd4a 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 82f5f929..a552beeb 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 05507d2c..e9ffbc93 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 cf0bdc2f..196c3177 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 f679551c..ac29fa60 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 728690c7..68dd45bb 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 98eedfc1..cc732ce8 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