File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
* Fixed command execution to properly return error codes when failures occur
6
6
* Improved error handling in all command implementations
7
+ * fix empty scope error. #11
7
8
8
9
## v0.0.4 (2025-03-20)
9
10
Original file line number Diff line number Diff line change @@ -17,10 +17,11 @@ public function __construct(
17
17
public readonly array $ scopes
18
18
)
19
19
{
20
- $ this ->maxVariableHardUsage = max (array_map (fn (Scope $ scope ) => $ scope ->getVariableHardUsage (), $ scopes ));
21
20
if (count ($ scopes ) === 0 ) {
21
+ $ this ->maxVariableHardUsage = 0 ;
22
22
$ this ->avarageVariableHardUsage = 0 ;
23
23
} else {
24
+ $ this ->maxVariableHardUsage = max (array_map (fn (Scope $ scope ) => $ scope ->getVariableHardUsage (), $ scopes ));
24
25
$ this ->avarageVariableHardUsage = array_sum (array_map (fn (Scope $ scope ) => $ scope ->getVariableHardUsage (), $ scopes )) / count ($ scopes );
25
26
}
26
27
}
Original file line number Diff line number Diff line change 9
9
10
10
class VariableAnalizerTest extends TestCase
11
11
{
12
+ public function testAnalyzeEmpty (): void
13
+ {
14
+ $ sut = new VariableAnalyzer ('target.php ' , []);
15
+ $ result = $ sut ->analyze ();
16
+ $ this ->assertSame ('target.php ' , $ result ->filename );
17
+ $ scopes = $ result ->scopes ;
18
+
19
+ $ this ->assertCount (0 , $ scopes );
20
+ }
21
+
12
22
public function testAnalyzeFunctionSimple (): void
13
23
{
14
24
$ func = new Func (null , 'testFunction ' );
You can’t perform that action at this time.
0 commit comments