Commit 93d31c6
committed
minor #1130 [Platform] Remove unused code in Vector constructor and add missing tests (camilleislasse)
This PR was merged into the main branch.
Discussion
----------
[Platform] Remove unused code in Vector constructor and add missing tests
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| Docs? | no
| License | MIT
The `Vector` constructor had duplicate validation code. The second check (line 36-38) could never be reached because the first check (line 28-30) already handles the same condition.
Given [`$dimensions` is typed `?int`](https://github.com/symfony/ai/blob/main/src/platform/src/Vector/Vector.php#L26):
- `null !== $dimensions` = "dimensions is not null"
- `\is_int($dimensions)` = "dimensions is an int"
When `$dimensions` is not null, it is an int. So both conditions are equivalent, making the second check unused code.
This PR:
- Removes the unreachable duplicate check
- Adds missing test coverage for dimension validation
Commits
-------
325377e [Platform] Remove dead code in Vector constructor and add missing testsFile tree
2 files changed
+24
-4
lines changed- src/platform
- src/Vector
- tests/Vector
2 files changed
+24
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | 36 | | |
41 | 37 | | |
42 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
35 | 59 | | |
0 commit comments