Completed
Pull Request — master (#118)
by thomas
02:37
created
src/BlocktrailSDK.php 2 patches
Doc Comments   +19 added lines, -11 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     /**
108 108
      * normalize network string
109 109
      *
110
-     * @param $network
110
+     * @param string $network
111 111
      * @param $testnet
112 112
      * @return array
113 113
      * @throws \Exception
@@ -764,6 +764,11 @@  discard block
 block discarded – undo
764 764
         ];
765 765
     }
766 766
 
767
+    /**
768
+     * @param integer $bits
769
+     *
770
+     * @return string
771
+     */
767 772
     public function randomBits($bits) {
768 773
         return $this->randomBytes($bits / 8);
769 774
     }
@@ -1092,7 +1097,7 @@  discard block
 block discarded – undo
1092 1097
      * create wallet using the API
1093 1098
      *
1094 1099
      * @param string    $identifier             the wallet identifier to create
1095
-     * @param array     $primaryPublicKey       BIP32 extended public key - [key, path]
1100
+     * @param string[]     $primaryPublicKey       BIP32 extended public key - [key, path]
1096 1101
      * @param array     $backupPublicKey        BIP32 extended public key - [backup key, path "M"]
1097 1102
      * @param string    $primaryMnemonic        mnemonic to store
1098 1103
      * @param string    $checksum               checksum to store
@@ -1120,10 +1125,10 @@  discard block
 block discarded – undo
1120 1125
      *
1121 1126
      * @param string $identifier       the wallet identifier to create
1122 1127
      * @param array  $primaryPublicKey BIP32 extended public key - [key, path]
1123
-     * @param array  $backupPublicKey  BIP32 extended public key - [backup key, path "M"]
1124
-     * @param        $encryptedPrimarySeed
1125
-     * @param        $encryptedSecret
1126
-     * @param        $recoverySecret
1128
+     * @param string[]  $backupPublicKey  BIP32 extended public key - [backup key, path "M"]
1129
+     * @param        string|false $encryptedPrimarySeed
1130
+     * @param        string|false $encryptedSecret
1131
+     * @param        string|false $recoverySecret
1127 1132
      * @param string $checksum         checksum to store
1128 1133
      * @param int    $keyIndex         account that we expect to use
1129 1134
      * @param bool   $segwit           opt in to segwit
@@ -1153,9 +1158,9 @@  discard block
 block discarded – undo
1153 1158
      *
1154 1159
      * @param string $identifier       the wallet identifier to create
1155 1160
      * @param array  $primaryPublicKey BIP32 extended public key - [key, path]
1156
-     * @param array  $backupPublicKey  BIP32 extended public key - [backup key, path "M"]
1157
-     * @param        $encryptedPrimarySeed
1158
-     * @param        $encryptedSecret
1161
+     * @param string[]  $backupPublicKey  BIP32 extended public key - [backup key, path "M"]
1162
+     * @param        string|false $encryptedPrimarySeed
1163
+     * @param        string|false $encryptedSecret
1159 1164
      * @param        $recoverySecret
1160 1165
      * @param string $checksum         checksum to store
1161 1166
      * @param int    $keyIndex         account that we expect to use
@@ -1889,7 +1894,7 @@  discard block
 block discarded – undo
1889 1894
      * convert a Satoshi value to a BTC value
1890 1895
      *
1891 1896
      * @param int       $satoshi
1892
-     * @return float
1897
+     * @return string
1893 1898
      */
1894 1899
     public static function toBTC($satoshi) {
1895 1900
         return bcdiv((int)(string)$satoshi, 100000000, 8);
@@ -1919,7 +1924,7 @@  discard block
 block discarded – undo
1919 1924
      * convert a BTC value to a Satoshi value
1920 1925
      *
1921 1926
      * @param float     $btc
1922
-     * @return string
1927
+     * @return integer
1923 1928
      */
1924 1929
     public static function toSatoshi($btc) {
1925 1930
         return (int)self::toSatoshiString($btc);
@@ -1980,6 +1985,9 @@  discard block
 block discarded – undo
1980 1985
         }
1981 1986
     }
1982 1987
 
1988
+    /**
1989
+     * @param BIP32Key[] $keys
1990
+     */
1983 1991
     public static function normalizeBIP32KeyArray($keys) {
1984 1992
         return Util::arrayMapWithIndex(function ($idx, $key) {
1985 1993
             return [$idx, self::normalizeBIP32Key($key)];
Please login to merge, or discard this patch.
Spacing   +11 added lines, -14 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
         $btccomEndpoint = getenv('BLOCKTRAIL_SDK_BTCCOM_API_ENDPOINT');
92 92
         if (!$btccomEndpoint) {
93
-            $btccomEndpoint = "https://" . ($this->network === "BCC" ? "bch-chain" : "chain") . ".api.btc.com";
93
+            $btccomEndpoint = "https://".($this->network === "BCC" ? "bch-chain" : "chain").".api.btc.com";
94 94
         }
95 95
         $btccomEndpoint = "{$btccomEndpoint}/v3/";
96 96
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
             } else {
661 661
                 // create new primary seed
662 662
                 /** @var HierarchicalKey $primaryPrivateKey */
663
-                list($primaryMnemonic, , $primaryPrivateKey) = $this->newV1PrimarySeed($options['passphrase']);
663
+                list($primaryMnemonic,, $primaryPrivateKey) = $this->newV1PrimarySeed($options['passphrase']);
664 664
                 if ($storePrimaryMnemonic !== false) {
665 665
                     $storePrimaryMnemonic = true;
666 666
                 }
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
         $backupPublicKey = null;
700 700
         if (!isset($options['backup_mnemonic']) && !isset($options['backup_public_key'])) {
701 701
             /** @var HierarchicalKey $backupPrivateKey */
702
-            list($backupMnemonic, , ) = $this->newV1BackupSeed();
702
+            list($backupMnemonic,,) = $this->newV1BackupSeed();
703 703
         } else if (isset($options['backup_mnemonic'])) {
704 704
             $backupMnemonic = $options['backup_mnemonic'];
705 705
         } elseif (isset($options['backup_public_key'])) {
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
         );
733 733
 
734 734
         // received the blocktrail public keys
735
-        $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) {
735
+        $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) {
736 736
             return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])];
737 737
         }, $data['blocktrail_public_keys']);
738 738
 
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
         );
855 855
 
856 856
         // received the blocktrail public keys
857
-        $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) {
857
+        $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) {
858 858
             return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])];
859 859
         }, $data['blocktrail_public_keys']);
860 860
 
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
                 'backup_seed' => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer($backupSeed)) : null,
890 890
                 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($recoveryEncryptedSecret))) : null,
891 891
                 'encrypted_secret' => $encryptedSecret ? MnemonicFactory::bip39()->entropyToMnemonic(new Buffer(base64_decode($encryptedSecret))) : null,
892
-                'blocktrail_public_keys' => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) {
892
+                'blocktrail_public_keys' => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) {
893 893
                     return [$keyIndex, $pubKey->tuple()];
894 894
                 }, $blocktrailPublicKeys),
895 895
             ],
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         );
994 994
 
995 995
         // received the blocktrail public keys
996
-        $blocktrailPublicKeys = Util::arrayMapWithIndex(function ($keyIndex, $pubKeyTuple) {
996
+        $blocktrailPublicKeys = Util::arrayMapWithIndex(function($keyIndex, $pubKeyTuple) {
997 997
             return [$keyIndex, BIP32Key::create(HierarchicalKeyFactory::fromExtended($pubKeyTuple[0]), $pubKeyTuple[1])];
998 998
         }, $data['blocktrail_public_keys']);
999 999
 
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
                 'backup_seed'               => $backupSeed ? MnemonicFactory::bip39()->entropyToMnemonic($backupSeed) : null,
1029 1029
                 'recovery_encrypted_secret' => $recoveryEncryptedSecret ? EncryptionMnemonic::encode($recoveryEncryptedSecret) : null,
1030 1030
                 'encrypted_secret'          => $encryptedSecret ? EncryptionMnemonic::encode($encryptedSecret) : null,
1031
-                'blocktrail_public_keys'    => Util::arrayMapWithIndex(function ($keyIndex, BIP32Key $pubKey) {
1031
+                'blocktrail_public_keys'    => Util::arrayMapWithIndex(function($keyIndex, BIP32Key $pubKey) {
1032 1032
                     return [$keyIndex, $pubKey->tuple()];
1033 1033
                 }, $blocktrailPublicKeys),
1034 1034
             ]
@@ -1251,10 +1251,7 @@  discard block
 block discarded – undo
1251 1251
         }
1252 1252
 
1253 1253
         $identifier = $options['identifier'];
1254
-        $readonly = isset($options['readonly']) ? $options['readonly'] :
1255
-                    (isset($options['readOnly']) ? $options['readOnly'] :
1256
-                        (isset($options['read-only']) ? $options['read-only'] :
1257
-                            false));
1254
+        $readonly = isset($options['readonly']) ? $options['readonly'] : (isset($options['readOnly']) ? $options['readOnly'] : (isset($options['read-only']) ? $options['read-only'] : false));
1258 1255
 
1259 1256
         // get the wallet data from the server
1260 1257
         $data = $this->getWallet($identifier);
@@ -1955,7 +1952,7 @@  discard block
 block discarded – undo
1955 1952
      */
1956 1953
     public static function sortMultisigKeys(array $pubKeys) {
1957 1954
         $result = array_values($pubKeys);
1958
-        usort($result, function (PublicKeyInterface $a, PublicKeyInterface $b) {
1955
+        usort($result, function(PublicKeyInterface $a, PublicKeyInterface $b) {
1959 1956
             $av = $a->getHex();
1960 1957
             $bv = $b->getHex();
1961 1958
             return $av == $bv ? 0 : $av > $bv ? 1 : -1;
@@ -1981,7 +1978,7 @@  discard block
 block discarded – undo
1981 1978
     }
1982 1979
 
1983 1980
     public static function normalizeBIP32KeyArray($keys) {
1984
-        return Util::arrayMapWithIndex(function ($idx, $key) {
1981
+        return Util::arrayMapWithIndex(function($idx, $key) {
1985 1982
             return [$idx, self::normalizeBIP32Key($key)];
1986 1983
         }, $keys);
1987 1984
     }
Please login to merge, or discard this patch.
src/BlocktrailSDKInterface.php 1 patch
Doc Comments   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,6 +15,7 @@  discard block
 block discarded – undo
15 15
      * @param   bool        $debug
16 16
      *
17 17
      * @codeCoverageIgnore
18
+     * @return void
18 19
      */
19 20
     public function setCurlDebugging($debug = true);
20 21
 
@@ -24,6 +25,7 @@  discard block
 block discarded – undo
24 25
      * @param   bool        $verboseErrors
25 26
      *
26 27
      * @codeCoverageIgnore
28
+     * @return void
27 29
      */
28 30
     public function setVerboseErrors($verboseErrors = true);
29 31
     
@@ -33,6 +35,7 @@  discard block
 block discarded – undo
33 35
      * @param bool      $value
34 36
      *
35 37
      * @codeCoverageIgnore
38
+     * @return void
36 39
      */
37 40
     public function setCurlDefaultOption($key, $value);
38 41
 
@@ -328,7 +331,7 @@  discard block
 block discarded – undo
328 331
      *
329 332
      * @param string    $identifier             the wallet identifier to be upgraded
330 333
      * @param int       $keyIndex               the new account to use
331
-     * @param array     $primaryPublicKey       BIP32 extended public key - [key, path]
334
+     * @param string[]     $primaryPublicKey       BIP32 extended public key - [key, path]
332 335
      * @return mixed
333 336
      */
334 337
     public function upgradeKeyIndex($identifier, $keyIndex, $primaryPublicKey);
@@ -423,7 +426,7 @@  discard block
 block discarded – undo
423 426
      *
424 427
      * @param string       $identifier     the identifier of the wallet
425 428
      * @param string|array $rawTransaction raw hex of the transaction (should be partially signed)
426
-     * @param array        $paths          list of the paths that were used for the UTXO
429
+     * @param string[]        $paths          list of the paths that were used for the UTXO
427 430
      * @param bool         $checkFee       let the server verify the fee after signing
428 431
      * @param null         $twoFactorToken
429 432
      * @return string                           the complete raw transaction
@@ -495,22 +498,22 @@  discard block
 block discarded – undo
495 498
     /**
496 499
      * lock a specific unspent output
497 500
      *
498
-     * @param     $identifier
501
+     * @param     string $identifier
499 502
      * @param     $txHash
500 503
      * @param     $txIdx
501 504
      * @param int $ttl
502 505
      * @return
503
-     */
506
+     boolean
504 507
     public function lockWalletUTXO($identifier, $txHash, $txIdx, $ttl = 3);
505 508
 
506 509
     /**
507 510
      * unlock a specific unspent output
508 511
      *
509
-     * @param     $identifier
512
+     * @param     string $identifier
510 513
      * @param     $txHash
511 514
      * @param     $txIdx
512 515
      * @return
513
-     */
516
+     boolean
514 517
     public function unlockWalletUTXO($identifier, $txHash, $txIdx);
515 518
 
516 519
     /**
@@ -639,5 +642,8 @@  discard block
 block discarded – undo
639 642
      */
640 643
     public static function sortMultisigKeys(array $pubKeys);
641 644
 
645
+    /**
646
+     * @return void
647
+     */
642 648
     public function shuffle($arr);
643 649
 }
Please login to merge, or discard this patch.
src/Throttler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
         }
78 78
 
79 79
         if ($this->lastTime) {
80
-            echo "Real diff ".(microtime(true)-$this->lastTime).PHP_EOL;
80
+            echo "Real diff ".(microtime(true) - $this->lastTime).PHP_EOL;
81 81
         }
82 82
         $this->lastTime = \microtime(true);
83 83
     }
Please login to merge, or discard this patch.
src/Connection/RestClient.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             'handler' => $handler,
76 76
             'base_uri' => $this->apiEndpoint,
77 77
             'headers' => array(
78
-                'User-Agent' => Blocktrail::SDK_USER_AGENT . '/' . Blocktrail::SDK_VERSION,
78
+                'User-Agent' => Blocktrail::SDK_USER_AGENT.'/'.Blocktrail::SDK_VERSION,
79 79
             ),
80 80
             'http_errors' => false,
81 81
             'connect_timeout' => 3,
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function request($method, $endpointUrl, $queryString = null, $body = null, $auth = null, $contentMD5Mode = null, $timeout = null) {
145 145
         $this->throttler->waitForThrottle();
146
-        echo "Fired request at " . microtime(true) . PHP_EOL;
146
+        echo "Fired request at ".microtime(true).PHP_EOL;
147 147
         $request = $this->buildRequest($method, $endpointUrl, $queryString, $body, $auth, $contentMD5Mode, $timeout);
148 148
         try {
149 149
             $response = $this->guzzle->send($request, ['auth' => $auth, 'timeout' => $timeout]);
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Blocktrail\SDK\Blocktrail;
6 6
 use Blocktrail\SDK\Throttler;
7
-use Composer\CaBundle\CaBundle;
8 7
 use GuzzleHttp\Client as Guzzle;
9 8
 use GuzzleHttp\Exception\RequestException;
10 9
 use GuzzleHttp\Handler\CurlHandler;
Please login to merge, or discard this patch.