Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
-
version: '8.4'
xdebug: '3.4.0'
-
version: '8.5'
xdebug: '3.5.0'
runs-on: ubuntu-22.04
steps:
-
Expand Down Expand Up @@ -94,6 +97,9 @@ jobs:
-
version: '8.4'
composer: --prefer-stable
-
version: '8.5'
composer: --prefer-stable
steps:
-
name: Download sources
Expand Down
6 changes: 3 additions & 3 deletions lib/avro/datum.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static function float_to_int_bits($float)
*/
static function double_to_long_bits($double)
{
return pack('d', (double) $double);
return pack('d', (float) $double);
}

/**
Expand Down Expand Up @@ -1014,7 +1014,7 @@ static public function int_bits_to_float($bits)
static public function long_bits_to_double($bits)
{
$double = unpack('d', $bits);
return (double) $double[1];
return (float) $double[1];
}

/**
Expand Down Expand Up @@ -1060,7 +1060,7 @@ public function read_null() { return null; }
*/
public function read_boolean()
{
return (boolean) (1 == ord($this->next_byte()));
return (bool) (1 == ord($this->next_byte()));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions test/DatumIOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ function data_provider()
array('"float"', (float) 2.0, "\000\000\000@"),
array('"float"', (float) 9.0, "\000\000\020A"),

array('"double"', (double) -10.0, "\000\000\000\000\000\000$\300"),
array('"double"', (double) -1.0, "\000\000\000\000\000\000\360\277"),
array('"double"', (double) 0.0, "\000\000\000\000\000\000\000\000"),
array('"double"', (double) 2.0, "\000\000\000\000\000\000\000@"),
array('"double"', (double) 9.0, "\000\000\000\000\000\000\"@"),
array('"double"', (float) -10.0, "\000\000\000\000\000\000$\300"),
array('"double"', (float) -1.0, "\000\000\000\000\000\000\360\277"),
array('"double"', (float) 0.0, "\000\000\000\000\000\000\000\000"),
array('"double"', (float) 2.0, "\000\000\000\000\000\000\000@"),
array('"double"', (float) 9.0, "\000\000\000\000\000\000\"@"),

array('"string"', 'foo', "\x06foo"),
array('"bytes"', "\x01\x02\x03", "\x06\x01\x02\x03"),
Expand Down Expand Up @@ -183,7 +183,7 @@ function default_provider()
array('"int"', '1', 1),
array('"long"', '2000', 2000),
array('"float"', '1.1', (float) 1.1),
array('"double"', '200.2', (double) 200.2),
array('"double"', '200.2', (float) 200.2),
array('"string"', '"quux"', 'quux'),
array('"bytes"', '"\u00FF"', "\xC3\xBF"),
array('{"type":"array","items":"int"}',
Expand Down
52 changes: 26 additions & 26 deletions test/FloatIntEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class FloatIntEncodingTest extends \PHPUnit\Framework\TestCase

static function make_special_vals()
{
self::$DOUBLE_NAN = (double) NAN;
self::$DOUBLE_POS_INF = (double) INF;
self::$DOUBLE_NEG_INF = (double) -INF;
self::$DOUBLE_NAN = (float) NAN;
self::$DOUBLE_POS_INF = (float) INF;
self::$DOUBLE_NEG_INF = (float) -INF;
self::$FLOAT_NAN = (float) NAN;
self::$FLOAT_POS_INF = (float) INF;
self::$FLOAT_NEG_INF = (float) -INF;
Expand Down Expand Up @@ -144,29 +144,29 @@ function test_encoding_nan_values($type, $val, $bits)
function normal_vals_provider()
{
return array(
array(self::DOUBLE_TYPE, (double) -10, "\000\000\000\000\000\000$\300", '000000000000420c'),
array(self::DOUBLE_TYPE, (double) -9, "\000\000\000\000\000\000\"\300", '000000000000220c'),
array(self::DOUBLE_TYPE, (double) -8, "\000\000\000\000\000\000 \300", '000000000000020c'),
array(self::DOUBLE_TYPE, (double) -7, "\000\000\000\000\000\000\034\300", '000000000000c10c'),
array(self::DOUBLE_TYPE, (double) -6, "\000\000\000\000\000\000\030\300", '000000000000810c'),
array(self::DOUBLE_TYPE, (double) -5, "\000\000\000\000\000\000\024\300", '000000000000410c'),
array(self::DOUBLE_TYPE, (double) -4, "\000\000\000\000\000\000\020\300", '000000000000010c'),
/**/ array(self::DOUBLE_TYPE, (double) -3, "\000\000\000\000\000\000\010\300", '000000000000800c'),
array(self::DOUBLE_TYPE, (double) -2, "\000\000\000\000\000\000\000\300", '000000000000000c'),
array(self::DOUBLE_TYPE, (double) -1, "\000\000\000\000\000\000\360\277", '0000000000000ffb'),
array(self::DOUBLE_TYPE, (double) 0, "\000\000\000\000\000\000\000\000", '0000000000000000'),
array(self::DOUBLE_TYPE, (double) 1, "\000\000\000\000\000\000\360?", '0000000000000ff3'),
array(self::DOUBLE_TYPE, (double) 2, "\000\000\000\000\000\000\000@", '0000000000000004'),
/**/ array(self::DOUBLE_TYPE, (double) 3, "\000\000\000\000\000\000\010@", '0000000000008004'),
array(self::DOUBLE_TYPE, (double) 4, "\000\000\000\000\000\000\020@", '0000000000000104'),
array(self::DOUBLE_TYPE, (double) 5, "\000\000\000\000\000\000\024@", '0000000000004104'),
array(self::DOUBLE_TYPE, (double) 6, "\000\000\000\000\000\000\030@", '0000000000008104'),
array(self::DOUBLE_TYPE, (double) 7, "\000\000\000\000\000\000\034@", '000000000000c104'),
array(self::DOUBLE_TYPE, (double) 8, "\000\000\000\000\000\000 @", '0000000000000204'),
array(self::DOUBLE_TYPE, (double) 9, "\000\000\000\000\000\000\"@", '0000000000002204'),
array(self::DOUBLE_TYPE, (double) 10, "\000\000\000\000\000\000$@", '0000000000004204'),
/**/ array(self::DOUBLE_TYPE, (double) -1234.2132, "\007\316\031Q\332H\223\300", '70ec9115ad84390c'),
array(self::DOUBLE_TYPE, (double) -2.11e+25, "\311\260\276J\031t1\305", '9c0beba49147135c'),
array(self::DOUBLE_TYPE, (float) -10, "\000\000\000\000\000\000$\300", '000000000000420c'),
array(self::DOUBLE_TYPE, (float) -9, "\000\000\000\000\000\000\"\300", '000000000000220c'),
array(self::DOUBLE_TYPE, (float) -8, "\000\000\000\000\000\000 \300", '000000000000020c'),
array(self::DOUBLE_TYPE, (float) -7, "\000\000\000\000\000\000\034\300", '000000000000c10c'),
array(self::DOUBLE_TYPE, (float) -6, "\000\000\000\000\000\000\030\300", '000000000000810c'),
array(self::DOUBLE_TYPE, (float) -5, "\000\000\000\000\000\000\024\300", '000000000000410c'),
array(self::DOUBLE_TYPE, (float) -4, "\000\000\000\000\000\000\020\300", '000000000000010c'),
/**/ array(self::DOUBLE_TYPE, (float) -3, "\000\000\000\000\000\000\010\300", '000000000000800c'),
array(self::DOUBLE_TYPE, (float) -2, "\000\000\000\000\000\000\000\300", '000000000000000c'),
array(self::DOUBLE_TYPE, (float) -1, "\000\000\000\000\000\000\360\277", '0000000000000ffb'),
array(self::DOUBLE_TYPE, (float) 0, "\000\000\000\000\000\000\000\000", '0000000000000000'),
array(self::DOUBLE_TYPE, (float) 1, "\000\000\000\000\000\000\360?", '0000000000000ff3'),
array(self::DOUBLE_TYPE, (float) 2, "\000\000\000\000\000\000\000@", '0000000000000004'),
/**/ array(self::DOUBLE_TYPE, (float) 3, "\000\000\000\000\000\000\010@", '0000000000008004'),
array(self::DOUBLE_TYPE, (float) 4, "\000\000\000\000\000\000\020@", '0000000000000104'),
array(self::DOUBLE_TYPE, (float) 5, "\000\000\000\000\000\000\024@", '0000000000004104'),
array(self::DOUBLE_TYPE, (float) 6, "\000\000\000\000\000\000\030@", '0000000000008104'),
array(self::DOUBLE_TYPE, (float) 7, "\000\000\000\000\000\000\034@", '000000000000c104'),
array(self::DOUBLE_TYPE, (float) 8, "\000\000\000\000\000\000 @", '0000000000000204'),
array(self::DOUBLE_TYPE, (float) 9, "\000\000\000\000\000\000\"@", '0000000000002204'),
array(self::DOUBLE_TYPE, (float) 10, "\000\000\000\000\000\000$@", '0000000000004204'),
/**/ array(self::DOUBLE_TYPE, (float) -1234.2132, "\007\316\031Q\332H\223\300", '70ec9115ad84390c'),
array(self::DOUBLE_TYPE, (float) -2.11e+25, "\311\260\276J\031t1\305", '9c0beba49147135c'),

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