Skip to content

Commit 1377507

Browse files
authored
feat: add full feature parity (#71)
1 parent dbe2502 commit 1377507

File tree

14 files changed

+681
-176
lines changed

14 files changed

+681
-176
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ARG VARIANT=8-bullseye
2+
FROM mcr.microsoft.com/vscode/devcontainers/php:0-${VARIANT}
3+
4+
RUN pecl install ast && \
5+
echo "extension=ast.so" >> "$PHP_INI_DIR/php.ini-development" && \
6+
mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
7+
8+
ENV PHAN_ALLOW_XDEBUG 0
9+
ENV PHAN_DISABLE_XDEBUG_WARN 1

.devcontainer/devcontainer.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/php
3+
{
4+
"name": "PHP",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
// Update VARIANT to pick a PHP version: 8, 8.0, 7, 7.4, 7.3
9+
// Append -bullseye or -buster to pin to an OS version.
10+
// Use -bullseye variants on local on arm64/Apple Silicon.
11+
"VARIANT": "8-bullseye"
12+
}
13+
},
14+
"settings": {
15+
"php.validate.executablePath": "/usr/local/bin/php",
16+
"php-cs-fixer.onsave": true,
17+
"php-cs-fixer.config": ".php-cs-fixer.dist.php",
18+
},
19+
"extensions": [
20+
"pkief.material-icon-theme",
21+
"eamodio.gitlens",
22+
"visualstudioexptteam.vscodeintellicode",
23+
"github.copilot",
24+
"felixfbecker.php-debug",
25+
"bmewburn.vscode-intelephense-client",
26+
"junstyle.php-cs-fixer"
27+
],
28+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
29+
// "forwardPorts": [8080],
30+
// Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
31+
"portsAttributes": {
32+
"8000": {
33+
"label": "Stream PHP SDK",
34+
"onAutoForward": "notify"
35+
}
36+
},
37+
// Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
38+
// "otherPortsAttributes": {
39+
// "onAutoForward": "silent"
40+
// },
41+
// Use 'postCreateCommand' to run commands after the container is created.
42+
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"
43+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
44+
"remoteUser": "vscode"
45+
}

.github/workflows/ci.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ name: build
22

33
on: [pull_request]
44

5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.head_ref }}
7+
cancel-in-progress: true
8+
59
jobs:
610
build:
711
name: 🧪 Test & lint
812
runs-on: ubuntu-latest
913
strategy:
1014
max-parallel: 1
1115
matrix:
12-
php-versions: ['7.3', '7.4', '8.0']
16+
php-versions: ['7.3', '7.4', '8.0', '8.1']
1317
steps:
1418
- name: Checkout
1519
uses: actions/checkout@v2
@@ -23,22 +27,23 @@ jobs:
2327
uses: shivammathur/setup-php@v2
2428
with:
2529
php-version: ${{ matrix.php-versions }}
26-
extensions: mbstring, intl
30+
extensions: ast, mbstring, intl
2731
ini-values: post_max_size=256M, max_execution_time=180
2832
tools: composer:v2
2933

3034
- name: Deps
3135
run: composer install --no-interaction
3236

3337
- name: Format
34-
run: vendor/bin/php-cs-fixer fix --config=.php_cs-fixer.dist.php -v --dry-run --stop-on-violation
38+
if: ${{ matrix.php-versions == '7.3' }}
39+
run: vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation
3540

3641
- name: Quality
37-
if: matrix.php-versions == '7.4'
38-
run: vendor/bin/phan --force-polyfill-parser || true
42+
if: ${{ matrix.php-versions == '7.3' }}
43+
run: vendor/bin/phan --no-progress-bar
3944

4045
- name: Test
4146
env:
42-
STREAM_API_KEY: ${{ secrets.STREAM_API_KEY }}
43-
STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }}
47+
STREAM_KEY: ${{ secrets.STREAM_API_KEY }}
48+
STREAM_SECRET: ${{ secrets.STREAM_API_SECRET }}
4449
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ composer.lock
44
.phplint-cache
55
.phpunit.result.cache
66
.envrc
7-
.php_cs.cache
7+
.php*cache
88
.idea
99
.vscode

.phan/config.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,39 @@
1818
// TODO: Set this.
1919
'target_php_version' => null,
2020

21+
'plugins' => [
22+
'AlwaysReturnPlugin',
23+
'DuplicateArrayKeyPlugin',
24+
'PrintfCheckerPlugin',
25+
'UnreachableCodePlugin',
26+
'UseReturnValuePlugin',
27+
'EmptyStatementListPlugin',
28+
'LoopVariableReusePlugin',
29+
'RedundantAssignmentPlugin',
30+
'UnknownClassElementAccessPlugin',
31+
'MoreSpecificElementTypePlugin',
32+
'UnsafeCodePlugin',
33+
'WhitespacePlugin',
34+
'PHPDocInWrongCommentPlugin',
35+
'NoAssertPlugin',
36+
'NumericalComparisonPlugin',
37+
'StrictLiteralComparisonPlugin',
38+
'DeprecateAliasPlugin',
39+
'ShortArrayPlugin',
40+
'AvoidableGetterPlugin',
41+
'RemoveDebugStatementPlugin',
42+
'HasPHPDocPlugin',
43+
],
44+
45+
'suppress_issue_types' => [
46+
'PhanPluginDescriptionlessCommentOnPublicMethod',
47+
'PhanPluginDescriptionlessCommentOnProtectedProperty',
48+
'PhanPluginDescriptionlessCommentOnPublicProperty',
49+
'PhanPluginDescriptionlessCommentOnPrivateMethod',
50+
'PhanPluginDescriptionlessCommentOnPrivateProperty',
51+
'PhanPluginDescriptionlessCommentOnProtectedMethod',
52+
],
53+
2154
// A list of directories that should be parsed for class and
2255
// method information. After excluding the directories
2356
// defined in exclude_analysis_directory_list, the remaining
@@ -49,6 +82,7 @@
4982
// should be added to both the `directory_list`
5083
// and `exclude_analysis_directory_list` arrays.
5184
'exclude_analysis_directory_list' => [
52-
'vendor/'
85+
'vendor/',
86+
'tests/',
5387
],
5488
];

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# ♻️ Contributing
2+
3+
We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our license file for more details.
4+
5+
## Getting started
6+
7+
### Restore dependencies
8+
9+
Installing dependencies into `./vendor` folder:
10+
11+
```bash
12+
$ composer install
13+
```
14+
15+
### Run tests
16+
17+
The tests we have are full fledged integration tests, meaning they will actually reach out to a Stream app. Hence the tests require at least two environment variables: `STREAM_KEY` and `STREAM_SECRET`.
18+
19+
```bash
20+
$ export STREAM_KEY="<your-key>"
21+
$ export STREAM_SECRET="<your-secret>"
22+
$ vendor/bin/phpunit
23+
```
24+
25+
> 💡 Note: On Unix systems you could use [direnv](https://direnv.net/) to set up these variables.
26+
27+
## IDE specific setup
28+
29+
If you use VS Code, you can pull up a Dockerized development environment with [Remote-Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. The proper configuration is already included in [.devcontainer](./.devcontainer/) folder. Once you're inside the container, just run the `composer install` command and you're good to go.

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ require_once "./vendor/autoload.php";
5151
Instantiate a new client, find your API keys in the dashboard.
5252

5353
```php
54-
$client = new GetStream\StreamChat\Client(getenv("STREAM_API_KEY"), getenv("STREAM_API_SECRET"));
54+
$client = new GetStream\StreamChat\Client(getenv("STREAM_KEY"), getenv("STREAM_SECRET"));
5555
```
5656

5757
Generate a token for clientside use
@@ -64,14 +64,6 @@ $expiration = (new DateTime())->getTimestamp() + 3600;
6464
$token = $client->createToken("bob-1", $expiration);
6565
```
6666

67-
Set location. Tell the client where your app is [hosted](https://getstream.io/chat/docs/multi_region/?language=php&q=locations).
68-
69-
```php
70-
71-
$client->setLocation("singapore");
72-
73-
```
74-
7567
## Update / Create users
7668

7769
```php
@@ -220,10 +212,18 @@ $client->deleteDevice($device_id, 'june');
220212

221213
### Copyright and License Information
222214

223-
[BSD-3](https://github.com/GetStream/stream-chat-php/blob/master/LICENSE).
215+
[BSD-3](./LICENSE).
224216

225217
## Contributing
226218

219+
Installing dependencies into `./vendor` folder:
220+
221+
```bash
222+
$ composer install
223+
```
224+
225+
For more tips head over to [CONTRIBUTING.md](./CONTRIBUTING.md).
226+
227227
### Commit message convention
228228

229229
Since we're autogenerating our [CHANGELOG](./CHANGELOG.md), we need to follow a specific commit message convention.
@@ -240,3 +240,8 @@ The job creates a pull request with the changelog. Check if it looks good.
240240
- Merge the pull request.
241241

242242
Once the PR is merged, it automatically kicks off another job which will create the tag and created a GitHub release.
243+
244+
## We are hiring!
245+
We've recently closed a $38 million Series B funding round and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.
246+
247+
Check out our current openings and apply via Stream's website.

composer.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"name": "get-stream/stream-chat",
33
"description": "A PHP client for Stream Chat (https://getstream.io/chat/)",
4-
"keywords": ["stream", "chat", "api", "chat-sdk"],
4+
"keywords": [
5+
"stream",
6+
"chat",
7+
"api",
8+
"chat-sdk"
9+
],
510
"homepage": "https://getstream.io/chat/",
611
"license": "BSD-3-Clause",
712
"authors": [
@@ -10,24 +15,27 @@
1015
"email": "[email protected]"
1116
}
1217
],
18+
"support": {
19+
"issues": "https://github.com/GetStream/stream-chat-php/issues",
20+
"docs": "https://getstream.io/chat/docs/php/?language=php"
21+
},
1322
"require": {
1423
"php": ">=7.3",
1524
"guzzlehttp/guzzle": "^6.3.3 || ^7.0.1",
1625
"firebase/php-jwt": "^v5.0.0"
1726
},
1827
"require-dev": {
19-
"friendsofphp/php-cs-fixer": "^2.18.0",
28+
"friendsofphp/php-cs-fixer": "^3.0.0",
2029
"phan/phan": "^5.2.1",
21-
"phpunit/phpunit": "^9.5.10",
22-
"ramsey/uuid": "^4.2.3"
30+
"phpunit/phpunit": "^9.5.11"
2331
},
2432
"autoload": {
2533
"psr-0": {
26-
"GetStream\\StreamChat" : "lib/"
34+
"GetStream\\StreamChat": "lib/"
2735
},
2836
"psr-4": {
29-
"GetStream\\Unit\\" : "tests/unit/",
30-
"GetStream\\Integration\\" : "tests/integration/"
37+
"GetStream\\Unit\\": "tests/unit/",
38+
"GetStream\\Integration\\": "tests/integration/"
3139
}
3240
}
33-
}
41+
}

0 commit comments

Comments
 (0)