Skip to content

PHPC-2474: Support Binary vector subtype#1853

Merged
jmikola merged 5 commits intomongodb:v2.xfrom
jmikola:phpc-2474-vector
Oct 7, 2025
Merged

PHPC-2474: Support Binary vector subtype#1853
jmikola merged 5 commits intomongodb:v2.xfrom
jmikola:phpc-2474-vector

Conversation

@jmikola
Copy link
Contributor

@jmikola jmikola commented Jul 24, 2025

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the python implementation, the Binary class has a from_vector static method. You have certainly considered this solution, of having only a factory method instead of a new class. But the new methods toArray and getVectorType are specific to this binary type, so having a dedicated class makes sense. But if you create a new Binary($raw, Binary::TYPE_VECTOR) instance with the vector type from the raw binary data, you don't have this methods. The current state doesn't allow creating a BinaryVector from raw data. I think you would have to wrap in into a BSON Document and encode/decode it to get a BinaryVector instance. I don't find any other binary type that would require a specific class.

I see 3 possible implementations:

  1. Add Binary::fromVector(array $vector, VectorType $vectorType) and toArray() to the existing Binary class
  2. Create BinaryVector class that extends Binary (current state of this PR).
  3. Create BinaryVector class that implements BinaryInterface, \JsonSerializable, Type, \Stringable.

We need to compare pro/con of each solution.

@jmikola jmikola marked this pull request as ready for review October 3, 2025 02:02
@jmikola jmikola requested a review from a team as a code owner October 3, 2025 02:02
@jmikola jmikola requested review from alcaeus and removed request for a team October 3, 2025 02:02
@jmikola
Copy link
Contributor Author

jmikola commented Oct 3, 2025

One failing test appears to be from Atlas connectivity tests failing to connect to a serverless cluster. Per PHPLIB-1667, I expect that should have been removed; however, I don't see a related PHPC ticket. Please review ignoring that particular test failure and I'll address that with a separate PR and ticket.

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. No objection to adding corpus tests in a follow-up PR.

@@ -0,0 +1,18 @@
--TEST--
MongoDB\BSON\Binary unserialization requires valid vector data (__serialize and __unserialize)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this complements bson-binary-set_state_error-004.phpt

@jmikola jmikola changed the title PHPC-2474: BinaryVector support PHPC-2474: Support Binary vector subtype Oct 7, 2025
@jmikola jmikola merged commit 36452c1 into mongodb:v2.x Oct 7, 2025
71 checks passed
alcaeus added a commit that referenced this pull request Jan 21, 2026
* v2.x: (39 commits)
  Bump tests/drivers-evergreen-tools from `61cb4e9` to `5514d6a` (#1908)
  Bump tests/drivers-evergreen-tools from `514927f` to `61cb4e9` (#1906)
  Bump tests/drivers-evergreen-tools from `ebe98d0` to `514927f` (#1905)
  PHPC-2649: Update to libmongocrypt 1.17.0 (#1904)
  PHPC-2654: Update to libmongoc 2.2.1 (#1900)
  Bump tests/drivers-evergreen-tools from `c92d062` to `ebe98d0` (#1903)
  Bump actions/cache from 4 to 5 (#1902)
  Bump tests/drivers-evergreen-tools from `c83e428` to `c92d062` (#1899)
  Bump tests/drivers-evergreen-tools from `cb019f7` to `c83e428` (#1898)
  Bump actions/checkout from 5 to 6 (#1895)
  Bump tests/drivers-evergreen-tools from `f8ab2a5` to `cb019f7` (#1896)
  PHPC-2634: Binary vector corpus tests (#1892)
  Bump tests/drivers-evergreen-tools from `1dcbfe4` to `f8ab2a5` (#1891)
  PHPC-2638 and PHPC-2630: Bump to libmongoc 2.1.2 and libmongocrypt 1.16.0 (#1868)
  Fix git submodule command in CONTRIBUTING.md
  PHPC-2627: Use appropriate return type for zend_object_iterator_funcs.valid (#1890)
  Bump github/codeql-action from 3 to 4 (#1889)
  Bump tests/drivers-evergreen-tools from `3b3f081` to `1dcbfe4` (#1878)
  PHPC-2474: Support Binary vector subtype (#1853)
  Upload test results to codecov.io (#1857)
  ...
alcaeus added a commit that referenced this pull request Jan 28, 2026
* v2.x: (40 commits)
  PHPC-2664: Drop Windows x86 builds (#1911)
  Bump tests/drivers-evergreen-tools from `61cb4e9` to `5514d6a` (#1908)
  Bump tests/drivers-evergreen-tools from `514927f` to `61cb4e9` (#1906)
  Bump tests/drivers-evergreen-tools from `ebe98d0` to `514927f` (#1905)
  PHPC-2649: Update to libmongocrypt 1.17.0 (#1904)
  PHPC-2654: Update to libmongoc 2.2.1 (#1900)
  Bump tests/drivers-evergreen-tools from `c92d062` to `ebe98d0` (#1903)
  Bump actions/cache from 4 to 5 (#1902)
  Bump tests/drivers-evergreen-tools from `c83e428` to `c92d062` (#1899)
  Bump tests/drivers-evergreen-tools from `cb019f7` to `c83e428` (#1898)
  Bump actions/checkout from 5 to 6 (#1895)
  Bump tests/drivers-evergreen-tools from `f8ab2a5` to `cb019f7` (#1896)
  PHPC-2634: Binary vector corpus tests (#1892)
  Bump tests/drivers-evergreen-tools from `1dcbfe4` to `f8ab2a5` (#1891)
  PHPC-2638 and PHPC-2630: Bump to libmongoc 2.1.2 and libmongocrypt 1.16.0 (#1868)
  Fix git submodule command in CONTRIBUTING.md
  PHPC-2627: Use appropriate return type for zend_object_iterator_funcs.valid (#1890)
  Bump github/codeql-action from 3 to 4 (#1889)
  Bump tests/drivers-evergreen-tools from `3b3f081` to `1dcbfe4` (#1878)
  PHPC-2474: Support Binary vector subtype (#1853)
  ...
alcaeus added a commit that referenced this pull request Jan 28, 2026
* v2.x: (40 commits)
  PHPC-2664: Drop Windows x86 builds (#1911)
  Bump tests/drivers-evergreen-tools from `61cb4e9` to `5514d6a` (#1908)
  Bump tests/drivers-evergreen-tools from `514927f` to `61cb4e9` (#1906)
  Bump tests/drivers-evergreen-tools from `ebe98d0` to `514927f` (#1905)
  PHPC-2649: Update to libmongocrypt 1.17.0 (#1904)
  PHPC-2654: Update to libmongoc 2.2.1 (#1900)
  Bump tests/drivers-evergreen-tools from `c92d062` to `ebe98d0` (#1903)
  Bump actions/cache from 4 to 5 (#1902)
  Bump tests/drivers-evergreen-tools from `c83e428` to `c92d062` (#1899)
  Bump tests/drivers-evergreen-tools from `cb019f7` to `c83e428` (#1898)
  Bump actions/checkout from 5 to 6 (#1895)
  Bump tests/drivers-evergreen-tools from `f8ab2a5` to `cb019f7` (#1896)
  PHPC-2634: Binary vector corpus tests (#1892)
  Bump tests/drivers-evergreen-tools from `1dcbfe4` to `f8ab2a5` (#1891)
  PHPC-2638 and PHPC-2630: Bump to libmongoc 2.1.2 and libmongocrypt 1.16.0 (#1868)
  Fix git submodule command in CONTRIBUTING.md
  PHPC-2627: Use appropriate return type for zend_object_iterator_funcs.valid (#1890)
  Bump github/codeql-action from 3 to 4 (#1889)
  Bump tests/drivers-evergreen-tools from `3b3f081` to `1dcbfe4` (#1878)
  PHPC-2474: Support Binary vector subtype (#1853)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants