Skip to content

Commit f4dbc2f

Browse files
committed
Fix PHP 8.2 deprecation errors
1 parent eb9f81e commit f4dbc2f

1 file changed

Lines changed: 60 additions & 1 deletion

File tree

lib/openpgp.php

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ function body() {
538538
}
539539

540540
function header_and_body() {
541-
$body = $this->body(); // Get body first, we will need it's length
541+
$body = $this->body() ?? ''; // Get body first, we will need it's length
542542
$tag = chr($this->tag | 0xC0); // First two bits are 1 for new packet format
543543
$size = chr(255).pack('N', strlen($body)); // Use 5-octet lengths
544544
return array('header' => $tag.$size, 'body' => $body);
@@ -616,6 +616,10 @@ function read_bytes($count = 1) {
616616
class OpenPGP_AsymmetricSessionKeyPacket extends OpenPGP_Packet {
617617
public $version, $keyid, $key_algorithm, $encrypted_data;
618618

619+
public $input;
620+
621+
public $length;
622+
619623
function __construct($key_algorithm='', $keyid='', $encrypted_data='', $version=3) {
620624
parent::__construct();
621625
$this->version = $version;
@@ -665,6 +669,10 @@ class OpenPGP_SignaturePacket extends OpenPGP_Packet {
665669
public $version, $signature_type, $hash_algorithm, $key_algorithm, $hashed_subpackets, $unhashed_subpackets, $hash_head;
666670
public $trailer; // This is the literal bytes that get tacked on the end of the message when verifying the signature
667671

672+
public $input;
673+
674+
public $length;
675+
668676
function __construct($data=NULL, $key_algorithm=NULL, $hash_algorithm=NULL) {
669677
parent::__construct();
670678
$this->version = 4; // Default to version 4 sigs
@@ -941,6 +949,10 @@ static function class_for($tag) {
941949
}
942950

943951
class OpenPGP_SignaturePacket_Subpacket extends OpenPGP_Packet {
952+
public $input;
953+
954+
public $length;
955+
944956
function __construct($data=NULL) {
945957
parent::__construct($data);
946958
$this->tag = array_search(substr(substr(get_class($this), 8+16), 0, -6), OpenPGP_SignaturePacket::$subpacket_types);
@@ -1199,6 +1211,8 @@ function body() {
11991211
}
12001212

12011213
class OpenPGP_SignaturePacket_KeyFlagsPacket extends OpenPGP_SignaturePacket_Subpacket {
1214+
public $flags;
1215+
12021216
function __construct($flags=array()) {
12031217
parent::__construct();
12041218
$this->flags = $flags;
@@ -1286,6 +1300,10 @@ function header_and_body() {
12861300
class OpenPGP_SymmetricSessionKeyPacket extends OpenPGP_Packet {
12871301
public $version, $symmetric_algorithm, $s2k, $encrypted_data;
12881302

1303+
public $input;
1304+
1305+
public $length;
1306+
12891307
function __construct($s2k=NULL, $encrypted_data='', $symmetric_algorithm=9, $version=3) {
12901308
parent::__construct();
12911309
$this->version = $version;
@@ -1314,6 +1332,11 @@ function body() {
13141332
*/
13151333
class OpenPGP_OnePassSignaturePacket extends OpenPGP_Packet {
13161334
public $version, $signature_type, $hash_algorithm, $key_algorithm, $key_id, $nested;
1335+
1336+
public $input;
1337+
1338+
public $length;
1339+
13171340
function read() {
13181341
$this->version = ord($this->read_byte());
13191342
$this->signature_type = ord($this->read_byte());
@@ -1348,6 +1371,10 @@ class OpenPGP_PublicKeyPacket extends OpenPGP_Packet {
13481371
public $key, $key_id, $fingerprint;
13491372
public $v3_days_of_validity;
13501373

1374+
public $input;
1375+
1376+
public $length;
1377+
13511378
function __construct($key=array(), $algorithm='RSA', $timestamp=NULL, $version=4) {
13521379
parent::__construct();
13531380

@@ -1544,6 +1571,10 @@ function body() {
15441571
* @see http://tools.ietf.org/html/rfc4880#section-12
15451572
*/
15461573
class OpenPGP_PublicSubkeyPacket extends OpenPGP_PublicKeyPacket {
1574+
public $input;
1575+
1576+
public $length;
1577+
15471578
// TODO
15481579
}
15491580

@@ -1642,6 +1673,10 @@ class OpenPGP_CompressedDataPacket extends OpenPGP_Packet implements IteratorAgg
16421673
/* see http://tools.ietf.org/html/rfc4880#section-9.3 */
16431674
static $algorithms = array(0 => 'Uncompressed', 1 => 'ZIP', 2 => 'ZLIB', 3 => 'BZip2');
16441675

1676+
public $input;
1677+
1678+
public $length;
1679+
16451680
function __construct($m=NULL, $algorithm=1) {
16461681
parent::__construct();
16471682
$this->algorithm = $algorithm;
@@ -1730,6 +1765,10 @@ function offsetUnset($offset) {
17301765
* @see http://tools.ietf.org/html/rfc4880#section-5.7
17311766
*/
17321767
class OpenPGP_EncryptedDataPacket extends OpenPGP_Packet {
1768+
public $input;
1769+
1770+
public $length;
1771+
17331772
function read() {
17341773
$this->data = $this->input;
17351774
}
@@ -1756,6 +1795,10 @@ class OpenPGP_MarkerPacket extends OpenPGP_Packet {
17561795
class OpenPGP_LiteralDataPacket extends OpenPGP_Packet {
17571796
public $format, $filename, $timestamp;
17581797

1798+
public $input;
1799+
1800+
public $length;
1801+
17591802
function __construct($data=NULL, $opt=array()) {
17601803
parent::__construct();
17611804
$this->data = $data;
@@ -1800,6 +1843,10 @@ function body() {
18001843
* @see http://tools.ietf.org/html/rfc4880#section-5.10
18011844
*/
18021845
class OpenPGP_TrustPacket extends OpenPGP_Packet {
1846+
public $input;
1847+
1848+
public $length;
1849+
18031850
function read() {
18041851
$this->data = $this->input;
18051852
}
@@ -1818,6 +1865,10 @@ function body() {
18181865
class OpenPGP_UserIDPacket extends OpenPGP_Packet {
18191866
public $name, $comment, $email;
18201867

1868+
public $input;
1869+
1870+
public $length;
1871+
18211872
function __construct($name='', $comment='', $email='') {
18221873
parent::__construct();
18231874
if(!$comment && !$email) {
@@ -1880,6 +1931,10 @@ function body() {
18801931
class OpenPGP_UserAttributePacket extends OpenPGP_Packet {
18811932
public $packets;
18821933

1934+
public $input;
1935+
1936+
public $length;
1937+
18831938
// TODO
18841939
}
18851940

@@ -1891,6 +1946,10 @@ class OpenPGP_UserAttributePacket extends OpenPGP_Packet {
18911946
class OpenPGP_IntegrityProtectedDataPacket extends OpenPGP_EncryptedDataPacket {
18921947
public $version;
18931948

1949+
public $input;
1950+
1951+
public $length;
1952+
18941953
function __construct($data='', $version=1) {
18951954
parent::__construct();
18961955
$this->version = $version;

0 commit comments

Comments
 (0)