Upgrade Notes#
Upgrade from 3.x to 4.x#
The package was renamed from
sandfoxme/bencode
toarokettu/bencode
The package namespace was changed from
SandFox\Bencode
toArokettu\Bencode
A custom autoloader to alias
SandFox\Bencode
toArokettu\Bencode
was 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
, andbigInt
must 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\BigInt
andBencode\Collection
are now enums, thereforedictType
,listType
,bigInt
params 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: true
to 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] );
bencodeSerialize
now declaresmixed
return type.
Upgrade from 1.x to 2.x#
Main breaking changes:
Required PHP version was bumped to 8.0. Upgrade your interpreter.
Legacy namespace
SandFoxMe
was removed. You should search and replaceSandFoxMe\Bencode
withSandFox\Bencode
in your code if you haven’t done it already.