Skip to content

Commit 1c4bf26

Browse files
committed
Move ScopeInfo, VariableInfo to class files
1 parent 0ab5eb0 commit 1c4bf26

File tree

3 files changed

+53
-44
lines changed

3 files changed

+53
-44
lines changed

VariableAnalysis/ScopeInfo.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace VariableAnalysis;
4+
5+
/**
6+
* Holds details of a scope.
7+
*/
8+
class ScopeInfo {
9+
public $owner;
10+
public $opener;
11+
public $closer;
12+
public $variables = array();
13+
14+
function __construct($currScope) {
15+
$this->owner = $currScope;
16+
// TODO: extract opener/closer
17+
}
18+
}

VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,12 @@
11
<?php
22

33
namespace VariableAnalysis\Sniffs\CodeAnalysis;
4+
5+
use VariableAnalysis\ScopeInfo;
6+
use VariableAnalysis\VariableInfo;
47
use PHP_CodeSniffer\Sniffs\Sniff;
58
use PHP_CodeSniffer\Files\File;
69

7-
/**
8-
* Holds details of a scope.
9-
*/
10-
class ScopeInfo {
11-
public $owner;
12-
public $opener;
13-
public $closer;
14-
public $variables = array();
15-
16-
function __construct($currScope) {
17-
$this->owner = $currScope;
18-
// TODO: extract opener/closer
19-
}
20-
}
21-
22-
/**
23-
* Holds details of a variable within a scope.
24-
*/
25-
class VariableInfo {
26-
public $name;
27-
/**
28-
* What scope the variable has: local, param, static, global, bound
29-
*/
30-
public $scopeType;
31-
public $typeHint;
32-
public $passByReference = false;
33-
public $firstDeclared;
34-
public $firstInitialized;
35-
public $firstRead;
36-
public $ignoreUnused = false;
37-
38-
static $scopeTypeDescriptions = array(
39-
'local' => 'variable',
40-
'param' => 'function parameter',
41-
'static' => 'static variable',
42-
'global' => 'global variable',
43-
'bound' => 'bound variable',
44-
);
45-
46-
function __construct($varName) {
47-
$this->name = $varName;
48-
}
49-
}
50-
5110
/**
5211
* Checks the code for undefined function variables.
5312
*

VariableAnalysis/VariableInfo.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace VariableAnalysis;
4+
5+
/**
6+
* Holds details of a variable within a scope.
7+
*/
8+
class VariableInfo {
9+
public $name;
10+
/**
11+
* What scope the variable has: local, param, static, global, bound
12+
*/
13+
public $scopeType;
14+
public $typeHint;
15+
public $passByReference = false;
16+
public $firstDeclared;
17+
public $firstInitialized;
18+
public $firstRead;
19+
public $ignoreUnused = false;
20+
21+
static $scopeTypeDescriptions = array(
22+
'local' => 'variable',
23+
'param' => 'function parameter',
24+
'static' => 'static variable',
25+
'global' => 'global variable',
26+
'bound' => 'bound variable',
27+
);
28+
29+
function __construct($varName) {
30+
$this->name = $varName;
31+
}
32+
}

0 commit comments

Comments
 (0)