Skip to content

Commit 4f52421

Browse files
authored
Merge pull request #1 from xp-framework/refactor/xp9-compat
XP9 Compat
2 parents 0b5677f + 2c2f70d commit 4f52421

File tree

4 files changed

+37
-31
lines changed

4 files changed

+37
-31
lines changed

.travis.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
language: php
44

5+
dist: trusty
6+
57
php:
6-
- 5.5
78
- 5.6
89
- 7.0
910
- 7.1
@@ -15,12 +16,9 @@ matrix:
1516
- php: nightly
1617

1718
before_script:
18-
- wget 'https://github.com/xp-framework/xp-runners/releases/download/v5.6.1/setup' -O - | php
19+
- curl -sSL https://dl.bintray.com/xp-runners/generic/xp-run-master.sh > xp-run
1920
- composer install --prefer-dist
2021
- echo "vendor/autoload.php" > composer.pth
21-
- echo "use=vendor/xp-framework/core" > xp.ini
22-
- echo "[runtime]" >> xp.ini
23-
- echo "date.timezone=Europe/Berlin" >> xp.ini
2422

2523
script:
26-
- ./unittest src/test/php
24+
- sh xp-run xp.unittest.TestRunner src/test/php

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Pattern matching changelog
33

44
## ?.?.? / ????-??-??
55

6+
## 8.0.0 / 2017-05-29
7+
8+
* **Heads up:** Dropped PHP 5.5 support - @thekid
9+
* Merged PR #1: Forward compatibility with XP 9.0.0 - @thekid
10+
611
## 7.1.0 / 2016-08-28
712

813
* Added forward compatibility with XP 8.0.0 - @thekid

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"description" : "Big number handling",
77
"keywords": ["module", "xp"],
88
"require" : {
9-
"xp-framework/core": "^8.0 | ^7.0 | ^6.5",
10-
"php" : ">=5.5.0"
9+
"xp-framework/core": "^9.0 | ^8.0 | ^7.0 | ^6.5",
10+
"php" : ">=5.6.0"
1111
},
1212
"require-dev" : {
13-
"xp-framework/unittest": "^7.0 | ^6.5"
13+
"xp-framework/unittest": "^9.0 | ^8.0 | ^7.0 | ^6.5"
1414
},
1515
"autoload" : {
1616
"files" : ["src/main/php/autoload.php"]

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @see http://sine.codeplex.com/SourceControl/changeset/view/57274#1535069
1010
* @ext bcmath
1111
*/
12-
abstract class BigNum extends \lang\Object {
12+
abstract class BigNum implements \lang\Value {
1313
protected $num;
1414

1515
static function __static() {
@@ -53,41 +53,44 @@ public function multiply($other) {
5353
* @return math.BigNum
5454
*/
5555
public abstract function divide($other);
56-
57-
/**
58-
* Returns whether another object is equal to this
59-
*
60-
* @param lang.Generic cmp
61-
* @return bool
62-
*/
63-
public function equals($cmp) {
64-
return $cmp instanceof $this && 0 === bccomp($cmp->num, $this->num);
65-
}
6656

6757
/**
6858
* Returns an integer representing this bignum
6959
*
70-
* @return int
60+
* @return int
7161
*/
72-
public function intValue() {
73-
return (int)substr($this->num, 0, strcspn($this->num, '.'));
74-
}
62+
public function intValue() { return (int)substr($this->num, 0, strcspn($this->num, '.')); }
7563

7664
/**
7765
* Returns a double representing this bignum
7866
*
79-
* @return int
67+
* @return double
8068
*/
81-
public function doubleValue() {
82-
return (double)$this->num;
69+
public function doubleValue() { return (double)$this->num; }
70+
71+
/** @return string */
72+
public function toString() { return nameof($this).'('.$this->num.')'; }
73+
74+
/** @return string */
75+
public function hashCode() { return $this->num; }
76+
77+
/**
78+
* Compare another value to this bignum
79+
*
80+
* @param var $value
81+
* @return int
82+
*/
83+
public function compareTo($value) {
84+
return $value instanceof $this ? bccomp($this->num, $value->num) : 1;
8385
}
8486

8587
/**
86-
* Returns a string representation
88+
* Returns whether another object is equal to this
8789
*
88-
* @return string
90+
* @param var $value
91+
* @return bool
8992
*/
90-
public function toString() {
91-
return typeof($this).'('.(string)$this.')';
93+
public function equals($value) {
94+
return $value instanceof $this && 0 === bccomp($this->num, $value->num);
9295
}
9396
}

0 commit comments

Comments
 (0)