Bit-Wasp/bitcoin-lib-php — pull request #20 by rubensayshi (2014-09-19 17:38:50+00:00)
Title: changes/fixes to be compatible with HHVM

so I wanted to use bitcoin-lib-php with the HHVM PHP engine and ran into some issues.

the biggest issue was that when `gmp_strval()` gets a string (not a resource) and base that it tries to create a resource out of the provided string using the specified base ... (see https://github.com/facebook/hhvm/issues/3793). example;

```php
var_dump(gmp_strval('30', 8)); // string(2) "36" in PHP
var_dump(gmp_strval('30', 8)); // string(2) "30" in HHVM
```

so I fixed that by calling `gmp_init()` whenever a string was provided to `gmp_strval()` and it also specified a base, I figured the diff of doing it everywhere where `gmp_strval()` was used would be a bit too large ... plus the issue should be fixed in the new HHVM release (not sure when that's going to be though since they just released a new stable today).

I also added a few tests around the gmp functions to figure out where it was going wrong and figured it never hurts to have more tests so I've left those in.

then the last problem that remained was that `Point` is a reserved class in HHVM which they've added, so the `Point` class didn't work anymore and I added a namespace to the whole library to avoid issues.

also there were 2 stray calls to `is_prime()` functions which I asumed should have been `self::is_prime()`, they weren't covered by test cases I guess... :-(

I tried seperating the adding of the namespace in a single commit so that it should be a bit easier to review.
The only expections are that there are a few lines where I added a `gmp_init` around a `gmp_Utils` call in which case I put the whole line in the #ccb49d8 commit.

Regardless of your desire to support HHVM or not, I think the changes I made are useful/good to add ;-)