Upgrade Notes#
Upgrade from 3.x to 4.x#
The package was renamed from
sandfoxme/bencodetoarokettu/bencodeThe package namespace was changed from
SandFox\BencodetoArokettu\BencodeA custom autoloader to alias
SandFox\BencodetoArokettu\Bencodewas added to 1.8.0, 2.8.0, and 3.1.0
Dictionaries are now converted to the ArrayObject by default
$options arrays were removed
Closures passed to
listType,dictType, andbigIntmust handle iterables instead of arrays nowClass names can no longer be passed to
listType,dictType, andbigInt<?php use Arokettu\Bencode\Bencode; // 3.x $data = Bencode::decode( "...", listType: CustomHandler::class, ); // should become in 4.0 $data = Bencode::decode( "...", listType: fn (iterable $list) => new CustomHandler([...$list]), );
Upgrade from 2.x to 3.x#
Main breaking changes:
Required PHP version was bumped to 8.1. Upgrade your interpreter.
Decoding:
Removed deprecated options:
dictionaryType(usedictType),useGMP(usebigInt: Bencode\BigInt::GMP)Bencode\BigIntandBencode\Collectionare now enums, thereforedictType,listType,bigIntparams no longer accept bare string values (like'array'or'object'or'gmp'). If you use constants, nothing will change for you.
Encoding:
Traversables no longer become dictionaries by default. You need to wrap them with
DictType.Stringables no longer become strings by default. Use
useStringable: trueto return old behavior.Bencode::dump($filename, $data)becameBencode::dump($data, $filename)for consistency with streams.<?php // Use Encoder object in 1.7+/2.7+/3.0+: $success = (new \SandFox\Bencode\Encoder([...$optionsHere]))->dump($data, $filename); // Or use named parameters in PHP 8.0+: $success = \SandFox\Bencode\Bencode::dump( data: $data, filename: $filename, [...$optionsHere] );
bencodeSerializenow declaresmixedreturn type.
Upgrade from 1.x to 2.x#
Main breaking changes:
Required PHP version was bumped to 8.0. Upgrade your interpreter.
Legacy namespace
SandFoxMewas removed. You should search and replaceSandFoxMe\BencodewithSandFox\Bencodein your code if you haven’t done it already.