Skip to content

Commit

Permalink
Fix php8.4 deprecated notices (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
it-can authored Jan 14, 2025
1 parent e587bfe commit c85f142
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Functions/BaseEncoderDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function toBase(ArbitraryInteger $number, int $base, $alphabet = n
*
* @throws Exception\BadParameterException if the string is empty or base is greater than 256
*/
public static function createArbitraryInteger(string $number, int $base, string $offset = null): ArbitraryInteger
public static function createArbitraryInteger(string $number, int $base, ?string $offset = null): ArbitraryInteger
{
if ($number == '') {
throw new Exception\BadParameterException("String cannot be empty.");
Expand Down
2 changes: 1 addition & 1 deletion src/LinearAlgebra/MatrixFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public static function one(int $m, int $n): NumericMatrix
* @throws Exception\MathException
* @throws Exception\OutOfBoundsException if m, n, or k are < 0; if k >= n
*/
public static function eye(int $m, int $n, int $k, float $x = null): NumericMatrix
public static function eye(int $m, int $n, int $k, ?float $x = null): NumericMatrix
{
if ($n < 0 || $m < 0 || $k < 0) {
throw new Exception\OutOfBoundsException("m, n and k must be ≥ 0. m = $m, n = $n, k = $k");
Expand Down
4 changes: 2 additions & 2 deletions src/LinearAlgebra/NumericMatrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,7 @@ private function solveRref(Vector $b): Vector
* @throws Exception\MatrixException if method is not a valid eigenvalue method
* @throws Exception\MathException
*/
public function eigenvalues(string $method = null): array
public function eigenvalues(?string $method = null): array
{
if (!$this->isSquare()) {
throw new Exception\MatrixException('Eigenvalues can only be calculated on square matrices');
Expand Down Expand Up @@ -3068,7 +3068,7 @@ public function eigenvalues(string $method = null): array
* @throws Exception\MatrixException if method is not a valid eigenvalue method
* @throws Exception\MathException
*/
public function eigenvectors(string $method = null): NumericMatrix
public function eigenvectors(?string $method = null): NumericMatrix
{
if ($method === null) {
return Eigenvector::eigenvectors($this, $this->eigenvalues());
Expand Down
2 changes: 1 addition & 1 deletion src/Probability/Combinatorics.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static function subfactorial(int $n): float
*
* @throws Exception\OutOfBoundsException if n is negative or k is larger than n
*/
public static function permutations(int $n, int $k = null): float
public static function permutations(int $n, ?int $k = null): float
{
if ($n < 0) {
throw new Exception\OutOfBoundsException('Cannot compute negative permutations.');
Expand Down
2 changes: 1 addition & 1 deletion src/Statistics/Distance.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static function jensenShannon(array $p, array $q): float
* @throws Exception\OutOfBoundsException
* @throws Exception\VectorException
*/
public static function mahalanobis(NumericMatrix $x, NumericMatrix $data, NumericMatrix $y = null): float
public static function mahalanobis(NumericMatrix $x, NumericMatrix $data, ?NumericMatrix $y = null): float
{
$Centroid = $data->rowMeans()->asColumnMatrix();
$Nx = $x->getN();
Expand Down
4 changes: 2 additions & 2 deletions src/Statistics/KernelDensityEstimation.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class KernelDensityEstimation
* @throws Exception\OutOfBoundsException h ≤ 0
* @throws Exception\BadParameterException
*/
public function __construct(array $data, float $h = null, $kernel = null)
public function __construct(array $data, ?float $h = null, $kernel = null)
{
$this->n = \count($data);
if ($this->n === 0) {
Expand All @@ -68,7 +68,7 @@ public function __construct(array $data, float $h = null, $kernel = null)
*
* @throws Exception\OutOfBoundsException if h ≤ 0
*/
public function setBandwidth(float $h = null): void
public function setBandwidth(?float $h = null): void
{
if ($h === null) {
$this->h = $this->getDefaultBandwidth();
Expand Down
8 changes: 4 additions & 4 deletions src/Statistics/Multivariate/PCA.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private function checkNewData(NumericMatrix $newData): void
*
* @throws Exception\MathException
*/
public function standardizeData(NumericMatrix $new_data = null): NumericMatrix
public function standardizeData(?NumericMatrix $new_data = null): NumericMatrix
{
if ($new_data === null) {
$X = $this->data;
Expand Down Expand Up @@ -164,7 +164,7 @@ public function getEigenvalues(): Vector
*
* @throws Exception\MathException
*/
public function getScores(NumericMatrix $new_data = null): NumericMatrix
public function getScores(?NumericMatrix $new_data = null): NumericMatrix
{
if ($new_data === null) {
$scaled_data = $this->data;
Expand Down Expand Up @@ -220,7 +220,7 @@ public function getCumR2(): array
*
* @throws Exception\MathException
*/
public function getQResiduals(NumericMatrix $new_data = null): NumericMatrix
public function getQResiduals(?NumericMatrix $new_data = null): NumericMatrix
{
$vars = $this->data->getN();

Expand Down Expand Up @@ -265,7 +265,7 @@ public function getQResiduals(NumericMatrix $new_data = null): NumericMatrix
*
* @throws Exception\MathException
*/
public function getT2Distances(NumericMatrix $new_data = null): NumericMatrix
public function getT2Distances(?NumericMatrix $new_data = null): NumericMatrix
{
$vars = $this->data->getN();

Expand Down

0 comments on commit c85f142

Please sign in to comment.