Skip to content

Commit

Permalink
CodeChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
ralferlebach committed Oct 18, 2024
1 parent 6c0c6bf commit 5c14673
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion classes/mathcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public static function compose_chain($function1, $function2) {
*
* @return array - structure of the given array, needed for restoring by vector_to_array
*/
public static function array_to_vector(&$data, int &$n = null): array {
public static function array_to_vector(&$data, int &$n = 0): array {
// NOTE: The operation will be done directly on $data, so work with a copy!

if (is_null($n)) {
Expand Down
19 changes: 11 additions & 8 deletions tests/mathcat_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public function test_newton_raphson_multi_stable(): void {
}

/**
* @dataProvider conversion_of_array_to_vector_provider
*
* @param array
* @return void
* Test if array_to_vector and vector_to_array work as expected
*
* @param array
* @return void
*/
public function test_conversion_of_array_to_vector($data): void {
$array = $data['old'];
Expand Down Expand Up @@ -135,8 +135,9 @@ public static function conversion_of_array_to_vector_provider(): array {
'karaoke box' => 7,
],
],
'basement' => 8
'basement' => 8,
],
],

'modified and reordered' => [
'old' => [0, 'first' => 2, 'second' => [7, 9, 8], 'third' => 5],
Expand All @@ -145,14 +146,16 @@ public static function conversion_of_array_to_vector_provider(): array {
],

// Forbidden cases: strings in array, empty arrays.
'forbidden because of string' => ['old' => ['test' => 'test', 'legid' => 3],
'forbidden because of string' => [
'old' => ['test' => 'test', 'legid' => 3],
'new' => ['test' => 0.0, 'legid' => 3.0],
'structure' => ['test' => 0, 'legid' => 1],
],

'forbidden because of empty array' => ['old' => ['test' => []],
'forbidden because of empty array' => [
'old' => ['test' => []],
'new' => ['test' => []],
'structure' => ['test' => []],
'structure' => ['test' => []],
],
];
}
Expand Down

0 comments on commit 5c14673

Please sign in to comment.