Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions source/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,32 @@ may go by different names.
.. [#3] JavaScript does not have separate types for integer and
floating-point.

--PHP
The following table maps from the names of JavaScript types to
their analogous types in PHP:

+----------+--------------+
|JavaScript|PHP |
+----------+--------------+
|string |String |
+----------+--------------+
|number |Integer/Float |
| |[#4]_ |
+----------+--------------+
|object |Object |
+----------+--------------+
|array |Array |
+----------+--------------+
|boolean |Boolean |
+----------+--------------+
|null |NULL |
+----------+--------------+
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not really sure whether PHP types should be spelled in upper-case or lower-case. I don't think it really matters since the built-in types are not first-class objects, though gettype() returns the lower-case spelling. Either way I think one spelling should be used consistently (and in some of the examples below you use all lower-case instead).


.. rubric:: Footnotes

.. [#4] JavaScript does not have separate types for integer and
floating-point.

With these simple data types, all kinds of structured data can be
represented. With that great flexibility comes great responsibility,
however, as the same concept could be represented in myriad ways. For
Expand Down
2 changes: 2 additions & 0 deletions source/reference/array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ array may be of a different type.
arrays.
--Ruby
In Ruby, "array" is analogous to a ``Array`` type.
--PHP
In PHP, "array" is analogous to a ``Array`` type.

.. schema_example::
{ "type": "array" }
Expand Down
2 changes: 2 additions & 0 deletions source/reference/boolean.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ such as 1 and 0, are not accepted by the schema.
--Ruby
In Ruby, "boolean" is analogous to ``TrueClass`` and ``FalseClass``. Note
that in Ruby there is no ``Boolean`` class.
--Python
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you meant --PHP here

In PHP, "boolean" is analogous to ``boolean``.

.. schema_example::
{ "type": "boolean" }
Expand Down
2 changes: 2 additions & 0 deletions source/reference/null.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ value: ``null``.
In Python, ``null`` is analogous to ``None``.
--Ruby
In Ruby, ``null`` is analogous to ``nil``.
--PHP
In PHP, ``null`` is analogous to ``null``.

.. schema_example::
{ "type": "null" }
Expand Down
2 changes: 2 additions & 0 deletions source/reference/numeric.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The ``integer`` type is used for integral numbers.
In Python, "integer" is analogous to the ``int`` type.
--Ruby
In Ruby, "integer" is analogous to the ``Integer`` type.
--PHP
In PHP, "integer" is analogous to the ``integer`` type.

.. schema_example::

Expand Down
3 changes: 3 additions & 0 deletions source/reference/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ conventionally referred to as a "property".
everything, whereas in JSON it is used only to mean a mapping from
string keys to values.

--PHP
In PHP, "objects" are analogous to the ``object`` type. In both
JSON and PHP, all keys in must be strings.

.. schema_example::
{ "type": "object" }
Expand Down
2 changes: 2 additions & 0 deletions source/reference/string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Unicode characters.
2.x, and the ``str`` type on Python 3.x.
--Ruby
In Ruby, "string" is analogous to the ``String`` type.
--PHP
In PHP, "string" is analogous to the ``string`` type.

.. schema_example::

Expand Down
27 changes: 27 additions & 0 deletions source/reference/type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ may go by different names.
.. [#3] JavaScript does not have separate types for integer and
floating-point.

--PHP
The following table maps from the names of JavaScript types to
their analogous types in PHP:

+----------+--------------+
|JavaScript|PHP |
+----------+--------------+
|string |String |
+----------+--------------+
|number |Integer/Float |
| |[#4]_ |
+----------+--------------+
|object |Object |
+----------+--------------+
|array |Array |
+----------+--------------+
|boolean |Boolean |
+----------+--------------+
|null |NULL |
+----------+--------------+

.. rubric:: Footnotes

.. [#4] JavaScript does not have separate types for integer and
floating-point.


The ``type`` keyword may either be a string or an array:

- If it's a string, it is the name of one of the basic types above.
Expand Down