Skip to content

Commit 8c040b4

Browse files
authored
Fix PHP 8.5 deprecations (#29)
1 parent 1d537bf commit 8c040b4

File tree

4 files changed

+41
-35
lines changed

4 files changed

+41
-35
lines changed

.github/workflows/checks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
-
4141
version: '8.4'
4242
xdebug: '3.4.0'
43+
-
44+
version: '8.5'
45+
xdebug: '3.5.0'
4346
runs-on: ubuntu-22.04
4447
steps:
4548
-
@@ -94,6 +97,9 @@ jobs:
9497
-
9598
version: '8.4'
9699
composer: --prefer-stable
100+
-
101+
version: '8.5'
102+
composer: --prefer-stable
97103
steps:
98104
-
99105
name: Download sources

lib/avro/datum.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static function float_to_int_bits($float)
358358
*/
359359
static function double_to_long_bits($double)
360360
{
361-
return pack('d', (double) $double);
361+
return pack('d', (float) $double);
362362
}
363363

364364
/**
@@ -1014,7 +1014,7 @@ static public function int_bits_to_float($bits)
10141014
static public function long_bits_to_double($bits)
10151015
{
10161016
$double = unpack('d', $bits);
1017-
return (double) $double[1];
1017+
return (float) $double[1];
10181018
}
10191019

10201020
/**
@@ -1060,7 +1060,7 @@ public function read_null() { return null; }
10601060
*/
10611061
public function read_boolean()
10621062
{
1063-
return (boolean) (1 == ord($this->next_byte()));
1063+
return (bool) (1 == ord($this->next_byte()));
10641064
}
10651065

10661066
/**

test/DatumIOTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ function data_provider()
120120
array('"float"', (float) 2.0, "\000\000\000@"),
121121
array('"float"', (float) 9.0, "\000\000\020A"),
122122

123-
array('"double"', (double) -10.0, "\000\000\000\000\000\000$\300"),
124-
array('"double"', (double) -1.0, "\000\000\000\000\000\000\360\277"),
125-
array('"double"', (double) 0.0, "\000\000\000\000\000\000\000\000"),
126-
array('"double"', (double) 2.0, "\000\000\000\000\000\000\000@"),
127-
array('"double"', (double) 9.0, "\000\000\000\000\000\000\"@"),
123+
array('"double"', (float) -10.0, "\000\000\000\000\000\000$\300"),
124+
array('"double"', (float) -1.0, "\000\000\000\000\000\000\360\277"),
125+
array('"double"', (float) 0.0, "\000\000\000\000\000\000\000\000"),
126+
array('"double"', (float) 2.0, "\000\000\000\000\000\000\000@"),
127+
array('"double"', (float) 9.0, "\000\000\000\000\000\000\"@"),
128128

129129
array('"string"', 'foo', "\x06foo"),
130130
array('"bytes"', "\x01\x02\x03", "\x06\x01\x02\x03"),
@@ -183,7 +183,7 @@ function default_provider()
183183
array('"int"', '1', 1),
184184
array('"long"', '2000', 2000),
185185
array('"float"', '1.1', (float) 1.1),
186-
array('"double"', '200.2', (double) 200.2),
186+
array('"double"', '200.2', (float) 200.2),
187187
array('"string"', '"quux"', 'quux'),
188188
array('"bytes"', '"\u00FF"', "\xC3\xBF"),
189189
array('{"type":"array","items":"int"}',

test/FloatIntEncodingTest.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class FloatIntEncodingTest extends \PHPUnit\Framework\TestCase
4242

4343
static function make_special_vals()
4444
{
45-
self::$DOUBLE_NAN = (double) NAN;
46-
self::$DOUBLE_POS_INF = (double) INF;
47-
self::$DOUBLE_NEG_INF = (double) -INF;
45+
self::$DOUBLE_NAN = (float) NAN;
46+
self::$DOUBLE_POS_INF = (float) INF;
47+
self::$DOUBLE_NEG_INF = (float) -INF;
4848
self::$FLOAT_NAN = (float) NAN;
4949
self::$FLOAT_POS_INF = (float) INF;
5050
self::$FLOAT_NEG_INF = (float) -INF;
@@ -144,29 +144,29 @@ function test_encoding_nan_values($type, $val, $bits)
144144
function normal_vals_provider()
145145
{
146146
return array(
147-
array(self::DOUBLE_TYPE, (double) -10, "\000\000\000\000\000\000$\300", '000000000000420c'),
148-
array(self::DOUBLE_TYPE, (double) -9, "\000\000\000\000\000\000\"\300", '000000000000220c'),
149-
array(self::DOUBLE_TYPE, (double) -8, "\000\000\000\000\000\000 \300", '000000000000020c'),
150-
array(self::DOUBLE_TYPE, (double) -7, "\000\000\000\000\000\000\034\300", '000000000000c10c'),
151-
array(self::DOUBLE_TYPE, (double) -6, "\000\000\000\000\000\000\030\300", '000000000000810c'),
152-
array(self::DOUBLE_TYPE, (double) -5, "\000\000\000\000\000\000\024\300", '000000000000410c'),
153-
array(self::DOUBLE_TYPE, (double) -4, "\000\000\000\000\000\000\020\300", '000000000000010c'),
154-
/**/ array(self::DOUBLE_TYPE, (double) -3, "\000\000\000\000\000\000\010\300", '000000000000800c'),
155-
array(self::DOUBLE_TYPE, (double) -2, "\000\000\000\000\000\000\000\300", '000000000000000c'),
156-
array(self::DOUBLE_TYPE, (double) -1, "\000\000\000\000\000\000\360\277", '0000000000000ffb'),
157-
array(self::DOUBLE_TYPE, (double) 0, "\000\000\000\000\000\000\000\000", '0000000000000000'),
158-
array(self::DOUBLE_TYPE, (double) 1, "\000\000\000\000\000\000\360?", '0000000000000ff3'),
159-
array(self::DOUBLE_TYPE, (double) 2, "\000\000\000\000\000\000\000@", '0000000000000004'),
160-
/**/ array(self::DOUBLE_TYPE, (double) 3, "\000\000\000\000\000\000\010@", '0000000000008004'),
161-
array(self::DOUBLE_TYPE, (double) 4, "\000\000\000\000\000\000\020@", '0000000000000104'),
162-
array(self::DOUBLE_TYPE, (double) 5, "\000\000\000\000\000\000\024@", '0000000000004104'),
163-
array(self::DOUBLE_TYPE, (double) 6, "\000\000\000\000\000\000\030@", '0000000000008104'),
164-
array(self::DOUBLE_TYPE, (double) 7, "\000\000\000\000\000\000\034@", '000000000000c104'),
165-
array(self::DOUBLE_TYPE, (double) 8, "\000\000\000\000\000\000 @", '0000000000000204'),
166-
array(self::DOUBLE_TYPE, (double) 9, "\000\000\000\000\000\000\"@", '0000000000002204'),
167-
array(self::DOUBLE_TYPE, (double) 10, "\000\000\000\000\000\000$@", '0000000000004204'),
168-
/**/ array(self::DOUBLE_TYPE, (double) -1234.2132, "\007\316\031Q\332H\223\300", '70ec9115ad84390c'),
169-
array(self::DOUBLE_TYPE, (double) -2.11e+25, "\311\260\276J\031t1\305", '9c0beba49147135c'),
147+
array(self::DOUBLE_TYPE, (float) -10, "\000\000\000\000\000\000$\300", '000000000000420c'),
148+
array(self::DOUBLE_TYPE, (float) -9, "\000\000\000\000\000\000\"\300", '000000000000220c'),
149+
array(self::DOUBLE_TYPE, (float) -8, "\000\000\000\000\000\000 \300", '000000000000020c'),
150+
array(self::DOUBLE_TYPE, (float) -7, "\000\000\000\000\000\000\034\300", '000000000000c10c'),
151+
array(self::DOUBLE_TYPE, (float) -6, "\000\000\000\000\000\000\030\300", '000000000000810c'),
152+
array(self::DOUBLE_TYPE, (float) -5, "\000\000\000\000\000\000\024\300", '000000000000410c'),
153+
array(self::DOUBLE_TYPE, (float) -4, "\000\000\000\000\000\000\020\300", '000000000000010c'),
154+
/**/ array(self::DOUBLE_TYPE, (float) -3, "\000\000\000\000\000\000\010\300", '000000000000800c'),
155+
array(self::DOUBLE_TYPE, (float) -2, "\000\000\000\000\000\000\000\300", '000000000000000c'),
156+
array(self::DOUBLE_TYPE, (float) -1, "\000\000\000\000\000\000\360\277", '0000000000000ffb'),
157+
array(self::DOUBLE_TYPE, (float) 0, "\000\000\000\000\000\000\000\000", '0000000000000000'),
158+
array(self::DOUBLE_TYPE, (float) 1, "\000\000\000\000\000\000\360?", '0000000000000ff3'),
159+
array(self::DOUBLE_TYPE, (float) 2, "\000\000\000\000\000\000\000@", '0000000000000004'),
160+
/**/ array(self::DOUBLE_TYPE, (float) 3, "\000\000\000\000\000\000\010@", '0000000000008004'),
161+
array(self::DOUBLE_TYPE, (float) 4, "\000\000\000\000\000\000\020@", '0000000000000104'),
162+
array(self::DOUBLE_TYPE, (float) 5, "\000\000\000\000\000\000\024@", '0000000000004104'),
163+
array(self::DOUBLE_TYPE, (float) 6, "\000\000\000\000\000\000\030@", '0000000000008104'),
164+
array(self::DOUBLE_TYPE, (float) 7, "\000\000\000\000\000\000\034@", '000000000000c104'),
165+
array(self::DOUBLE_TYPE, (float) 8, "\000\000\000\000\000\000 @", '0000000000000204'),
166+
array(self::DOUBLE_TYPE, (float) 9, "\000\000\000\000\000\000\"@", '0000000000002204'),
167+
array(self::DOUBLE_TYPE, (float) 10, "\000\000\000\000\000\000$@", '0000000000004204'),
168+
/**/ array(self::DOUBLE_TYPE, (float) -1234.2132, "\007\316\031Q\332H\223\300", '70ec9115ad84390c'),
169+
array(self::DOUBLE_TYPE, (float) -2.11e+25, "\311\260\276J\031t1\305", '9c0beba49147135c'),
170170

171171
array(self::FLOAT_TYPE, (float) -10, "\000\000 \301", '0000021c'),
172172
array(self::FLOAT_TYPE, (float) -9, "\000\000\020\301", '0000011c'),

0 commit comments

Comments
 (0)