Skip to content

Commit 5d421e4

Browse files
committed
Use type unions in api doc
1 parent 9b88894 commit 5d421e4

File tree

3 files changed

+59
-65
lines changed

3 files changed

+59
-65
lines changed

src/main/php/math/BigFloat.class.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BigFloat extends BigNum {
1414
/**
1515
* Creates a new BigFloat instance
1616
*
17-
* @param string in
17+
* @param int|float|string $in
1818
*/
1919
public function __construct($in) {
2020
$this->num= false !== strpos($in, '.') ? rtrim(rtrim($in, '0'), '.') : (string)$in;
@@ -23,8 +23,8 @@ public function __construct($in) {
2323
/**
2424
* +
2525
*
26-
* @param var other
27-
* @return math.BigNum
26+
* @param math.BigNum|int|float|string $other
27+
* @return math.BigNum
2828
*/
2929
public function add($other) {
3030
return new self(bcadd($this->num, $other instanceof self ? $other->num : $other));
@@ -33,8 +33,8 @@ public function add($other) {
3333
/**
3434
* -
3535
*
36-
* @param var other
37-
* @return math.BigNum
36+
* @param math.BigNum|int|float|string $other
37+
* @return math.BigNum
3838
*/
3939
public function subtract($other) {
4040
return new self(bcsub($this->num, $other instanceof self ? $other->num : $other));
@@ -43,8 +43,8 @@ public function subtract($other) {
4343
/**
4444
* *
4545
*
46-
* @param var other
47-
* @return math.BigNum
46+
* @param math.BigNum|int|float|string $other
47+
* @return math.BigNum
4848
*/
4949
public function multiply($other) {
5050
return new self(bcmul($this->num, $other instanceof self ? $other->num : $other));
@@ -53,8 +53,8 @@ public function multiply($other) {
5353
/**
5454
* /
5555
*
56-
* @param var other
57-
* @return math.BigNum
56+
* @param math.BigNum|int|float|string $other
57+
* @return math.BigNum
5858
*/
5959
public function divide($other) {
6060
try {
@@ -72,9 +72,9 @@ public function divide($other) {
7272
/**
7373
* ^
7474
*
75-
* @see http://en.wikipedia.org/wiki/Exponentiation
76-
* @param var other
77-
* @return math.BigNum
75+
* @see http://en.wikipedia.org/wiki/Exponentiation
76+
* @param math.BigNum|int|float|string $other
77+
* @return math.BigNum
7878
*/
7979
public function power($other) {
8080
return new self(bcpow($this->num, $other instanceof self ? $other->num : $other));
@@ -83,7 +83,7 @@ public function power($other) {
8383
/**
8484
* Returns the next lowest "integer" value by rounding down value if necessary.
8585
*
86-
* @return math.BigFloat
86+
* @return self
8787
*/
8888
public function ceil() {
8989
return new self(false === strpos($this->num, '.')
@@ -95,7 +95,7 @@ public function ceil() {
9595
/**
9696
* Returns the next highest "integer" value by rounding up value if necessary
9797
*
98-
* @return math.BigFloat
98+
* @return self
9999
*/
100100
public function floor() {
101101
return new self(false === strpos($this->num, '.')
@@ -108,8 +108,8 @@ public function floor() {
108108
* Returns the rounded value of val to specified precision (number of digits
109109
* after the decimal point).
110110
*
111-
* @param int precision
112-
* @return math.BigFloat
111+
* @param int $precision
112+
* @return self
113113
*/
114114
public function round($precision= 0) {
115115
if (false === strpos($this->num, '.')) return new self($this->num);

src/main/php/math/BigInt.class.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BigInt extends BigNum {
1414
/**
1515
* Creates a new BigInt instance
1616
*
17-
* @param string in
17+
* @param int|float|string $in
1818
*/
1919
public function __construct($in) {
2020
$this->num= substr($in, 0, strcspn($in, '.'));
@@ -23,8 +23,8 @@ public function __construct($in) {
2323
/**
2424
* +
2525
*
26-
* @param var other
27-
* @return math.BigNum
26+
* @param math.BigNum|int|float|string $other
27+
* @return math.BigNum
2828
*/
2929
public function add($other) {
3030
if ($other instanceof self) {
@@ -41,8 +41,8 @@ public function add($other) {
4141
/**
4242
* -
4343
*
44-
* @param var other
45-
* @return math.BigNum
44+
* @param math.BigNum|int|float|string $other
45+
* @return math.BigNum
4646
*/
4747
public function subtract($other) {
4848
if ($other instanceof self) {
@@ -59,8 +59,8 @@ public function subtract($other) {
5959
/**
6060
* *
6161
*
62-
* @param var other
63-
* @return math.BigNum
62+
* @param math.BigNum|int|float|string $other
63+
* @return math.BigNum
6464
*/
6565
public function multiply($other) {
6666
if ($other instanceof self) {
@@ -77,8 +77,8 @@ public function multiply($other) {
7777
/**
7878
* /
7979
*
80-
* @param var other
81-
* @return math.BigNum
80+
* @param math.BigNum|int|float|string $other
81+
* @return math.BigNum
8282
*/
8383
public function divide($other) {
8484
try {
@@ -119,8 +119,8 @@ public function divide($other) {
119119
/**
120120
* +(0), strictly integer addition
121121
*
122-
* @param var other
123-
* @return math.BigNum
122+
* @param math.BigNum|int|float|string $other
123+
* @return math.BigNum
124124
*/
125125
public function add0($other) {
126126
return new self(bcadd($this->num, $other instanceof parent ? $other->num : $other, 0));
@@ -129,8 +129,8 @@ public function add0($other) {
129129
/**
130130
* -(0), strictly integer subtraction
131131
*
132-
* @param var other
133-
* @return math.BigNum
132+
* @param math.BigNum|int|float|string $other
133+
* @return math.BigNum
134134
*/
135135
public function subtract0($other) {
136136
return new self(bcsub($this->num, $other instanceof parent ? $other->num : $other, 0));
@@ -139,8 +139,8 @@ public function subtract0($other) {
139139
/**
140140
* *(0), strictly integer multiplication
141141
*
142-
* @param var other
143-
* @return math.BigNum
142+
* @param math.BigNum|int|float|string $other
143+
* @return math.BigNum
144144
*/
145145
public function multiply0($other) {
146146
return new self(bcmul($this->num, $other instanceof self ? $other->num : $other, 0));
@@ -149,8 +149,8 @@ public function multiply0($other) {
149149
/**
150150
* /
151151
*
152-
* @param var other
153-
* @return math.BigNum
152+
* @param math.BigNum|int|float|string $other
153+
* @return math.BigNum
154154
*/
155155
public function divide0($other) {
156156
try {
@@ -169,8 +169,8 @@ public function divide0($other) {
169169
* ^
170170
*
171171
* @see http://en.wikipedia.org/wiki/Exponentiation
172-
* @param var other
173-
* @return math.BigNum
172+
* @param math.BigNum|int|float|string $other
173+
* @return math.BigNum
174174
*/
175175
public function power($other) {
176176
if ($other instanceof self) {
@@ -193,8 +193,8 @@ public function power($other) {
193193
/**
194194
* %
195195
*
196-
* @param var other
197-
* @return math.BigNum
196+
* @param math.BigNum|int|float|string $other
197+
* @return math.BigNum
198198
*/
199199
public function modulo($other) {
200200
try {
@@ -212,8 +212,8 @@ public function modulo($other) {
212212
/**
213213
* &
214214
*
215-
* @param var other
216-
* @return math.BigNum
215+
* @param math.BigNum|int|float|string $other
216+
* @return math.BigNum
217217
*/
218218
public function bitwiseAnd($other) {
219219
$a= self::bytesOf($this->num);
@@ -225,8 +225,8 @@ public function bitwiseAnd($other) {
225225
/**
226226
* |
227227
*
228-
* @param var other
229-
* @return math.BigNum
228+
* @param math.BigNum|int|float|string $other
229+
* @return math.BigNum
230230
*/
231231
public function bitwiseOr($other) {
232232
$a= self::bytesOf($this->num);
@@ -238,8 +238,8 @@ public function bitwiseOr($other) {
238238
/**
239239
* ^
240240
*
241-
* @param var other
242-
* @return math.BigNum
241+
* @param math.BigNum|int|float|string $other
242+
* @return math.BigNum
243243
*/
244244
public function bitwiseXor($other) {
245245
$a= self::bytesOf($this->num);
@@ -252,7 +252,7 @@ public function bitwiseXor($other) {
252252
* >>
253253
*
254254
* @param var shift
255-
* @return math.BigNum
255+
* @return math.BigNum
256256
*/
257257
public function shiftRight($shift) {
258258
return new self(bcdiv($this->num, bcpow(2, $shift instanceof self ? $shift->num : $shift, 0), 0));
@@ -262,7 +262,7 @@ public function shiftRight($shift) {
262262
* <<
263263
*
264264
* @param var shift
265-
* @return math.BigNum
265+
* @return math.BigNum
266266
*/
267267
public function shiftLeft($shift) {
268268
return new self(bcmul($this->num, bcpow(2, $shift instanceof self ? $shift->num : $shift, 0), 0));
@@ -273,7 +273,7 @@ public function shiftLeft($shift) {
273273
*
274274
* @see xp://math.BigNum#toBytes
275275
* @param string bytes
276-
* @return math.BigNum
276+
* @return math.BigNum
277277
*/
278278
protected static function fromBytes($bytes) {
279279
$len= strlen($bytes);
@@ -294,7 +294,7 @@ protected static function fromBytes($bytes) {
294294
* Creates sequence of bytes from a bignum
295295
*
296296
* @see xp://math.BigNum#fromBytes
297-
* @return string
297+
* @return string
298298
*/
299299
protected static function bytesOf($n) {
300300
$value= '';
@@ -308,7 +308,7 @@ protected static function bytesOf($n) {
308308
/**
309309
* Returns an byte representing this big integer
310310
*
311-
* @return int
311+
* @return int
312312
*/
313313
public function byteValue() {
314314
return $this->bitwiseAnd(0xFF)->intValue();

src/main/php/math/BigNum.class.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,32 @@ static function __static() {
2121
/**
2222
* +
2323
*
24-
* @param var other
25-
* @return math.BigNum
24+
* @param self|int|float|string $other
25+
* @return self
2626
*/
27-
public function add($other) {
28-
return new static(bcadd($this->num, $other instanceof self ? $other->num : $other));
29-
}
27+
public abstract function add($other);
3028

3129
/**
3230
* -
3331
*
34-
* @param var other
35-
* @return math.BigNum
32+
* @param self|int|float|string $other
33+
* @return self
3634
*/
37-
public function subtract($other) {
38-
return new static(bcsub($this->num, $other instanceof self ? $other->num : $other));
39-
}
35+
public abstract function subtract($other);
4036

4137
/**
4238
* *
4339
*
44-
* @param var other
45-
* @return math.BigNum
40+
* @param self|int|float|string $other
41+
* @return self
4642
*/
47-
public function multiply($other) {
48-
return new static(bcmul($this->num, $other instanceof self ? $other->num : $other));
49-
}
43+
public abstract function multiply($other);
5044

5145
/**
5246
* /
5347
*
54-
* @param var other
55-
* @return math.BigNum
48+
* @param self|int|float|string $other
49+
* @return self
5650
*/
5751
public abstract function divide($other);
5852

0 commit comments

Comments
 (0)