Skip to content

Commit

Permalink
Enable type declaration set for rector (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrauser authored Oct 12, 2023
1 parent 5571f76 commit 9c1a1c9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 48 deletions.
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/CodeClone.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CloneInfo[]>
*/
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<int[]>
*/
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
Expand Down
4 changes: 1 addition & 3 deletions src/Detector/Strategy/SuffixTree/CloneInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions src/Detector/Strategy/SuffixTree/PairList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Detector/Strategy/SuffixTree/Sentinel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class Sentinel extends AbstractToken
{
/** @var int The hash value used. */
private $hash;
private int $hash;

public function __construct()
{
Expand Down
16 changes: 4 additions & 12 deletions src/Detector/Strategy/SuffixTree/SuffixTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ class SuffixTree
{
/**
* Infinity in this context.
*
* @var int
*/
protected $INFTY;
protected int $INFTY;

/**
* The word we are working on.
Expand Down Expand Up @@ -91,10 +89,8 @@ class SuffixTree
/**
* The next node function realized as a hash table. This corresponds to the
* <em>g</em> 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
Expand Down Expand Up @@ -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 <i>s</i> 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 <em>k</em>.
*
* @var int
*/
private $refWordBegin = 0;
private int $refWordBegin = 0;

/**
* This is the new (or old) explicit state as returned by
Expand Down
20 changes: 7 additions & 13 deletions src/Detector/Strategy/SuffixTree/SuffixTreeHashTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, ];
Expand All @@ -54,42 +54,36 @@ class SuffixTreeHashTable
*
* @var int[]
*/
private $keyNodes;
private array $keyNodes;

/**
* Storage space for the character part of the key.
*
* @var array<AbstractToken|null>
*/
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
Expand Down

0 comments on commit 9c1a1c9

Please sign in to comment.