Skip to content

Commit

Permalink
Merge pull request #72 from Hi-Folks/feat/fix-deprecation-php-84
Browse files Browse the repository at this point in the history
Fix deprecation for PHP 8.4
  • Loading branch information
roberto-butti authored Nov 23, 2024
2 parents e32a0b4 + 1eaacf4 commit e626ec1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.2 - WIP

- Fix deprecations for PHP 8.4

## 1.0.1 - 2024-11-21

- Welcome PHP 8.4
Expand Down
3 changes: 1 addition & 2 deletions src/Freq.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,9 @@ public static function frequencyTableBySize(array $data, int $chunkSize = 1): ar
* each class is not a range.
*
* @param mixed[] $data
* @param ?int $category
* @return int[]
*/
public static function frequencyTable(array $data, int $category = null): array
public static function frequencyTable(array $data, ?int $category = null): array
{
$result = [];
$min = floor((float) min($data));
Expand Down
2 changes: 1 addition & 1 deletion src/Stat.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public static function pvariance(array $data, ?int $round = null): float
*
* @return float the standard deviation of the numeric data
*/
public static function stdev(array $data, int $round = null): float
public static function stdev(array $data, ?int $round = null): float
{
$variance = self::variance($data);

Expand Down
2 changes: 1 addition & 1 deletion src/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function frequencies(bool $transformToInteger = false): array
* @param int|null $round whether to round the result
* @return array<float>
*/
public function relativeFrequencies(int $round = null): array
public function relativeFrequencies(?int $round = null): array
{
return Freq::relativeFrequencies($this->values, $round);
}
Expand Down
8 changes: 7 additions & 1 deletion tests/StatFromCsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
if (($handle = fopen(getcwd() . '/tests/data/income.data.csv', 'r')) !== false) {
$x = [];
$y = [];
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
while (($data = fgetcsv(
$handle,
1000,
separator: ',',
enclosure: '"',
escape: "",
)) !== false) {
$num = count($data);
expect($num)->toEqual(3);
$row++;
Expand Down

0 comments on commit e626ec1

Please sign in to comment.