Skip to content

Commit 1a7c6e8

Browse files
committed
refactoring
1 parent e84f4cb commit 1a7c6e8

File tree

2 files changed

+90
-5
lines changed

2 files changed

+90
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "optimistex/math-expression",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"type": "library",
55
"description": "Taken from http://www.phpclasses.org/browse/file/11680.html, cred to Miles Kaufmann",
66
"keywords": [

tests/Expression.php

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
class ExpressionTest extends TestCase
77
{
8+
/**
9+
* @param array $array
10+
* @throws ReflectionException
11+
*/
812
public function arrayTest(array $array)
913
{
1014
$expr = new Expression();
@@ -22,6 +26,9 @@ public function testTest() {
2226
}
2327
*/
2428

29+
/**
30+
* @throws ReflectionException
31+
*/
2532
public function testEmptyFormula()
2633
{
2734
$expr = new Expression();
@@ -31,6 +38,10 @@ public function testEmptyFormula()
3138
}
3239

3340
// -------------------------------------------------------------------------
41+
42+
/**
43+
* @throws ReflectionException
44+
*/
3445
public function testIntegers()
3546
{
3647
$ints = array('100', '3124123', (string)PHP_INT_MAX, '-1000');
@@ -43,6 +54,10 @@ public function testIntegers()
4354
}
4455

4556
// -------------------------------------------------------------------------
57+
58+
/**
59+
* @throws ReflectionException
60+
*/
4661
public function testFloats()
4762
{
4863
$ints = array('10.10', '0.01', '.1', '1.', '-100.100', '1.10e2', '-0.10e10');
@@ -54,7 +69,11 @@ public function testFloats()
5469
}
5570

5671
// -------------------------------------------------------------------------
57-
public function testAritmeticOperators()
72+
73+
/**
74+
* @throws ReflectionException
75+
*/
76+
public function testArithmeticOperators()
5877
{
5978
$expressions = array('20+20', '-20+20', '-0.1+0.1', '.1+.1', '1.+1.',
6079
'0.1+(-0.1)', '20*20', '-20*20', '20*(-20)', '1.*1.',
@@ -71,6 +90,10 @@ public function testAritmeticOperators()
7190
}
7291

7392
// -------------------------------------------------------------------------
93+
94+
/**
95+
* @throws ReflectionException
96+
*/
7497
public function testSemicolon()
7598
{
7699
$expr = new Expression();
@@ -79,6 +102,10 @@ public function testSemicolon()
79102
}
80103

81104
// -------------------------------------------------------------------------
105+
106+
/**
107+
* @throws ReflectionException
108+
*/
82109
public function testBooleanComparators()
83110
{
84111
$expressions = array('10 == 10', '10 == 20', '0.1 == 0.1', '0.1 == 0.2',
@@ -93,6 +120,10 @@ public function testBooleanComparators()
93120
}
94121

95122
// -------------------------------------------------------------------------
123+
124+
/**
125+
* @throws ReflectionException
126+
*/
96127
public function testBooleanOperators()
97128
{
98129
$expressions = array('10 == 10 && 10 == 10', '10 != 10 && 10 != 10',
@@ -113,6 +144,10 @@ public function testBooleanOperators()
113144
}
114145

115146
// -------------------------------------------------------------------------
147+
148+
/**
149+
* @throws ReflectionException
150+
*/
116151
public function testPriorityOperands()
117152
{
118153
$data = [
@@ -129,6 +164,10 @@ public function testPriorityOperands()
129164
}
130165

131166
// -------------------------------------------------------------------------
167+
168+
/**
169+
* @throws ReflectionException
170+
*/
132171
public function testKeywords()
133172
{
134173
$expressions = array('1 == true', 'true == true', 'false == false',
@@ -149,13 +188,21 @@ public function testKeywords()
149188
}
150189

151190
// -------------------------------------------------------------------------
191+
192+
/**
193+
* @throws ReflectionException
194+
*/
152195
public function testNegation()
153196
{
154197
$expressions = array('!(10 == 10)', '!1', '!0');
155198
$this->arrayTest($expressions);
156199
}
157200

158201
// -------------------------------------------------------------------------
202+
203+
/**
204+
* @throws ReflectionException
205+
*/
159206
public function testStrings()
160207
{
161208
$expressions = array('"foo" == "foo"', '"foo\\"bar" == "foo\\"bar"',
@@ -176,7 +223,11 @@ public function testStrings()
176223
}
177224

178225
// -------------------------------------------------------------------------
179-
public function testMatchers()
226+
227+
/**
228+
* @throws ReflectionException
229+
*/
230+
public function testMatches()
180231
{
181232
$expressions = array('"Foobar" =~ /([fo]+)/i' => 'Foo',
182233
'"foobar" =~ /([0-9]+)/' => null,
@@ -196,6 +247,10 @@ public function testMatchers()
196247
}
197248

198249
// -------------------------------------------------------------------------
250+
251+
/**
252+
* @throws ReflectionException
253+
*/
199254
public function testVariableAssignment()
200255
{
201256
$expressions = array('foo = "bar"' => array('var' => 'foo', 'value' => 'bar'),
@@ -213,6 +268,10 @@ public function testVariableAssignment()
213268
}
214269

215270
// -------------------------------------------------------------------------
271+
272+
/**
273+
* @throws ReflectionException
274+
*/
216275
public function testVariables()
217276
{
218277
$expr = new Expression();
@@ -227,6 +286,10 @@ public function testVariables()
227286
}
228287

229288
// -------------------------------------------------------------------------
289+
290+
/**
291+
* @throws ReflectionException
292+
*/
230293
public function testJSON()
231294
{
232295
$expressions = array(
@@ -267,6 +330,10 @@ public function testJSON()
267330
}
268331

269332
// -------------------------------------------------------------------------
333+
334+
/**
335+
* @throws ReflectionException
336+
*/
270337
public function testCustomFunctions()
271338
{
272339
$functions = [
@@ -298,6 +365,10 @@ public function testCustomFunctions()
298365
}
299366

300367
// -------------------------------------------------------------------------
368+
369+
/**
370+
* @throws ReflectionException
371+
*/
301372
public function testCustomClosures()
302373
{
303374
$expr = new Expression();
@@ -311,6 +382,10 @@ public function testCustomClosures()
311382
}
312383

313384
// -------------------------------------------------------------------------
385+
386+
/**
387+
* @throws ReflectionException
388+
*/
314389
public function testBug_1()
315390
{
316391
$expr = new Expression();
@@ -324,8 +399,9 @@ public function testBug_1()
324399
$this->assertEquals($expr->evaluate($formula), 364);
325400
}
326401

327-
// */
328-
402+
/**
403+
* @throws ReflectionException
404+
*/
329405
public function testFormulaWithBrackets()
330406
{
331407
$e = new Expression();
@@ -361,6 +437,9 @@ public function testFormulaWithBrackets()
361437
}
362438
}
363439

440+
/**
441+
* @throws ReflectionException
442+
*/
364443
public function testFunctionOrderParameters()
365444
{
366445
$e = new Expression();
@@ -399,6 +478,9 @@ public function testFunctionOrderParameters()
399478
}
400479
}
401480

481+
/**
482+
* @throws ReflectionException
483+
*/
402484
public function testRowBreaking()
403485
{
404486
$expr = new Expression();
@@ -412,6 +494,9 @@ public function testRowBreaking()
412494
));
413495
}
414496

497+
/**
498+
* @throws ReflectionException
499+
*/
415500
public function testFunctionIf()
416501
{
417502
$expr = new Expression();

0 commit comments

Comments
 (0)