From b72a740f4dc177ecca092f88a171d3d3e5553f9b Mon Sep 17 00:00:00 2001 From: BafS Date: Wed, 21 May 2025 23:09:06 +0200 Subject: [PATCH 1/3] Fix PHP 8.4 deprecations --- composer.json | 2 +- src/Address/AddressCreator.php | 2 +- src/Address/AddressInterface.php | 2 +- src/Address/Base58Address.php | 2 +- src/Address/Base58AddressInterface.php | 2 +- src/Address/BaseAddressCreator.php | 2 +- src/Address/Bech32AddressInterface.php | 2 +- src/Address/PayToPubKeyHashAddress.php | 2 +- src/Address/ScriptHashAddress.php | 2 +- src/Address/SegwitAddress.php | 4 ++-- src/Bitcoin.php | 4 ++-- src/Block/BlockFactory.php | 4 ++-- src/Block/MerkleRoot.php | 2 +- src/Crypto/EcAdapter/EcAdapterFactory.php | 2 +- src/Crypto/EcAdapter/EcSerializer.php | 2 +- src/Crypto/EcAdapter/Impl/PhpEcc/Key/PrivateKey.php | 6 +++--- src/Crypto/EcAdapter/Impl/PhpEcc/Key/PublicKey.php | 2 +- src/Crypto/EcAdapter/Impl/Secp256k1/Key/PrivateKey.php | 6 +++--- src/Crypto/EcAdapter/Key/Key.php | 2 +- src/Crypto/EcAdapter/Key/KeyInterface.php | 2 +- src/Crypto/EcAdapter/Key/PrivateKeyInterface.php | 6 +++--- src/Key/Deterministic/HierarchicalKey.php | 6 +++--- src/Key/Deterministic/Slip132/Slip132.php | 2 +- src/Key/Factory/ElectrumKeyFactory.php | 4 ++-- src/Key/Factory/HierarchicalKeyFactory.php | 8 ++++---- src/Key/Factory/PrivateKeyFactory.php | 4 ++-- src/Key/Factory/PublicKeyFactory.php | 2 +- src/Key/KeyToScript/Factory/KeyToScriptDataFactory.php | 2 +- src/Key/KeyToScript/Factory/MultisigScriptDataFactory.php | 2 +- src/MessageSigner/MessageSigner.php | 6 +++--- src/Mnemonic/Bip39/Bip39Mnemonic.php | 2 +- src/Mnemonic/MnemonicFactory.php | 4 ++-- src/Script/Consensus/NativeConsensus.php | 2 +- src/Script/Factory/ScriptCreator.php | 2 +- src/Script/FullyQualifiedScript.php | 8 ++++---- src/Script/Interpreter/CheckerBase.php | 2 +- src/Script/Interpreter/Interpreter.php | 4 ++-- src/Script/Interpreter/InterpreterInterface.php | 2 +- src/Script/Interpreter/Number.php | 6 +++--- src/Script/P2shScript.php | 2 +- src/Script/Parser/Parser.php | 2 +- src/Script/Path/LogicOpNode.php | 2 +- src/Script/Script.php | 4 ++-- src/Script/ScriptFactory.php | 8 ++++---- src/Script/ScriptInfo/Multisig.php | 6 +++--- src/Script/ScriptInterface.php | 2 +- src/Script/WitnessScript.php | 2 +- .../Key/HierarchicalKey/ExtendedKeySerializer.php | 2 +- src/Serializer/Key/PrivateKey/WifPrivateKeySerializer.php | 2 +- src/Serializer/Transaction/TransactionInputSerializer.php | 2 +- .../Transaction/TransactionOutputSerializer.php | 2 +- src/Serializer/Transaction/TransactionSerializer.php | 2 +- src/Signature/SignatureFactory.php | 4 ++-- src/Signature/SignatureSort.php | 2 +- src/Signature/TransactionSignatureFactory.php | 4 ++-- src/Transaction/Factory/Checksig.php | 2 +- src/Transaction/Factory/InputSigner.php | 6 +++--- src/Transaction/Factory/InputSignerInterface.php | 2 +- src/Transaction/Factory/Signer.php | 6 +++--- src/Transaction/Factory/TxBuilder.php | 6 +++--- src/Transaction/SignatureHash/V1Hasher.php | 4 ++-- src/Uri.php | 4 ++-- 62 files changed, 103 insertions(+), 103 deletions(-) diff --git a/composer.json b/composer.json index d8f19a764..a425b8a79 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ } }, "require": { - "php-64bit": ">=7.0", + "php-64bit": ">=7.1", "pleonasm/merkle-tree": "~1.0.0", "composer/semver": "^1.4.0|^3.2.0", "lastguest/murmurhash": "^v2.0.0", diff --git a/src/Address/AddressCreator.php b/src/Address/AddressCreator.php index 56997eca4..c6970b35a 100644 --- a/src/Address/AddressCreator.php +++ b/src/Address/AddressCreator.php @@ -101,7 +101,7 @@ public function fromOutputScript(ScriptInterface $outputScript): Address * @return Address * @throws UnrecognizedAddressException */ - public function fromString(string $strAddress, NetworkInterface $network = null): Address + public function fromString(string $strAddress, ?NetworkInterface $network = null): Address { $network = $network ?: Bitcoin::getNetwork(); diff --git a/src/Address/AddressInterface.php b/src/Address/AddressInterface.php index 5753f80bd..0ca64a81d 100644 --- a/src/Address/AddressInterface.php +++ b/src/Address/AddressInterface.php @@ -14,7 +14,7 @@ interface AddressInterface * @param NetworkInterface $network * @return string */ - public function getAddress(NetworkInterface $network = null): string; + public function getAddress(?NetworkInterface $network = null): string; /** * @return BufferInterface diff --git a/src/Address/Base58Address.php b/src/Address/Base58Address.php index 8b823d154..3834dcb0b 100644 --- a/src/Address/Base58Address.php +++ b/src/Address/Base58Address.php @@ -15,7 +15,7 @@ abstract class Base58Address extends Address implements Base58AddressInterface * @param NetworkInterface|null $network * @return string */ - public function getAddress(NetworkInterface $network = null): string + public function getAddress(?NetworkInterface $network = null): string { $network = $network ?: Bitcoin::getNetwork(); $payload = new Buffer($this->getPrefixByte($network) . $this->getHash()->getBinary()); diff --git a/src/Address/Base58AddressInterface.php b/src/Address/Base58AddressInterface.php index 10cb155cd..0bc5bea17 100644 --- a/src/Address/Base58AddressInterface.php +++ b/src/Address/Base58AddressInterface.php @@ -12,5 +12,5 @@ interface Base58AddressInterface extends AddressInterface * @param NetworkInterface $network * @return string */ - public function getPrefixByte(NetworkInterface $network = null): string; + public function getPrefixByte(?NetworkInterface $network = null): string; } diff --git a/src/Address/BaseAddressCreator.php b/src/Address/BaseAddressCreator.php index 3b70124e7..1c906fa88 100644 --- a/src/Address/BaseAddressCreator.php +++ b/src/Address/BaseAddressCreator.php @@ -14,7 +14,7 @@ abstract class BaseAddressCreator * @param NetworkInterface|null $network * @return Address */ - abstract public function fromString(string $strAddress, NetworkInterface $network = null): Address; + abstract public function fromString(string $strAddress, ?NetworkInterface $network = null): Address; /** * @param ScriptInterface $script diff --git a/src/Address/Bech32AddressInterface.php b/src/Address/Bech32AddressInterface.php index 63a069918..b9c727f5e 100644 --- a/src/Address/Bech32AddressInterface.php +++ b/src/Address/Bech32AddressInterface.php @@ -12,5 +12,5 @@ interface Bech32AddressInterface extends AddressInterface * @param NetworkInterface $network * @return string */ - public function getHRP(NetworkInterface $network = null): string; + public function getHRP(?NetworkInterface $network = null): string; } diff --git a/src/Address/PayToPubKeyHashAddress.php b/src/Address/PayToPubKeyHashAddress.php index 54b4b6924..cfa925678 100644 --- a/src/Address/PayToPubKeyHashAddress.php +++ b/src/Address/PayToPubKeyHashAddress.php @@ -29,7 +29,7 @@ public function __construct(BufferInterface $data) * @param NetworkInterface $network * @return string */ - public function getPrefixByte(NetworkInterface $network = null): string + public function getPrefixByte(?NetworkInterface $network = null): string { $network = $network ?: Bitcoin::getNetwork(); return pack("H*", $network->getAddressByte()); diff --git a/src/Address/ScriptHashAddress.php b/src/Address/ScriptHashAddress.php index 27778ec51..3b1e291c4 100644 --- a/src/Address/ScriptHashAddress.php +++ b/src/Address/ScriptHashAddress.php @@ -29,7 +29,7 @@ public function __construct(BufferInterface $data) * @param NetworkInterface $network * @return string */ - public function getPrefixByte(NetworkInterface $network = null): string + public function getPrefixByte(?NetworkInterface $network = null): string { $network = $network ?: Bitcoin::getNetwork(); return pack("H*", $network->getP2shByte()); diff --git a/src/Address/SegwitAddress.php b/src/Address/SegwitAddress.php index 89aba2edb..be1d36aaf 100644 --- a/src/Address/SegwitAddress.php +++ b/src/Address/SegwitAddress.php @@ -31,7 +31,7 @@ public function __construct(WitnessProgram $witnessProgram) * @param NetworkInterface|null $network * @return string */ - public function getHRP(NetworkInterface $network = null): string + public function getHRP(?NetworkInterface $network = null): string { $network = $network ?: Bitcoin::getNetwork(); return $network->getSegwitBech32Prefix(); @@ -57,7 +57,7 @@ public function getScriptPubKey(): ScriptInterface * @param NetworkInterface|null $network * @return string */ - public function getAddress(NetworkInterface $network = null): string + public function getAddress(?NetworkInterface $network = null): string { $network = $network ?: Bitcoin::getNetwork(); diff --git a/src/Bitcoin.php b/src/Bitcoin.php index 97d8bcf4d..91b79c661 100644 --- a/src/Bitcoin.php +++ b/src/Bitcoin.php @@ -50,7 +50,7 @@ public static function getGenerator() * @param GeneratorPoint $generator * @return EcAdapterInterface */ - public static function getEcAdapter(Math $math = null, GeneratorPoint $generator = null) + public static function getEcAdapter(?Math $math = null, ?GeneratorPoint $generator = null) { if (null === self::$adapter) { self::$adapter = EcAdapterFactory::getAdapter( @@ -86,7 +86,7 @@ public static function getParams() * @param Math|null $math * @return ParamsInterface */ - public static function getDefaultParams(Math $math = null) + public static function getDefaultParams(?Math $math = null) { return new Params($math ?: self::getMath()); } diff --git a/src/Block/BlockFactory.php b/src/Block/BlockFactory.php index a5890deda..fcb816d7a 100644 --- a/src/Block/BlockFactory.php +++ b/src/Block/BlockFactory.php @@ -26,7 +26,7 @@ class BlockFactory * @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange * @throws \Exception */ - public static function fromHex(string $string, Math $math = null): BlockInterface + public static function fromHex(string $string, ?Math $math = null): BlockInterface { return self::fromBuffer(Buffer::hex($string), $math); } @@ -37,7 +37,7 @@ public static function fromHex(string $string, Math $math = null): BlockInterfac * @return BlockInterface * @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange */ - public static function fromBuffer(BufferInterface $buffer, Math $math = null): BlockInterface + public static function fromBuffer(BufferInterface $buffer, ?Math $math = null): BlockInterface { $opcodes = new Opcodes(); $serializer = new BlockSerializer( diff --git a/src/Block/MerkleRoot.php b/src/Block/MerkleRoot.php index b39c73ff7..591bdab3b 100644 --- a/src/Block/MerkleRoot.php +++ b/src/Block/MerkleRoot.php @@ -45,7 +45,7 @@ public function __construct(Math $math, array $txCollection) * @return BufferInterface * @throws MerkleTreeEmpty */ - public function calculateHash(callable $hashFunction = null): BufferInterface + public function calculateHash(?callable $hashFunction = null): BufferInterface { if ($this->lastHash instanceof BufferInterface) { return $this->lastHash; diff --git a/src/Crypto/EcAdapter/EcAdapterFactory.php b/src/Crypto/EcAdapter/EcAdapterFactory.php index fda77ecfe..249ca5f5f 100644 --- a/src/Crypto/EcAdapter/EcAdapterFactory.php +++ b/src/Crypto/EcAdapter/EcAdapterFactory.php @@ -27,7 +27,7 @@ class EcAdapterFactory * @param int|null $flags * @return resource */ - public static function getSecp256k1Context(int $flags = null) + public static function getSecp256k1Context(?int $flags = null) { if (!extension_loaded('secp256k1')) { throw new \RuntimeException('Secp256k1 not installed'); diff --git a/src/Crypto/EcAdapter/EcSerializer.php b/src/Crypto/EcAdapter/EcSerializer.php index 2a8449a7c..c53da5bb2 100644 --- a/src/Crypto/EcAdapter/EcSerializer.php +++ b/src/Crypto/EcAdapter/EcSerializer.php @@ -110,7 +110,7 @@ public static function getAdapterImplPath(EcAdapterInterface $adapter): string * @param EcAdapterInterface $adapter * @return mixed */ - public static function getSerializer(string $interface, $useCache = true, EcAdapterInterface $adapter = null) + public static function getSerializer(string $interface, $useCache = true, ?EcAdapterInterface $adapter = null) { if (null === $adapter) { $adapter = Bitcoin::getEcAdapter(); diff --git a/src/Crypto/EcAdapter/Impl/PhpEcc/Key/PrivateKey.php b/src/Crypto/EcAdapter/Impl/PhpEcc/Key/PrivateKey.php index c56231f09..9bfe8310a 100644 --- a/src/Crypto/EcAdapter/Impl/PhpEcc/Key/PrivateKey.php +++ b/src/Crypto/EcAdapter/Impl/PhpEcc/Key/PrivateKey.php @@ -76,7 +76,7 @@ public function getSecret(): \GMP * @param RbgInterface|null $rbg * @return Signature */ - public function sign(BufferInterface $msg32, RbgInterface $rbg = null): SignatureInterface + public function sign(BufferInterface $msg32, ?RbgInterface $rbg = null): SignatureInterface { $rbg = $rbg ?: new Rfc6979($this->ecAdapter, $this, $msg32); $randomK = gmp_init($rbg->bytes(32)->getHex(), 16); @@ -101,7 +101,7 @@ public function sign(BufferInterface $msg32, RbgInterface $rbg = null): Signatur * @return CompactSignatureInterface * @throws \Exception */ - public function signCompact(BufferInterface $msg32, RbgInterface $rbg = null): CompactSignatureInterface + public function signCompact(BufferInterface $msg32, ?RbgInterface $rbg = null): CompactSignatureInterface { $sign = $this->sign($msg32, $rbg); @@ -165,7 +165,7 @@ public function getPublicKey(): PublicKeyInterface * @param NetworkInterface $network * @return string */ - public function toWif(NetworkInterface $network = null): string + public function toWif(?NetworkInterface $network = null): string { $network = $network ?: Bitcoin::getNetwork(); $serializer = new WifPrivateKeySerializer( diff --git a/src/Crypto/EcAdapter/Impl/PhpEcc/Key/PublicKey.php b/src/Crypto/EcAdapter/Impl/PhpEcc/Key/PublicKey.php index 939aa0d24..37bd45122 100644 --- a/src/Crypto/EcAdapter/Impl/PhpEcc/Key/PublicKey.php +++ b/src/Crypto/EcAdapter/Impl/PhpEcc/Key/PublicKey.php @@ -49,7 +49,7 @@ public function __construct( EcAdapter $ecAdapter, PointInterface $point, bool $compressed = false, - string $prefix = null + ?string $prefix = null ) { $this->ecAdapter = $ecAdapter; $this->point = $point; diff --git a/src/Crypto/EcAdapter/Impl/Secp256k1/Key/PrivateKey.php b/src/Crypto/EcAdapter/Impl/Secp256k1/Key/PrivateKey.php index 144f094ce..1419c71e2 100644 --- a/src/Crypto/EcAdapter/Impl/Secp256k1/Key/PrivateKey.php +++ b/src/Crypto/EcAdapter/Impl/Secp256k1/Key/PrivateKey.php @@ -75,7 +75,7 @@ public function __construct(EcAdapter $adapter, \GMP $secret, bool $compressed = * @param RbgInterface|null $rbgInterface * @return Signature */ - public function sign(BufferInterface $msg32, RbgInterface $rbgInterface = null): Signature + public function sign(BufferInterface $msg32, ?RbgInterface $rbgInterface = null): Signature { $context = $this->ecAdapter->getContext(); @@ -101,7 +101,7 @@ public function sign(BufferInterface $msg32, RbgInterface $rbgInterface = null): * @param RbgInterface|null $rbfInterface * @return CompactSignature */ - public function signCompact(BufferInterface $msg32, RbgInterface $rbfInterface = null): CompactSignatureInterface + public function signCompact(BufferInterface $msg32, ?RbgInterface $rbfInterface = null): CompactSignatureInterface { $context = $this->ecAdapter->getContext(); @@ -224,7 +224,7 @@ public function tweakMul(\GMP $tweak): KeyInterface * @param NetworkInterface $network * @return string */ - public function toWif(NetworkInterface $network = null): string + public function toWif(?NetworkInterface $network = null): string { $network = $network ?: Bitcoin::getNetwork(); $wifSerializer = new WifPrivateKeySerializer(new PrivateKeySerializer($this->ecAdapter)); diff --git a/src/Crypto/EcAdapter/Key/Key.php b/src/Crypto/EcAdapter/Key/Key.php index adf3f50e9..9b854ca87 100644 --- a/src/Crypto/EcAdapter/Key/Key.php +++ b/src/Crypto/EcAdapter/Key/Key.php @@ -28,7 +28,7 @@ public function isPrivate(): bool * @param PublicKeySerializerInterface|null $serializer * @return \BitWasp\Buffertools\BufferInterface */ - public function getPubKeyHash(PublicKeySerializerInterface $serializer = null): BufferInterface + public function getPubKeyHash(?PublicKeySerializerInterface $serializer = null): BufferInterface { if ($this instanceof PrivateKeyInterface) { $publicKey = $this->getPublicKey(); diff --git a/src/Crypto/EcAdapter/Key/KeyInterface.php b/src/Crypto/EcAdapter/Key/KeyInterface.php index a5e7cf39d..e16ed1a5b 100644 --- a/src/Crypto/EcAdapter/Key/KeyInterface.php +++ b/src/Crypto/EcAdapter/Key/KeyInterface.php @@ -30,7 +30,7 @@ public function isPrivate(): bool; * @param PublicKeySerializerInterface|null $serializer * @return BufferInterface */ - public function getPubKeyHash(PublicKeySerializerInterface $serializer = null): BufferInterface; + public function getPubKeyHash(?PublicKeySerializerInterface $serializer = null): BufferInterface; /** * @param \GMP $offset diff --git a/src/Crypto/EcAdapter/Key/PrivateKeyInterface.php b/src/Crypto/EcAdapter/Key/PrivateKeyInterface.php index 10ba43e10..6000fbb18 100644 --- a/src/Crypto/EcAdapter/Key/PrivateKeyInterface.php +++ b/src/Crypto/EcAdapter/Key/PrivateKeyInterface.php @@ -25,14 +25,14 @@ public function getSecret(); * @param RbgInterface $rbg * @return SignatureInterface */ - public function sign(BufferInterface $msg32, RbgInterface $rbg = null); + public function sign(BufferInterface $msg32, ?RbgInterface $rbg = null); /** * @param BufferInterface $msg32 * @param RbgInterface|null $rbgInterface * @return CompactSignature */ - public function signCompact(BufferInterface $msg32, RbgInterface $rbgInterface = null); + public function signCompact(BufferInterface $msg32, ?RbgInterface $rbgInterface = null); /** * Return the public key. @@ -48,5 +48,5 @@ public function getPublicKey(); * @param NetworkInterface $network * @return string */ - public function toWif(NetworkInterface $network = null); + public function toWif(?NetworkInterface $network = null); } diff --git a/src/Key/Deterministic/HierarchicalKey.php b/src/Key/Deterministic/HierarchicalKey.php index a6105fadd..b76315149 100644 --- a/src/Key/Deterministic/HierarchicalKey.php +++ b/src/Key/Deterministic/HierarchicalKey.php @@ -345,7 +345,7 @@ public function derivePath(string $path): HierarchicalKey * @param NetworkInterface $network * @return string */ - public function toExtendedKey(NetworkInterface $network = null): string + public function toExtendedKey(?NetworkInterface $network = null): string { $network = $network ?: Bitcoin::getNetwork(); @@ -361,7 +361,7 @@ public function toExtendedKey(NetworkInterface $network = null): string * @param NetworkInterface $network * @return string */ - public function toExtendedPrivateKey(NetworkInterface $network = null): string + public function toExtendedPrivateKey(?NetworkInterface $network = null): string { if (!$this->isPrivate()) { throw new \LogicException('Cannot create extended private key from public'); @@ -376,7 +376,7 @@ public function toExtendedPrivateKey(NetworkInterface $network = null): string * @param NetworkInterface $network * @return string */ - public function toExtendedPublicKey(NetworkInterface $network = null): string + public function toExtendedPublicKey(?NetworkInterface $network = null): string { return $this->withoutPrivateKey()->toExtendedKey($network); } diff --git a/src/Key/Deterministic/Slip132/Slip132.php b/src/Key/Deterministic/Slip132/Slip132.php index fd3986d41..dcee37985 100644 --- a/src/Key/Deterministic/Slip132/Slip132.php +++ b/src/Key/Deterministic/Slip132/Slip132.php @@ -16,7 +16,7 @@ class Slip132 */ private $helper; - public function __construct(KeyToScriptHelper $helper = null) + public function __construct(?KeyToScriptHelper $helper = null) { $this->helper = $helper ?: new KeyToScriptHelper(Bitcoin::getEcAdapter()); } diff --git a/src/Key/Factory/ElectrumKeyFactory.php b/src/Key/Factory/ElectrumKeyFactory.php index 87e02ae94..87628ef94 100644 --- a/src/Key/Factory/ElectrumKeyFactory.php +++ b/src/Key/Factory/ElectrumKeyFactory.php @@ -29,7 +29,7 @@ class ElectrumKeyFactory * ElectrumKeyFactory constructor. * @param EcAdapterInterface|null $ecAdapter */ - public function __construct(EcAdapterInterface $ecAdapter = null) + public function __construct(?EcAdapterInterface $ecAdapter = null) { $this->adapter = $ecAdapter ?: Bitcoin::getEcAdapter(); $this->privateFactory = new PrivateKeyFactory($ecAdapter); @@ -41,7 +41,7 @@ public function __construct(EcAdapterInterface $ecAdapter = null) * @return ElectrumKey * @throws \Exception */ - public function fromMnemonic(string $mnemonic, ElectrumWordListInterface $wordList = null): ElectrumKey + public function fromMnemonic(string $mnemonic, ?ElectrumWordListInterface $wordList = null): ElectrumKey { $mnemonicConverter = MnemonicFactory::electrum($wordList, $this->adapter); $entropy = $mnemonicConverter->mnemonicToEntropy($mnemonic); diff --git a/src/Key/Factory/HierarchicalKeyFactory.php b/src/Key/Factory/HierarchicalKeyFactory.php index 4f93c821b..c1e2d6496 100644 --- a/src/Key/Factory/HierarchicalKeyFactory.php +++ b/src/Key/Factory/HierarchicalKeyFactory.php @@ -43,7 +43,7 @@ class HierarchicalKeyFactory * @param Base58ExtendedKeySerializer|null $serializer * @throws \Exception */ - public function __construct(EcAdapterInterface $ecAdapter = null, Base58ExtendedKeySerializer $serializer = null) + public function __construct(?EcAdapterInterface $ecAdapter = null, ?Base58ExtendedKeySerializer $serializer = null) { $this->adapter = $ecAdapter ?: Bitcoin::getEcAdapter(); $this->privFactory = new PrivateKeyFactory($this->adapter); @@ -59,7 +59,7 @@ public function __construct(EcAdapterInterface $ecAdapter = null, Base58Extended * @throws \BitWasp\Bitcoin\Exceptions\RandomBytesFailure * @throws \Exception */ - public function generateMasterKey(Random $random, ScriptDataFactory $scriptDataFactory = null): HierarchicalKey + public function generateMasterKey(Random $random, ?ScriptDataFactory $scriptDataFactory = null): HierarchicalKey { return $this->fromEntropy( $random->bytes(64), @@ -73,7 +73,7 @@ public function generateMasterKey(Random $random, ScriptDataFactory $scriptDataF * @return HierarchicalKey * @throws \Exception */ - public function fromEntropy(BufferInterface $entropy, ScriptDataFactory $scriptFactory = null): HierarchicalKey + public function fromEntropy(BufferInterface $entropy, ?ScriptDataFactory $scriptFactory = null): HierarchicalKey { $seed = Hash::hmac('sha512', $entropy, new Buffer('Bitcoin seed')); $privSecret = $seed->slice(0, 32); @@ -89,7 +89,7 @@ public function fromEntropy(BufferInterface $entropy, ScriptDataFactory $scriptF * @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure * @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange */ - public function fromExtended(string $extendedKey, NetworkInterface $network = null): HierarchicalKey + public function fromExtended(string $extendedKey, ?NetworkInterface $network = null): HierarchicalKey { return $this->serializer->parse($network ?: Bitcoin::getNetwork(), $extendedKey); } diff --git a/src/Key/Factory/PrivateKeyFactory.php b/src/Key/Factory/PrivateKeyFactory.php index 98991aff8..7600b2273 100644 --- a/src/Key/Factory/PrivateKeyFactory.php +++ b/src/Key/Factory/PrivateKeyFactory.php @@ -31,7 +31,7 @@ class PrivateKeyFactory * PrivateKeyFactory constructor. * @param EcAdapterInterface $ecAdapter */ - public function __construct(EcAdapterInterface $ecAdapter = null) + public function __construct(?EcAdapterInterface $ecAdapter = null) { $ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter(); $this->privSerializer = EcSerializer::getSerializer(PrivateKeySerializerInterface::class, true, $ecAdapter); @@ -106,7 +106,7 @@ public function fromHexUncompressed(string $hex): PrivateKeyInterface * @throws \BitWasp\Bitcoin\Exceptions\InvalidPrivateKey * @throws \Exception */ - public function fromWif(string $wif, NetworkInterface $network = null): PrivateKeyInterface + public function fromWif(string $wif, ?NetworkInterface $network = null): PrivateKeyInterface { return $this->wifSerializer->parse($wif, $network); } diff --git a/src/Key/Factory/PublicKeyFactory.php b/src/Key/Factory/PublicKeyFactory.php index c5e3dc279..af4955538 100644 --- a/src/Key/Factory/PublicKeyFactory.php +++ b/src/Key/Factory/PublicKeyFactory.php @@ -23,7 +23,7 @@ class PublicKeyFactory * PublicKeyFactory constructor. * @param EcAdapterInterface $ecAdapter */ - public function __construct(EcAdapterInterface $ecAdapter = null) + public function __construct(?EcAdapterInterface $ecAdapter = null) { $ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter(); $this->serializer = EcSerializer::getSerializer(PublicKeySerializerInterface::class, true, $ecAdapter); diff --git a/src/Key/KeyToScript/Factory/KeyToScriptDataFactory.php b/src/Key/KeyToScript/Factory/KeyToScriptDataFactory.php index 9c5989ea8..999d18eaa 100644 --- a/src/Key/KeyToScript/Factory/KeyToScriptDataFactory.php +++ b/src/Key/KeyToScript/Factory/KeyToScriptDataFactory.php @@ -23,7 +23,7 @@ abstract class KeyToScriptDataFactory extends ScriptDataFactory * KeyToP2PKScriptFactory constructor. * @param PublicKeySerializerInterface|null $pubKeySerializer */ - public function __construct(PublicKeySerializerInterface $pubKeySerializer = null) + public function __construct(?PublicKeySerializerInterface $pubKeySerializer = null) { if (null === $pubKeySerializer) { $pubKeySerializer = EcSerializer::getSerializer(PublicKeySerializerInterface::class, true); diff --git a/src/Key/KeyToScript/Factory/MultisigScriptDataFactory.php b/src/Key/KeyToScript/Factory/MultisigScriptDataFactory.php index 218b61f38..637ebf2bf 100644 --- a/src/Key/KeyToScript/Factory/MultisigScriptDataFactory.php +++ b/src/Key/KeyToScript/Factory/MultisigScriptDataFactory.php @@ -28,7 +28,7 @@ class MultisigScriptDataFactory extends KeyToScriptDataFactory */ private $sortKeys; - public function __construct(int $numSigners, int $numKeys, bool $sortKeys, PublicKeySerializerInterface $pubKeySerializer = null) + public function __construct(int $numSigners, int $numKeys, bool $sortKeys, ?PublicKeySerializerInterface $pubKeySerializer = null) { $this->numSigners = $numSigners; $this->numKeys = $numKeys; diff --git a/src/MessageSigner/MessageSigner.php b/src/MessageSigner/MessageSigner.php index e6cc65fb3..c777a3c10 100644 --- a/src/MessageSigner/MessageSigner.php +++ b/src/MessageSigner/MessageSigner.php @@ -25,7 +25,7 @@ class MessageSigner /** * @param EcAdapterInterface $ecAdapter */ - public function __construct(EcAdapterInterface $ecAdapter = null) + public function __construct(?EcAdapterInterface $ecAdapter = null) { $this->ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter(); } @@ -64,7 +64,7 @@ public function calculateMessageHash(NetworkInterface $network, string $message) * @param NetworkInterface|null $network * @return bool */ - public function verify(SignedMessage $signedMessage, PayToPubKeyHashAddress $address, NetworkInterface $network = null): bool + public function verify(SignedMessage $signedMessage, PayToPubKeyHashAddress $address, ?NetworkInterface $network = null): bool { $network = $network ?: Bitcoin::getNetwork(); $hash = $this->calculateMessageHash($network, $signedMessage->getMessage()); @@ -83,7 +83,7 @@ public function verify(SignedMessage $signedMessage, PayToPubKeyHashAddress $add * @param NetworkInterface|null $network * @return SignedMessage */ - public function sign(string $message, PrivateKeyInterface $privateKey, NetworkInterface $network = null): SignedMessage + public function sign(string $message, PrivateKeyInterface $privateKey, ?NetworkInterface $network = null): SignedMessage { $network = $network ?: Bitcoin::getNetwork(); $hash = $this->calculateMessageHash($network, $message); diff --git a/src/Mnemonic/Bip39/Bip39Mnemonic.php b/src/Mnemonic/Bip39/Bip39Mnemonic.php index 175a5a5ff..050820fa8 100644 --- a/src/Mnemonic/Bip39/Bip39Mnemonic.php +++ b/src/Mnemonic/Bip39/Bip39Mnemonic.php @@ -48,7 +48,7 @@ public function __construct(EcAdapterInterface $ecAdapter, Bip39WordListInterfac * @return string * @throws \BitWasp\Bitcoin\Exceptions\RandomBytesFailure */ - public function create(int $entropySize = null): string + public function create(?int $entropySize = null): string { if (null === $entropySize) { $entropySize = self::DEFAULT_ENTROPY_BYTE_LEN * 8; diff --git a/src/Mnemonic/MnemonicFactory.php b/src/Mnemonic/MnemonicFactory.php index 10c247e55..f272d0108 100644 --- a/src/Mnemonic/MnemonicFactory.php +++ b/src/Mnemonic/MnemonicFactory.php @@ -19,7 +19,7 @@ class MnemonicFactory * @param EcAdapterInterface $ecAdapter * @return ElectrumMnemonic */ - public static function electrum(ElectrumWordListInterface $wordList = null, EcAdapterInterface $ecAdapter = null): ElectrumMnemonic + public static function electrum(?ElectrumWordListInterface $wordList = null, ?EcAdapterInterface $ecAdapter = null): ElectrumMnemonic { return new ElectrumMnemonic( $ecAdapter ?: Bitcoin::getEcAdapter(), @@ -32,7 +32,7 @@ public static function electrum(ElectrumWordListInterface $wordList = null, EcAd * @param EcAdapterInterface $ecAdapter * @return Bip39Mnemonic */ - public static function bip39(Bip39WordListInterface $wordList = null, EcAdapterInterface $ecAdapter = null): Bip39Mnemonic + public static function bip39(?Bip39WordListInterface $wordList = null, ?EcAdapterInterface $ecAdapter = null): Bip39Mnemonic { return new Bip39Mnemonic( $ecAdapter ?: Bitcoin::getEcAdapter(), diff --git a/src/Script/Consensus/NativeConsensus.php b/src/Script/Consensus/NativeConsensus.php index 448070420..25542589f 100644 --- a/src/Script/Consensus/NativeConsensus.php +++ b/src/Script/Consensus/NativeConsensus.php @@ -20,7 +20,7 @@ class NativeConsensus implements ConsensusInterface * NativeConsensus constructor. * @param EcAdapterInterface $ecAdapter */ - public function __construct(EcAdapterInterface $ecAdapter = null) + public function __construct(?EcAdapterInterface $ecAdapter = null) { $this->adapter = $ecAdapter ?: Bitcoin::getEcAdapter(); } diff --git a/src/Script/Factory/ScriptCreator.php b/src/Script/Factory/ScriptCreator.php index f0980a9dc..6ea9173fb 100644 --- a/src/Script/Factory/ScriptCreator.php +++ b/src/Script/Factory/ScriptCreator.php @@ -34,7 +34,7 @@ class ScriptCreator * @param Opcodes $opcodes * @param BufferInterface|null $buffer */ - public function __construct(Math $math, Opcodes $opcodes, BufferInterface $buffer = null) + public function __construct(Math $math, Opcodes $opcodes, ?BufferInterface $buffer = null) { if ($buffer !== null) { $this->script = $buffer->getBinary(); diff --git a/src/Script/FullyQualifiedScript.php b/src/Script/FullyQualifiedScript.php index 9bf505537..f14c0f565 100644 --- a/src/Script/FullyQualifiedScript.php +++ b/src/Script/FullyQualifiedScript.php @@ -58,8 +58,8 @@ class FullyQualifiedScript */ public function __construct( OutputData $spkData, - OutputData $rsData = null, - OutputData $wsData = null + ?OutputData $rsData = null, + ?OutputData $wsData = null ) { $signScript = $spkData; $sigVersion = SigHash::V0; @@ -182,8 +182,8 @@ public static function fromTxData( ScriptInterface $scriptPubKey, ScriptInterface $scriptSig, ScriptWitnessInterface $witness, - SignData $signData = null, - OutputClassifier $classifier = null + ?SignData $signData = null, + ?OutputClassifier $classifier = null ) { $classifier = $classifier ?: new OutputClassifier(); $signData = $signData ?: new SignData(); diff --git a/src/Script/Interpreter/CheckerBase.php b/src/Script/Interpreter/CheckerBase.php index 196cbc5e7..8d33fea40 100644 --- a/src/Script/Interpreter/CheckerBase.php +++ b/src/Script/Interpreter/CheckerBase.php @@ -72,7 +72,7 @@ abstract class CheckerBase * @param TransactionSignatureSerializer|null $sigSerializer * @param PublicKeySerializerInterface|null $pubKeySerializer */ - public function __construct(EcAdapterInterface $ecAdapter, TransactionInterface $transaction, int $nInput, int $amount, TransactionSignatureSerializer $sigSerializer = null, PublicKeySerializerInterface $pubKeySerializer = null) + public function __construct(EcAdapterInterface $ecAdapter, TransactionInterface $transaction, int $nInput, int $amount, ?TransactionSignatureSerializer $sigSerializer = null, ?PublicKeySerializerInterface $pubKeySerializer = null) { $this->sigSerializer = $sigSerializer ?: new TransactionSignatureSerializer(EcSerializer::getSerializer(DerSignatureSerializerInterface::class, true, $ecAdapter)); $this->pubKeySerializer = $pubKeySerializer ?: EcSerializer::getSerializer(PublicKeySerializerInterface::class, true, $ecAdapter); diff --git a/src/Script/Interpreter/Interpreter.php b/src/Script/Interpreter/Interpreter.php index 2340cd1ff..96a7ae1d7 100644 --- a/src/Script/Interpreter/Interpreter.php +++ b/src/Script/Interpreter/Interpreter.php @@ -54,7 +54,7 @@ class Interpreter implements InterpreterInterface /** * @param EcAdapterInterface $ecAdapter */ - public function __construct(EcAdapterInterface $ecAdapter = null) + public function __construct(?EcAdapterInterface $ecAdapter = null) { $ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter(); $this->math = $ecAdapter->getMath(); @@ -216,7 +216,7 @@ private function verifyWitnessProgram(WitnessProgram $witnessProgram, ScriptWitn * @param ScriptWitnessInterface|null $witness * @return bool */ - public function verify(ScriptInterface $scriptSig, ScriptInterface $scriptPubKey, int $flags, CheckerBase $checker, ScriptWitnessInterface $witness = null): bool + public function verify(ScriptInterface $scriptSig, ScriptInterface $scriptPubKey, int $flags, CheckerBase $checker, ?ScriptWitnessInterface $witness = null): bool { static $emptyWitness = null; if ($emptyWitness === null) { diff --git a/src/Script/Interpreter/InterpreterInterface.php b/src/Script/Interpreter/InterpreterInterface.php index 25d4fc173..631aaff5a 100644 --- a/src/Script/Interpreter/InterpreterInterface.php +++ b/src/Script/Interpreter/InterpreterInterface.php @@ -95,7 +95,7 @@ interface InterpreterInterface * @param ScriptWitnessInterface|null $witness * @return bool */ - public function verify(ScriptInterface $scriptSig, ScriptInterface $scriptPubKey, int $flags, CheckerBase $checker, ScriptWitnessInterface $witness = null); + public function verify(ScriptInterface $scriptSig, ScriptInterface $scriptPubKey, int $flags, CheckerBase $checker, ?ScriptWitnessInterface $witness = null); /** * @param ScriptInterface $script diff --git a/src/Script/Interpreter/Number.php b/src/Script/Interpreter/Number.php index bf9c68be4..355ee4ce8 100644 --- a/src/Script/Interpreter/Number.php +++ b/src/Script/Interpreter/Number.php @@ -42,7 +42,7 @@ public function __construct($number, Math $math) * @param Math|null $math * @return self */ - public static function int($number, Math $math = null) + public static function int($number, ?Math $math = null) { return new self( $number, @@ -55,7 +55,7 @@ public static function int($number, Math $math = null) * @param Math|null $math * @return self */ - public static function gmp(\GMP $number, Math $math = null) + public static function gmp(\GMP $number, ?Math $math = null) { return new self( gmp_strval($number, 10), @@ -70,7 +70,7 @@ public static function gmp(\GMP $number, Math $math = null) * @param Math|null $math * @return self */ - public static function buffer(BufferInterface $vch, $fRequireMinimal, $maxNumSize = self::MAX_NUM_SIZE, Math $math = null) + public static function buffer(BufferInterface $vch, $fRequireMinimal, $maxNumSize = self::MAX_NUM_SIZE, ?Math $math = null) { $size = $vch->getSize(); if ($size > $maxNumSize) { diff --git a/src/Script/P2shScript.php b/src/Script/P2shScript.php index 2498f4f5b..71b3ae33e 100644 --- a/src/Script/P2shScript.php +++ b/src/Script/P2shScript.php @@ -31,7 +31,7 @@ class P2shScript extends Script * @param Opcodes|null $opcodes * @throws P2shScriptException */ - public function __construct(ScriptInterface $script, Opcodes $opcodes = null) + public function __construct(ScriptInterface $script, ?Opcodes $opcodes = null) { if ($script instanceof WitnessScript) { $script = $script->getOutputScript(); diff --git a/src/Script/Parser/Parser.php b/src/Script/Parser/Parser.php index 96644b0cc..0bc7307db 100644 --- a/src/Script/Parser/Parser.php +++ b/src/Script/Parser/Parser.php @@ -147,7 +147,7 @@ private function doNext(int $ptr) * @param null|int $length * @return Script */ - public function slice(int $begin, int $length = null) + public function slice(int $begin, ?int $length = null) { if ($begin < 0) { throw new \RuntimeException("Invalid start of script - cannot be negative or "); diff --git a/src/Script/Path/LogicOpNode.php b/src/Script/Path/LogicOpNode.php index e68ab54fe..071badbd8 100644 --- a/src/Script/Path/LogicOpNode.php +++ b/src/Script/Path/LogicOpNode.php @@ -26,7 +26,7 @@ class LogicOpNode * @param LogicOpNode|null $parent * @param bool|null $value */ - public function __construct(LogicOpNode $parent = null, bool $value = null) + public function __construct(?LogicOpNode $parent = null, ?bool $value = null) { $this->parent = $parent; $this->value = $value; diff --git a/src/Script/Script.php b/src/Script/Script.php index 3de59dda0..d19045d35 100644 --- a/src/Script/Script.php +++ b/src/Script/Script.php @@ -41,7 +41,7 @@ class Script extends Serializable implements ScriptInterface * @param BufferInterface $script * @param Opcodes|null $opCodes */ - public function __construct(BufferInterface $script = null, Opcodes $opCodes = null) + public function __construct(?BufferInterface $script = null, ?Opcodes $opCodes = null) { $this->script = $script instanceof BufferInterface ? $script->getBinary() : ''; $this->opCodes = $opCodes ?: new Opcodes(); @@ -226,7 +226,7 @@ public function countP2shSigOps(ScriptInterface $scriptSig): int * @param array|null $ops * @return bool */ - public function isPushOnly(array&$ops = null): bool + public function isPushOnly(?array&$ops = null): bool { $decoded = $this->getScriptParser()->decode(); $data = []; diff --git a/src/Script/ScriptFactory.php b/src/Script/ScriptFactory.php index f6bf71d3d..82a5600ff 100644 --- a/src/Script/ScriptFactory.php +++ b/src/Script/ScriptFactory.php @@ -39,7 +39,7 @@ public static function fromHex(string $string): ScriptInterface * @param Math|null $math * @return ScriptInterface */ - public static function fromBuffer(BufferInterface $buffer, Opcodes $opcodes = null, Math $math = null): ScriptInterface + public static function fromBuffer(BufferInterface $buffer, ?Opcodes $opcodes = null, ?Math $math = null): ScriptInterface { return self::create($buffer, $opcodes, $math)->getScript(); } @@ -50,7 +50,7 @@ public static function fromBuffer(BufferInterface $buffer, Opcodes $opcodes = nu * @param Math|null $math * @return ScriptCreator */ - public static function create(BufferInterface $buffer = null, Opcodes $opcodes = null, Math $math = null): ScriptCreator + public static function create(?BufferInterface $buffer = null, ?Opcodes $opcodes = null, ?Math $math = null): ScriptCreator { return new ScriptCreator($math ?: Bitcoin::getMath(), $opcodes ?: new Opcodes(), $buffer); } @@ -126,7 +126,7 @@ public static function scriptPubKey(): OutputScriptFactory * @param EcAdapterInterface|null $ecAdapter * @return NativeConsensus */ - public static function getNativeConsensus(EcAdapterInterface $ecAdapter = null): NativeConsensus + public static function getNativeConsensus(?EcAdapterInterface $ecAdapter = null): NativeConsensus { return new NativeConsensus($ecAdapter ?: Bitcoin::getEcAdapter()); } @@ -143,7 +143,7 @@ public static function getBitcoinConsensus(): BitcoinConsensus * @param EcAdapterInterface|null $ecAdapter * @return ConsensusInterface */ - public static function consensus(EcAdapterInterface $ecAdapter = null): ConsensusInterface + public static function consensus(?EcAdapterInterface $ecAdapter = null): ConsensusInterface { if (extension_loaded('bitcoinconsensus')) { return self::getBitcoinConsensus(); diff --git a/src/Script/ScriptInfo/Multisig.php b/src/Script/ScriptInfo/Multisig.php index a0fbd4e0f..fab5b75bf 100644 --- a/src/Script/ScriptInfo/Multisig.php +++ b/src/Script/ScriptInfo/Multisig.php @@ -50,7 +50,7 @@ class Multisig * @param bool $allowVerify * @param PublicKeySerializerInterface|null $pubKeySerializer */ - public function __construct(int $requiredSigs, array $keys, int $opcode, $allowVerify = false, PublicKeySerializerInterface $pubKeySerializer = null) + public function __construct(int $requiredSigs, array $keys, int $opcode, $allowVerify = false, ?PublicKeySerializerInterface $pubKeySerializer = null) { if ($opcode === Opcodes::OP_CHECKMULTISIG) { $verify = false; @@ -92,7 +92,7 @@ public function __construct(int $requiredSigs, array $keys, int $opcode, $allowV * @param bool $allowVerify * @return Multisig */ - public static function fromDecodedScript(array $decoded, PublicKeySerializerInterface $pubKeySerializer = null, $allowVerify = false) + public static function fromDecodedScript(array $decoded, ?PublicKeySerializerInterface $pubKeySerializer = null, $allowVerify = false) { if (count($decoded) < 4) { throw new \InvalidArgumentException('Malformed multisig script'); @@ -128,7 +128,7 @@ public static function fromDecodedScript(array $decoded, PublicKeySerializerInte * @param bool $allowVerify * @return Multisig */ - public static function fromScript(ScriptInterface $script, PublicKeySerializerInterface $pubKeySerializer = null, bool $allowVerify = false) + public static function fromScript(ScriptInterface $script, ?PublicKeySerializerInterface $pubKeySerializer = null, bool $allowVerify = false) { return static::fromDecodedScript($script->getScriptParser()->decode(), $pubKeySerializer, $allowVerify); } diff --git a/src/Script/ScriptInterface.php b/src/Script/ScriptInterface.php index b7a48f3c4..728ded205 100644 --- a/src/Script/ScriptInterface.php +++ b/src/Script/ScriptInterface.php @@ -37,7 +37,7 @@ public function getOpcodes(): Opcodes; * @param array $ops * @return bool */ - public function isPushOnly(array &$ops = null): bool; + public function isPushOnly(?array &$ops = null): bool; /** * @param WitnessProgram|null $witness diff --git a/src/Script/WitnessScript.php b/src/Script/WitnessScript.php index 48c37a82c..20360a06b 100644 --- a/src/Script/WitnessScript.php +++ b/src/Script/WitnessScript.php @@ -36,7 +36,7 @@ class WitnessScript extends Script * @param Opcodes|null $opcodes * @throws WitnessScriptException */ - public function __construct(ScriptInterface $script, Opcodes $opcodes = null) + public function __construct(ScriptInterface $script, ?Opcodes $opcodes = null) { if ($script instanceof self) { throw new WitnessScriptException("Cannot nest V0 P2WSH scripts."); diff --git a/src/Serializer/Key/HierarchicalKey/ExtendedKeySerializer.php b/src/Serializer/Key/HierarchicalKey/ExtendedKeySerializer.php index 00287d6e7..e9c306d77 100644 --- a/src/Serializer/Key/HierarchicalKey/ExtendedKeySerializer.php +++ b/src/Serializer/Key/HierarchicalKey/ExtendedKeySerializer.php @@ -53,7 +53,7 @@ class ExtendedKeySerializer * @param EcAdapterInterface $ecAdapter * @param GlobalPrefixConfig|null $config */ - public function __construct(EcAdapterInterface $ecAdapter, GlobalPrefixConfig $config = null) + public function __construct(EcAdapterInterface $ecAdapter, ?GlobalPrefixConfig $config = null) { $this->privateKeySerializer = EcSerializer::getSerializer(PrivateKeySerializerInterface::class, true, $ecAdapter); $this->publicKeySerializer = EcSerializer::getSerializer(PublicKeySerializerInterface::class, true, $ecAdapter); diff --git a/src/Serializer/Key/PrivateKey/WifPrivateKeySerializer.php b/src/Serializer/Key/PrivateKey/WifPrivateKeySerializer.php index 112ece49d..a49e23c90 100644 --- a/src/Serializer/Key/PrivateKey/WifPrivateKeySerializer.php +++ b/src/Serializer/Key/PrivateKey/WifPrivateKeySerializer.php @@ -55,7 +55,7 @@ public function serialize(NetworkInterface $network, PrivateKeyInterface $privat * @throws InvalidPrivateKey * @throws \Exception */ - public function parse(string $wif, NetworkInterface $network = null): PrivateKeyInterface + public function parse(string $wif, ?NetworkInterface $network = null): PrivateKeyInterface { $network = $network ?: Bitcoin::getNetwork(); $data = Base58::decodeCheck($wif); diff --git a/src/Serializer/Transaction/TransactionInputSerializer.php b/src/Serializer/Transaction/TransactionInputSerializer.php index 984136fb0..abbc9e951 100644 --- a/src/Serializer/Transaction/TransactionInputSerializer.php +++ b/src/Serializer/Transaction/TransactionInputSerializer.php @@ -40,7 +40,7 @@ class TransactionInputSerializer * @param OutPointSerializerInterface $outPointSerializer * @param Opcodes|null $opcodes */ - public function __construct(OutPointSerializerInterface $outPointSerializer, Opcodes $opcodes = null) + public function __construct(OutPointSerializerInterface $outPointSerializer, ?Opcodes $opcodes = null) { $this->outpointSerializer = $outPointSerializer; $this->varstring = Types::varstring(); diff --git a/src/Serializer/Transaction/TransactionOutputSerializer.php b/src/Serializer/Transaction/TransactionOutputSerializer.php index 5d2daf7a5..266c5d989 100644 --- a/src/Serializer/Transaction/TransactionOutputSerializer.php +++ b/src/Serializer/Transaction/TransactionOutputSerializer.php @@ -34,7 +34,7 @@ class TransactionOutputSerializer * TransactionOutputSerializer constructor. * @param Opcodes|null $opcodes */ - public function __construct(Opcodes $opcodes = null) + public function __construct(?Opcodes $opcodes = null) { $this->uint64le = Types::uint64le(); $this->varstring = Types::varstring(); diff --git a/src/Serializer/Transaction/TransactionSerializer.php b/src/Serializer/Transaction/TransactionSerializer.php index ee337b823..a14aabd0d 100644 --- a/src/Serializer/Transaction/TransactionSerializer.php +++ b/src/Serializer/Transaction/TransactionSerializer.php @@ -46,7 +46,7 @@ class TransactionSerializer implements TransactionSerializerInterface */ protected $witnessSerializer; - public function __construct(TransactionInputSerializer $inputSerializer = null, TransactionOutputSerializer $outputSerializer = null, ScriptWitnessSerializer $witnessSerializer = null) + public function __construct(?TransactionInputSerializer $inputSerializer = null, ?TransactionOutputSerializer $outputSerializer = null, ?ScriptWitnessSerializer $witnessSerializer = null) { $this->int32le = Types::int32le(); $this->uint32le = Types::uint32le(); diff --git a/src/Signature/SignatureFactory.php b/src/Signature/SignatureFactory.php index cb3747269..965707e03 100644 --- a/src/Signature/SignatureFactory.php +++ b/src/Signature/SignatureFactory.php @@ -20,7 +20,7 @@ class SignatureFactory * @return SignatureInterface * @throws \Exception */ - public static function fromHex(string $string, EcAdapterInterface $ecAdapter = null): SignatureInterface + public static function fromHex(string $string, ?EcAdapterInterface $ecAdapter = null): SignatureInterface { return self::fromBuffer(Buffer::hex($string), $ecAdapter); } @@ -30,7 +30,7 @@ public static function fromHex(string $string, EcAdapterInterface $ecAdapter = n * @param EcAdapterInterface|null $ecAdapter * @return SignatureInterface */ - public static function fromBuffer(BufferInterface $buffer, EcAdapterInterface $ecAdapter = null): SignatureInterface + public static function fromBuffer(BufferInterface $buffer, ?EcAdapterInterface $ecAdapter = null): SignatureInterface { /** @var DerSignatureSerializerInterface $serializer */ $serializer = EcSerializer::getSerializer(DerSignatureSerializerInterface::class, true, $ecAdapter); diff --git a/src/Signature/SignatureSort.php b/src/Signature/SignatureSort.php index 6187f4ca5..d5f00c5fc 100644 --- a/src/Signature/SignatureSort.php +++ b/src/Signature/SignatureSort.php @@ -19,7 +19,7 @@ class SignatureSort implements SignatureSortInterface * SignatureSort constructor. * @param EcAdapterInterface $ecAdapter */ - public function __construct(EcAdapterInterface $ecAdapter = null) + public function __construct(?EcAdapterInterface $ecAdapter = null) { $this->ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter(); } diff --git a/src/Signature/TransactionSignatureFactory.php b/src/Signature/TransactionSignatureFactory.php index dd83bd3ee..59d14fbd4 100644 --- a/src/Signature/TransactionSignatureFactory.php +++ b/src/Signature/TransactionSignatureFactory.php @@ -19,7 +19,7 @@ class TransactionSignatureFactory * @return TransactionSignatureInterface * @throws \Exception */ - public static function fromHex(string $string, EcAdapterInterface $ecAdapter = null): TransactionSignatureInterface + public static function fromHex(string $string, ?EcAdapterInterface $ecAdapter = null): TransactionSignatureInterface { return self::fromBuffer(Buffer::hex($string), $ecAdapter); } @@ -30,7 +30,7 @@ public static function fromHex(string $string, EcAdapterInterface $ecAdapter = n * @return TransactionSignatureInterface * @throws \Exception */ - public static function fromBuffer(BufferInterface $buffer, EcAdapterInterface $ecAdapter = null): TransactionSignatureInterface + public static function fromBuffer(BufferInterface $buffer, ?EcAdapterInterface $ecAdapter = null): TransactionSignatureInterface { $serializer = new TransactionSignatureSerializer( EcSerializer::getSerializer(DerSignatureSerializerInterface::class, true, $ecAdapter) diff --git a/src/Transaction/Factory/Checksig.php b/src/Transaction/Factory/Checksig.php index cb599d239..84e2840de 100644 --- a/src/Transaction/Factory/Checksig.php +++ b/src/Transaction/Factory/Checksig.php @@ -247,7 +247,7 @@ public function getKey(int $idx) * @param PublicKeyInterface|null $key * @return $this */ - public function setKey(int $idx, PublicKeyInterface $key = null) + public function setKey(int $idx, ?PublicKeyInterface $key = null) { if ($idx < 0 || $idx > $this->keyCount) { throw new \RuntimeException("Out of range index for public key"); diff --git a/src/Transaction/Factory/InputSigner.php b/src/Transaction/Factory/InputSigner.php index bf4a07781..14ca35f81 100644 --- a/src/Transaction/Factory/InputSigner.php +++ b/src/Transaction/Factory/InputSigner.php @@ -166,8 +166,8 @@ public function __construct( TransactionOutputInterface $txOut, SignData $signData, CheckerBase $checker, - TransactionSignatureSerializer $sigSerializer = null, - PublicKeySerializerInterface $pubKeySerializer = null + ?TransactionSignatureSerializer $sigSerializer = null, + ?PublicKeySerializerInterface $pubKeySerializer = null ) { $this->ecAdapter = $ecAdapter; $this->tx = $tx; @@ -1029,7 +1029,7 @@ public function sign(PrivateKeyInterface $privateKey, int $sigHashType = SigHash * @param int $flags * @return bool */ - public function verify(int $flags = null): bool + public function verify(?int $flags = null): bool { $consensus = ScriptFactory::consensus(); diff --git a/src/Transaction/Factory/InputSignerInterface.php b/src/Transaction/Factory/InputSignerInterface.php index 5684274e5..2b9b117f5 100644 --- a/src/Transaction/Factory/InputSignerInterface.php +++ b/src/Transaction/Factory/InputSignerInterface.php @@ -93,7 +93,7 @@ public function sign(PrivateKeyInterface $privateKey, int $sigHashType = SigHash * @param int $flags * @return bool */ - public function verify(int $flags = null): bool; + public function verify(?int $flags = null): bool; /** * Produces a SigValues instance containing the scriptSig & script witness diff --git a/src/Transaction/Factory/Signer.php b/src/Transaction/Factory/Signer.php index a61c877d2..dc5c89e26 100644 --- a/src/Transaction/Factory/Signer.php +++ b/src/Transaction/Factory/Signer.php @@ -71,7 +71,7 @@ class Signer * @param TransactionInterface $tx * @param EcAdapterInterface $ecAdapter */ - public function __construct(TransactionInterface $tx, EcAdapterInterface $ecAdapter = null) + public function __construct(TransactionInterface $tx, ?EcAdapterInterface $ecAdapter = null) { $this->tx = $tx; $this->ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter(); @@ -133,7 +133,7 @@ public function allowComplexScripts(bool $setting) * @param int $sigHashType * @return $this */ - public function sign(int $nIn, PrivateKeyInterface $key, TransactionOutputInterface $txOut, SignData $signData = null, int $sigHashType = SigHash::ALL) + public function sign(int $nIn, PrivateKeyInterface $key, TransactionOutputInterface $txOut, ?SignData $signData = null, int $sigHashType = SigHash::ALL) { $input = $this->input($nIn, $txOut, $signData); foreach ($input->getSteps() as $idx => $step) { @@ -149,7 +149,7 @@ public function sign(int $nIn, PrivateKeyInterface $key, TransactionOutputInterf * @param SignData|null $signData * @return InputSignerInterface */ - public function input(int $nIn, TransactionOutputInterface $txOut, SignData $signData = null): InputSignerInterface + public function input(int $nIn, TransactionOutputInterface $txOut, ?SignData $signData = null): InputSignerInterface { if (null === $signData) { $signData = new SignData(); diff --git a/src/Transaction/Factory/TxBuilder.php b/src/Transaction/Factory/TxBuilder.php index 08cd5470e..8332ffa67 100644 --- a/src/Transaction/Factory/TxBuilder.php +++ b/src/Transaction/Factory/TxBuilder.php @@ -110,7 +110,7 @@ public function version(int $nVersion) * @param int $nSequence * @return $this */ - public function input($hashPrevOut, int $nPrevOut, ScriptInterface $script = null, int $nSequence = TransactionInputInterface::SEQUENCE_FINAL) + public function input($hashPrevOut, int $nPrevOut, ?ScriptInterface $script = null, int $nSequence = TransactionInputInterface::SEQUENCE_FINAL) { if ($hashPrevOut instanceof BufferInterface) { if ($hashPrevOut->getSize() !== 32) { @@ -221,7 +221,7 @@ public function lockToBlockHeight(Locktime $lockTime, int $blockHeight) * @param int $nSequence * @return $this */ - public function spendOutPoint(OutPointInterface $outpoint, ScriptInterface $script = null, int $nSequence = TransactionInputInterface::SEQUENCE_FINAL) + public function spendOutPoint(OutPointInterface $outpoint, ?ScriptInterface $script = null, int $nSequence = TransactionInputInterface::SEQUENCE_FINAL) { $this->inputs[] = new TransactionInput( $outpoint, @@ -239,7 +239,7 @@ public function spendOutPoint(OutPointInterface $outpoint, ScriptInterface $scri * @param int $nSequence * @return $this */ - public function spendOutputFrom(TransactionInterface $transaction, int $outputToSpend, ScriptInterface $script = null, int $nSequence = TransactionInputInterface::SEQUENCE_FINAL) + public function spendOutputFrom(TransactionInterface $transaction, int $outputToSpend, ?ScriptInterface $script = null, int $nSequence = TransactionInputInterface::SEQUENCE_FINAL) { // Check TransactionOutput exists in $tx $transaction->getOutput($outputToSpend); diff --git a/src/Transaction/SignatureHash/V1Hasher.php b/src/Transaction/SignatureHash/V1Hasher.php index 9ac7e9722..41d7ff0aa 100644 --- a/src/Transaction/SignatureHash/V1Hasher.php +++ b/src/Transaction/SignatureHash/V1Hasher.php @@ -46,8 +46,8 @@ class V1Hasher extends SigHash public function __construct( TransactionInterface $transaction, int $amount, - OutPointSerializerInterface $outpointSerializer = null, - TransactionOutputSerializer $outputSerializer = null + ?OutPointSerializerInterface $outpointSerializer = null, + ?TransactionOutputSerializer $outputSerializer = null ) { $this->amount = $amount; $this->outputSerializer = $outputSerializer ?: new TransactionOutputSerializer(); diff --git a/src/Uri.php b/src/Uri.php index 4af902c63..764112025 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -52,7 +52,7 @@ class Uri * @param AddressInterface|null $address * @param int $convention */ - public function __construct(AddressInterface $address = null, int $convention = self::BIP0021) + public function __construct(?AddressInterface $address = null, int $convention = self::BIP0021) { if ($convention === self::BIP0021) { if ($address === null) { @@ -123,7 +123,7 @@ public function setRequestUrl(string $url) * @param NetworkInterface|null $network * @return string */ - public function uri(NetworkInterface $network = null): string + public function uri(?NetworkInterface $network = null): string { if ($this->rule === self::BIP0072) { $address = $this->bip72Address === null ? '' : $this->bip72Address->getAddress($network); From 27d8cac963f8eb76fadf0b1c42f6fd22f7b0f5f8 Mon Sep 17 00:00:00 2001 From: Fabien Salathe Date: Thu, 22 May 2025 06:22:24 +0900 Subject: [PATCH 2/3] Test newest and oldest supported version --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d2c805140..683fc9b57 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,9 +14,9 @@ jobs: strategy: matrix: php-version: - - 8.0 + - 7.1 - 8.1 - - 8.2 + - 8.4 steps: - name: Checkout code From 59a9d1dc30e979e569eccd7fe359136e97cc42f4 Mon Sep 17 00:00:00 2001 From: Fabien Salathe Date: Thu, 22 May 2025 06:25:59 +0900 Subject: [PATCH 3/3] Revert v7 test --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 683fc9b57..f091855fe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: php-version: - - 7.1 + - 8.0 - 8.1 - 8.4