Skip to content

Commit c85f142

Browse files
authored
Fix php8.4 deprecated notices (#485)
1 parent e587bfe commit c85f142

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

src/Functions/BaseEncoderDecoder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static function toBase(ArbitraryInteger $number, int $base, $alphabet = n
9191
*
9292
* @throws Exception\BadParameterException if the string is empty or base is greater than 256
9393
*/
94-
public static function createArbitraryInteger(string $number, int $base, string $offset = null): ArbitraryInteger
94+
public static function createArbitraryInteger(string $number, int $base, ?string $offset = null): ArbitraryInteger
9595
{
9696
if ($number == '') {
9797
throw new Exception\BadParameterException("String cannot be empty.");

src/LinearAlgebra/MatrixFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public static function one(int $m, int $n): NumericMatrix
425425
* @throws Exception\MathException
426426
* @throws Exception\OutOfBoundsException if m, n, or k are < 0; if k >= n
427427
*/
428-
public static function eye(int $m, int $n, int $k, float $x = null): NumericMatrix
428+
public static function eye(int $m, int $n, int $k, ?float $x = null): NumericMatrix
429429
{
430430
if ($n < 0 || $m < 0 || $k < 0) {
431431
throw new Exception\OutOfBoundsException("m, n and k must be ≥ 0. m = $m, n = $n, k = $k");

src/LinearAlgebra/NumericMatrix.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3029,7 +3029,7 @@ private function solveRref(Vector $b): Vector
30293029
* @throws Exception\MatrixException if method is not a valid eigenvalue method
30303030
* @throws Exception\MathException
30313031
*/
3032-
public function eigenvalues(string $method = null): array
3032+
public function eigenvalues(?string $method = null): array
30333033
{
30343034
if (!$this->isSquare()) {
30353035
throw new Exception\MatrixException('Eigenvalues can only be calculated on square matrices');
@@ -3068,7 +3068,7 @@ public function eigenvalues(string $method = null): array
30683068
* @throws Exception\MatrixException if method is not a valid eigenvalue method
30693069
* @throws Exception\MathException
30703070
*/
3071-
public function eigenvectors(string $method = null): NumericMatrix
3071+
public function eigenvectors(?string $method = null): NumericMatrix
30723072
{
30733073
if ($method === null) {
30743074
return Eigenvector::eigenvectors($this, $this->eigenvalues());

src/Probability/Combinatorics.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public static function subfactorial(int $n): float
228228
*
229229
* @throws Exception\OutOfBoundsException if n is negative or k is larger than n
230230
*/
231-
public static function permutations(int $n, int $k = null): float
231+
public static function permutations(int $n, ?int $k = null): float
232232
{
233233
if ($n < 0) {
234234
throw new Exception\OutOfBoundsException('Cannot compute negative permutations.');

src/Statistics/Distance.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public static function jensenShannon(array $p, array $q): float
191191
* @throws Exception\OutOfBoundsException
192192
* @throws Exception\VectorException
193193
*/
194-
public static function mahalanobis(NumericMatrix $x, NumericMatrix $data, NumericMatrix $y = null): float
194+
public static function mahalanobis(NumericMatrix $x, NumericMatrix $data, ?NumericMatrix $y = null): float
195195
{
196196
$Centroid = $data->rowMeans()->asColumnMatrix();
197197
$Nx = $x->getN();

src/Statistics/KernelDensityEstimation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class KernelDensityEstimation
4949
* @throws Exception\OutOfBoundsException h ≤ 0
5050
* @throws Exception\BadParameterException
5151
*/
52-
public function __construct(array $data, float $h = null, $kernel = null)
52+
public function __construct(array $data, ?float $h = null, $kernel = null)
5353
{
5454
$this->n = \count($data);
5555
if ($this->n === 0) {
@@ -68,7 +68,7 @@ public function __construct(array $data, float $h = null, $kernel = null)
6868
*
6969
* @throws Exception\OutOfBoundsException if h ≤ 0
7070
*/
71-
public function setBandwidth(float $h = null): void
71+
public function setBandwidth(?float $h = null): void
7272
{
7373
if ($h === null) {
7474
$this->h = $this->getDefaultBandwidth();

src/Statistics/Multivariate/PCA.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private function checkNewData(NumericMatrix $newData): void
106106
*
107107
* @throws Exception\MathException
108108
*/
109-
public function standardizeData(NumericMatrix $new_data = null): NumericMatrix
109+
public function standardizeData(?NumericMatrix $new_data = null): NumericMatrix
110110
{
111111
if ($new_data === null) {
112112
$X = $this->data;
@@ -164,7 +164,7 @@ public function getEigenvalues(): Vector
164164
*
165165
* @throws Exception\MathException
166166
*/
167-
public function getScores(NumericMatrix $new_data = null): NumericMatrix
167+
public function getScores(?NumericMatrix $new_data = null): NumericMatrix
168168
{
169169
if ($new_data === null) {
170170
$scaled_data = $this->data;
@@ -220,7 +220,7 @@ public function getCumR2(): array
220220
*
221221
* @throws Exception\MathException
222222
*/
223-
public function getQResiduals(NumericMatrix $new_data = null): NumericMatrix
223+
public function getQResiduals(?NumericMatrix $new_data = null): NumericMatrix
224224
{
225225
$vars = $this->data->getN();
226226

@@ -265,7 +265,7 @@ public function getQResiduals(NumericMatrix $new_data = null): NumericMatrix
265265
*
266266
* @throws Exception\MathException
267267
*/
268-
public function getT2Distances(NumericMatrix $new_data = null): NumericMatrix
268+
public function getT2Distances(?NumericMatrix $new_data = null): NumericMatrix
269269
{
270270
$vars = $this->data->getN();
271271

0 commit comments

Comments
 (0)