Skip to content

Commit

Permalink
Apply EditorConfig rules and lint Sphinx docs (#832)
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor committed Oct 28, 2023
1 parent 35a5029 commit 117d407
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
indent_size = 2

[**.{yml,yaml}]
indent_size = 2

[**.{neon,neon.dist}]
indent_style = tab

[**/Makefile]
indent_style = tab
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ sphinx:
configuration: docs/conf.py

python:
install:
- requirements: docs/requirements.txt
install:
- requirements: docs/requirements.txt
31 changes: 22 additions & 9 deletions docs/cloud-messaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Cloud Messaging
###############

You can use the Firebase Admin SDK for PHP to send Firebase Cloud Messaging messages to end-user devices. Specifically, you can send messages to individual devices, named topics, or condition statements that match one or more topics.
You can use the Firebase Admin SDK for PHP to send Firebase Cloud Messaging messages to end-user devices.
Specifically, you can send messages to individual devices, named topics, or condition statements that match one or more topics.

.. note::
Sending messages to Device Groups is only possible with legacy protocols which are not supported
Expand Down Expand Up @@ -72,9 +73,11 @@ have to send/validate a message in order to know if it's valid or not.
Send messages to topics
***********************

Based on the publish/subscribe model, FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic. You compose topic messages as needed, and FCM handles routing and delivering the message reliably to the right devices.
Based on the publish/subscribe model, FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic.
You compose topic messages as needed, and FCM handles routing and delivering the message reliably to the right devices.

For example, users of a local weather forecasting app could opt in to a "severe weather alerts" topic and receive notifications of storms threatening specified areas. Users of a sports app could subscribe to automatic updates in live game scores for their favorite teams.
For example, users of a local weather forecasting app could opt in to a "severe weather alerts" topic and receive notifications of storms threatening specified areas.
Users of a sports app could subscribe to automatic updates in live game scores for their favorite teams.

Some things to keep in mind about topics:

Expand Down Expand Up @@ -118,11 +121,15 @@ Send conditional messages
- https://github.com/firebase/quickstart-js/issues/183
- https://stackoverflow.com/a/52302136/284325

Sometimes you want to send a message to a combination of topics. This is done by specifying a condition, which is a boolean expression that specifies the target topics. For example, the following condition will send messages to devices that are subscribed to ``TopicA`` and either ``TopicB`` or ``TopicC``:
Sometimes you want to send a message to a combination of topics.
This is done by specifying a condition, which is a boolean expression that specifies the target topics.
For example, the following condition will send messages to devices that are subscribed to ``TopicA`` and either ``TopicB`` or ``TopicC``:

``"'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics)"``

FCM first evaluates any conditions in parentheses, and then evaluates the expression from left to right. In the above expression, a user subscribed to any single topic does not receive the message. Likewise, a user who does not subscribe to TopicA does not receive the message. These combinations do receive it:
FCM first evaluates any conditions in parentheses, and then evaluates the expression from left to right.
In the above expression, a user subscribed to any single topic does not receive the message.
Likewise, a user who does not subscribe to TopicA does not receive the message. These combinations do receive it:

- ``TopicA`` and ``TopicB``
- ``TopicA`` and ``TopicC``
Expand Down Expand Up @@ -151,9 +158,15 @@ FCM first evaluates any conditions in parentheses, and then evaluates the expres
Send messages to specific devices
*********************************

The Admin FCM API allows you to send messages to individual devices by specifying a registration token for the target device. Registration tokens are strings generated by the client FCM SDKs for each end-user client app instance.
The Admin FCM API allows you to send messages to individual devices by specifying a registration token for the target device.
Registration tokens are strings generated by the client FCM SDKs for each end-user client app instance.

Each of the Firebase client SDKs are able to generate these registration tokens: `iOS <https://firebase.google.com/docs/cloud-messaging/ios/client#access_the_registration_token>`_, `Android <https://firebase.google.com/docs/cloud-messaging/android/client#sample-register>`_, `Web <https://firebase.google.com/docs/cloud-messaging/js/client#access_the_registration_token>`_, `C++ <https://firebase.google.com/docs/cloud-messaging/cpp/client#access_the_device_registration_token>`_, and `Unity <https://firebase.google.com/docs/cloud-messaging/unity/client#initialize_firebase_messaging>`_.
Each of the Firebase client SDKs are able to generate these registration tokens:
`iOS <https://firebase.google.com/docs/cloud-messaging/ios/client#access_the_registration_token>`_,
`Android <https://firebase.google.com/docs/cloud-messaging/android/client#sample-register>`_,
`Web <https://firebase.google.com/docs/cloud-messaging/js/client#access_the_registration_token>`_,
`C++ <https://firebase.google.com/docs/cloud-messaging/cpp/client#access_the_device_registration_token>`_,
and `Unity <https://firebase.google.com/docs/cloud-messaging/unity/client#initialize_firebase_messaging>`_.

.. code-block:: php
Expand Down Expand Up @@ -594,7 +607,7 @@ Validating messages
*******************

You can validate a message by sending a validation-only request to the Firebase REST API. If the message is invalid,
a `Kreait\Firebase\Exception\Messaging\InvalidMessage` exception is thrown, which you can catch to evaluate the raw
a ``Kreait\Firebase\Exception\Messaging\InvalidMessage`` exception is thrown, which you can catch to evaluate the raw
error message(s) that the API returned.

.. code-block:: php
Expand Down Expand Up @@ -624,7 +637,7 @@ Validating Registration Tokens
******************************

If you have a set of registration tokens that you want to check for validity or if they are still registered
to your project, you can use the `validateTokens()` method:
to your project, you can use the ``validateTokens()`` method:

.. code-block:: php
Expand Down
12 changes: 6 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
### Integrations

html_context = {
"display_github": True,
"github_user": "kreait",
"github_repo": "firebase-php",
"github_version": "7.x",
"conf_py_path": "/docs/",
"source_suffix": ".rst",
'display_github': True,
'github_user': 'kreait',
'github_repo': 'firebase-php',
'github_version': '7.x',
'conf_py_path': '/docs/',
'source_suffix': '.rst',
}
2 changes: 1 addition & 1 deletion docs/dynamic-links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ or programmatically.
If ``getStatistics()`` is called without a second parameter, stats will include the statistics of the past 7 days.

The returned object will be an instance of ``Kreait\Firebase\DynamicLink\DynamicLinkStatistics``, which currently
only includes event statistics. You can access the raw returned data with `$stats->rawData()`.
only includes event statistics. You can access the raw returned data with ``$stats->rawData()``.

Event Statistics
----------------
Expand Down
18 changes: 9 additions & 9 deletions docs/realtime-database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,14 @@ a website might be set as follows:
.. code-block:: php
$database->getReference('config/website')
->set([
'name' => 'My Application',
'emails' => [
'support' => 'support@domain.tld',
'sales' => 'sales@domain.tld',
],
'website' => 'https://app.domain.tld',
]);
->set([
'name' => 'My Application',
'emails' => [
'support' => 'support@domain.tld',
'sales' => 'sales@domain.tld',
],
'website' => 'https://app.domain.tld',
]);
$database->getReference('config/website/name')->set('New name');
Expand Down Expand Up @@ -352,7 +352,7 @@ to the recent activity feed and the posting user's activity feed using code like
];
$database->getReference() // this is the root reference
->update($updates);
->update($updates);
Writing lists
Expand Down
2 changes: 1 addition & 1 deletion docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ HTTP Client Options
*******************

You can configure the behavior of the Guzzle HTTP Client performing the API requests by passing an
instance of `Kreait\Firebase\Http\HttpClientOptions` to the factory before creating a
instance of ``Kreait\Firebase\Http\HttpClientOptions`` to the factory before creating a
service.

.. code-block:: php
Expand Down
4 changes: 2 additions & 2 deletions docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The emulator suite must be running otherwise the PHP SDK can't connect to it.
Auth Emulator
-------------

If not already present, create a `firebase.json` file in the root of your project and make sure that at least the
If not already present, create a ``firebase.json`` file in the root of your project and make sure that at least the
following fields are set (the port number can be changed to your requirements):

.. code-block:: js
Expand Down Expand Up @@ -66,7 +66,7 @@ real Firebase project ID; the Authentication emulator will accept any project ID
Realtime Database Emulator
--------------------------

If not already present, create a `firebase.json` file in the root of your project and make sure that at least the
If not already present, create a ``firebase.json`` file in the root of your project and make sure that at least the
following fields are set (the port number can be changed to your requirements):

.. code-block:: js
Expand Down
2 changes: 1 addition & 1 deletion docs/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Troubleshooting

.. note::
This SDK works with immutable objects until noted otherwise. You can recognize these
objects when they have a ˚`with*``method. In that case, please keep in mind that in
objects when they have a ``with*`` method. In that case, please keep in mind that in
order to get hold of the changes you made, you will have to use the result of
that method, e.g. ``$changedObject = $object->withChangedProperty();``.

Expand Down
14 changes: 7 additions & 7 deletions docs/user-management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ Result:
.. code-block:: text
[
'some-uid' => <UserRecord>,
'another-uid' => <UserRecord>,
'non-existing-uid' => null
'some-uid' => <UserRecord>,
'another-uid' => <UserRecord>,
'non-existing-uid' => null
]
*************
Expand Down Expand Up @@ -222,10 +222,10 @@ Any combination of the following properties can be provided:
================= ======= ===========
Property Type Description
================= ======= ===========
``uid`` string The uid to assign to the newly created user. Must be a string between 1 and 128 characters long, inclusive. If not provided, a random uid will be automatically generated.
``uid`` string The uid to assign to the newly created user. Must be a string between 1 and 128 characters long, inclusive. If not provided, a random uid will be automatically generated.
``email`` string The user's primary email. Must be a valid email address.
``emailVerified`` boolean Whether or not the user's primary email is verified. If not provided, the default is false.
``phoneNumber`` string The user's primary phone number. Must be a valid E.164 spec compliant phone number.
``phoneNumber`` string The user's primary phone number. Must be a valid E.164 spec compliant phone number.
``password`` string The user's raw, unhashed password. Must be at least six characters long.
``displayName`` string The users' display name.
``photoURL`` string The user's photo URL.
Expand Down Expand Up @@ -467,8 +467,8 @@ for email actions.
========================= =========== ===========
Parameter Type Description
========================= =========== ===========
``continueUrl`` string|null Sets the continue URL
``url`` string|null Alias for ``continueUrl``
``continueUrl`` string|null Sets the continue URL
``url`` string|null Alias for ``continueUrl``
``handleCodeInApp`` bool|null | Whether the email action link will be opened in a mobile app or a web link first.
| The default is false. When set to true, the action code link will be be sent
| as a Universal Link or Android App Link and will be opened by the app if
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Messaging/MessageDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ public static function invalidData(): array
'reserved_key_from' => [
['from' => 'any'],
],
// // According to the docs, "notification" is reserved, but it's still accepted ¯\_(ツ)_/¯
// According to the docs, "notification" is reserved, but it's still accepted ¯\_(ツ)_/¯
/*
'reserved_key_notification' => [
['notification' => 'any'],
],
*/
*/
'reserved_key_message_type' => [
['message_type' => 'any'],
],
Expand Down

0 comments on commit 117d407

Please sign in to comment.