Upgrade Notes#
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.