Skip to content

Commit

Permalink
Document TypeConverterFactory and related stuff, add custom CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
sad-spirit committed Jan 25, 2025
1 parent d3ace7c commit 48e733f
Show file tree
Hide file tree
Showing 6 changed files with 543 additions and 6 deletions.
Empty file removed docs/_static/.gitkeep
Empty file.
11 changes: 11 additions & 0 deletions docs/_static/theme_override.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.wy-nav-content {
max-width: 1050px;
}

.rst-content table.docutils td {
vertical-align: top;
}

.wy-table-responsive table td {
white-space: inherit;
}
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

html_css_files = [
'theme_override.css',
]
513 changes: 513 additions & 0 deletions docs/converter-factories.rst

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions docs/converters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,24 @@ the existing ones as described above.
The best course of action will be to extend either ``BaseConverter`` or ``ContainerConverter`` based on the
properties of the type.

``BaseConverter`` handles the null values as ``pgsql`` extension itself converts ``NULL`` fields of any type
to PHP ``null`` values. It defines two abstract methods
``BaseConverter``
-----------------

This base class implements ``input()`` and ``output()`` methods that handle null values as ``pgsql`` extension itself
converts ``NULL`` fields of any type to PHP ``null`` values.

It delegates handling of non-null values to the two new abstract methods

``inputNotNull(string $native): mixed``
Parses native value that is not NULL into PHP variable
Converts a string received from PostgreSQL to PHP variable of the proper type.

``outputNotNull(mixed $value): string``
Converts PHP variable not identical to null into native format
Returns a string representation of PHP variable not identical to null.

``ContainerConverter``
----------------------

``ContainerConverter`` defines helper methods for parsing complex string representations. Those accept the string
This class defines helper methods for parsing complex string representations. Those accept the string
received from the database and position of the current symbol that is updated once parts of the string is processed.

``nextChar(string $str, int &$p): ?string``
Expand All @@ -268,5 +276,5 @@ received from the database and position of the current symbol that is updated on
``inputNotNull()`` is implemented in ``ContainerConverter``, a new abstract method is defined instead

``parseInput(string $native, int &$pos): mixed``
Parses a native value into PHP variable from given position. This will be called from current position in
Parses a string representation into PHP variable from given position. This may be called from any position in
the string and should return once it finishes parsing the value.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ features like transparent conversion of query results work only with the wrapper
overview
types
converters
converter-factories

0 comments on commit 48e733f

Please sign in to comment.