Skip to content

Commit 53d3d9e

Browse files
Merge pull request #71 from Hi-Folks/upgrade-php-8
php 8 compatibility
2 parents 47971fe + 9e8536a commit 53d3d9e

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:37:"PHPUnit\Runner\DefaultTestResultCache":4371:{a:2:{s:7:"defects";a:3:{s:75:"HiFolks\RandoPhp\Tests\DrawSampleTest::random_extract_keys_with_empty_stuff";i:4;s:50:"HiFolks\RandoPhp\Tests\RandomByteTest::random_byte";i:3;s:70:"HiFolks\RandoPhp\Tests\RandomIntegerTest::random_integer_min_max_wrong";i:3;}s:5:"times";a:50:{s:53:"HiFolks\RandoPhp\Tests\DrawSampleTest::random_extract";d:0.008;s:64:"HiFolks\RandoPhp\Tests\DrawSampleTest::random_extract_duplicates";d:0.002;s:58:"HiFolks\RandoPhp\Tests\DrawSampleTest::random_extract_keys";d:0.001;s:75:"HiFolks\RandoPhp\Tests\DrawSampleTest::random_extract_keys_with_empty_stuff";d:0.005;s:61:"HiFolks\RandoPhp\Tests\DrawSampleTest::random_extract_implode";d:0.001;s:66:"HiFolks\RandoPhp\Tests\DrawSampleTest::random_extract_preservekeys";d:0.002;s:74:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::load_boolean_test";d:0.002;s:74:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::load_integer_test";d:0.002;s:72:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::load_float_test";d:0.002;s:71:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::load_byte_test";d:0.002;s:75:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::load_sequence_test";d:0.002;s:75:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::load_datetime_test";d:0.002;s:71:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::load_char_test";d:0.002;s:74:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::load_latlong_test";d:0.002;s:87:"HiFolks\RandoPhp\Tests\LoadModelsWithMagicFunctionsTest::model_not_found_exception_test";d:0.002;s:56:"HiFolks\RandoPhp\Tests\RandomBooleanTest::random_boolean";d:0.004;s:50:"HiFolks\RandoPhp\Tests\RandomByteTest::random_byte";d:0.005;s:56:"HiFolks\RandoPhp\Tests\RandomCharTest::it_generates_char";d:0.001;s:62:"HiFolks\RandoPhp\Tests\RandomCharTest::it_generates_alpha_char";d:0.002;s:67:"HiFolks\RandoPhp\Tests\RandomCharTest::it_generates_lowercase_alpha";d:0.002;s:67:"HiFolks\RandoPhp\Tests\RandomCharTest::it_generates_uppercase_alpha";d:0.001;s:64:"HiFolks\RandoPhp\Tests\RandomCharTest::it_generates_numeric_char";d:0.002;s:69:"HiFolks\RandoPhp\Tests\RandomCharTest::it_generates_alphanumeric_char";d:0.002;s:79:"HiFolks\RandoPhp\Tests\RandomCharTest::it_generates_alphanumeric_lowercase_char";d:0.001;s:79:"HiFolks\RandoPhp\Tests\RandomCharTest::it_generates_alphanumeric_uppercase_char";d:0.002;s:58:"HiFolks\RandoPhp\Tests\RandomDateTimeTest::random_datetime";d:0.001;s:66:"HiFolks\RandoPhp\Tests\RandomDateTimeTest::random_datetime_min_max";d:0.001;s:65:"HiFolks\RandoPhp\Tests\RandomDateTimeTest::random_datetime_format";d:0.002;s:71:"HiFolks\RandoPhp\Tests\RandomDateTimeTest::random_datetime_range_format";d:0.002;s:52:"HiFolks\RandoPhp\Tests\RandomFloatTest::random_float";d:0.002;s:77:"HiFolks\RandoPhp\Tests\RandomFloatTest::random_float_min_max_types_validation";d:0.004;s:69:"HiFolks\RandoPhp\Tests\RandomFloatTest::random_float_min_max_decimals";d:0.009;s:56:"HiFolks\RandoPhp\Tests\RandomIntegerTest::random_integer";d:0.002;s:64:"HiFolks\RandoPhp\Tests\RandomIntegerTest::random_integer_min_max";d:0.002;s:70:"HiFolks\RandoPhp\Tests\RandomIntegerTest::random_integer_min_max_wrong";d:0.001;s:62:"HiFolks\RandoPhp\Tests\RandomLatLongTest::random_latlong_array";d:0.003;s:63:"HiFolks\RandoPhp\Tests\RandomLatLongTest::random_latlong_object";d:0.003;s:57:"HiFolks\RandoPhp\Tests\RandomLatLongTest::random_latitude";d:0.002;s:58:"HiFolks\RandoPhp\Tests\RandomLatLongTest::random_longitude";d:0.002;s:56:"HiFolks\RandoPhp\Tests\RandomLatLongTest::random_latlong";d:0.002;s:58:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_sequence";d:0.002;s:64:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_count_sequence";d:0.002;s:63:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_char_sequence";d:0.004;s:69:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_count_char_sequence";d:0.003;s:76:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_no_duplicate_char_sequence";d:0.002;s:71:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_numeric_char_sequence";d:0.005;s:61:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_rollthedice";d:0.018;s:57:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_tombola";d:0.042;s:66:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_sequence_implode";d:0.002;s:67:"HiFolks\RandoPhp\Tests\RandomSequenceTest::random_sequence_asString";d:0.002;}}}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^7.1"
23+
"php": "^7.1|^8.0"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "^7.0"
26+
"phpunit/phpunit": "^7.0|^8.0|^9.3"
2727
},
2828
"autoload": {
2929
"psr-4": {

src/Models/Sample.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public function noDuplicates()
101101
* Extract random keys from array.
102102
*
103103
* @return int[]|string[]|int|string|null
104-
* @throws \Exception
105104
*/
106105
public function extractKeys()
107106
{
@@ -122,7 +121,11 @@ public function extractKeys()
122121
shuffle($a);
123122
}
124123
} catch (\Exception $e) {
124+
return null;
125+
} catch (\Error $e) {
126+
return null;
125127
}
128+
126129
return $a;
127130
}
128131
} else {

tests/DrawSampleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function random_extract_keys_with_empty_stuff()
4747
$array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
4848
$count = 5;
4949
$sampleKeys = Draw::sample($array)->count(0)->extractKeys();
50+
$this->assertSame(null, $sampleKeys, "Null for count 0");
5051
$this->assertEmpty($sampleKeys, "Check extract key with 0 count");
5152
$sampleKeys = Draw::sample([])->count(2)->extractKeys();
5253
$this->assertEmpty($sampleKeys, "Check extract key with empty array");

tests/RandomByteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function random_byte()
2222
$byte = Randomize::byte()->length(0)->generate();
2323
} catch (\Error $e) {
2424
$catch = true;
25-
$this->assertStringContainsString("Length must be greater", $e->getMessage(), "Message Error test");
25+
$this->assertIsString($e->getMessage(), "Message Error");
2626
}
2727
$this->assertSame(true, $catch, "Exception catch");
2828

tests/RandomIntegerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public function random_integer_min_max_wrong()
4646
$this->assertGreaterThan(0, $e->getCode(), "Code exception test");
4747
} catch (\Error $e) {
4848
$catch = true;
49-
$this->assertStringContainsString("Minimum", $e->getMessage(), "Message Error test");
49+
$this->assertIsString($e->getMessage(), "Message Error");
50+
5051
}
5152
$this->assertSame(true, $catch, "Exception catch");
5253
}

0 commit comments

Comments
 (0)