Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit 3e184fb

Browse files
authored
Merge pull request #229 from mesilov/228-count-by-filter
2 parents 1caade7 + 6a4eabf commit 3e184fb

File tree

27 files changed

+403
-237
lines changed

27 files changed

+403
-237
lines changed

.github/workflows/phpstan.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,39 @@ on:
55
name: PHPStan checks
66

77
jobs:
8-
phpstan:
9-
name: PHPStan
8+
static-analysis:
9+
name: "PHPStan"
10+
runs-on: "ubuntu-latest"
1011

11-
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php-version:
16+
- "7.4"
17+
- "8.0"
18+
dependencies:
19+
- "lowest"
20+
- "highest"
1221

1322
steps:
1423
- name: "Checkout"
15-
uses: actions/checkout@v2
24+
uses: "actions/checkout@v2"
1625

17-
- name: PHPStan
18-
uses: docker://oskarstark/phpstan-ga
26+
- name: "Install PHP"
27+
uses: "shivammathur/setup-php@v2"
1928
with:
20-
args: analyse
29+
coverage: "none"
30+
php-version: "${{ matrix.php-version }}"
31+
extensions: mbstring
32+
tools: composer:v2
33+
34+
- name: "Install lowest dependencies"
35+
if: ${{ matrix.dependencies == 'lowest' }}
36+
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
37+
38+
- name: "Install highest dependencies"
39+
if: ${{ matrix.dependencies == 'highest' }}
40+
run: "composer update --no-interaction --no-progress --no-suggest"
41+
42+
- name: "PHPStan"
43+
run: "composer phpstan-analyse"

.github/workflows/phpunit.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,5 @@ jobs:
3333
run: |
3434
composer update ${{ env.COMPOSER_FLAGS }}
3535
36-
- name: "Run tests"
37-
run: "composer exec phpunit -- --verbose"
38-
39-
- name: Run test suite
40-
run: composer run-script unit-tests
36+
- name: "run unit tests"
37+
run: "composer phpunit-run-unit-tests"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ composer.lock
55
.phpunit.result.cache
66
tools/.env.local
77
tools/logs
8-
examples/logs
8+
examples/logs
9+
.env.local

CHANGELOG.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
# bitrix24-php-sdk change log
22

3-
## 2.0-alpha.4(25.11.2021)
3+
## 2.0-alpha.5 – 26.11.2021
4+
5+
### Added
6+
7+
* add method `countByFilter` for all related services, see
8+
issue [Добавить для всех сущностей метод подсчёта количества элементов по фильтру #228](https://github.com/mesilov/bitrix24-php-sdk/issues/228)
9+
10+
### Removed
11+
12+
* remove all `0.*` and `1.*` code from `2.*` branch
13+
14+
## 2.0-alpha.4 – 25.11.2021
415

516
### Changed
17+
618
* switch `symfony/http-client` to `5.3` version requirement.
719
* switch `symfony/http-client-contracts` to `^2.4` version requirement.
820
* switch `symfony/event-dispatcher` to `5.3.*` version requirement.
921
* switch `ramsey/uuid` to `^4.0` version requirement.
10-
22+
1123
### Fixed
24+
1225
* issue [Несовместимость с Laravel 8 #224](https://github.com/mesilov/bitrix24-php-sdk/issues/224)
1326

14-
## 2.0-alpha.3(14.11.2021)
27+
## 2.0-alpha.314.11.2021
1528

1629
* add php8 version support
1730
* change in scope «CRM» Product service and integration tests
@@ -22,7 +35,7 @@
2235
* bump phpunit version
2336
* bump phpstan version
2437

25-
## 2.0-alpha.2 (31.01.2021)
38+
## 2.0-alpha.2 31.01.2021
2639

2740
* remove Travis CI and migrate to Github Actions
2841
* add unit-tests in independent github action
@@ -37,7 +50,7 @@
3750
* add in scope «IM» IM service and integration test
3851
* add in default scope «Main» default service
3952

40-
## 2.0-alpha.1 (11.07.2020)
53+
## 2.0-alpha.1 11.07.2020
4154

4255
* remove all v1 code
4356
* migrate to Symfony HttpClient
@@ -46,6 +59,7 @@
4659
* add Events support
4760

4861
## 0.1.0 (14.11.2021)
62+
4963
branch version 1.x – bugfix and security releases only
5064

5165
## 0.7.0 (11.07.2020)

README.md

Lines changed: 93 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,62 @@ bitrix24-php-sdk [![Build Status](https://travis-ci.org/mesilov/bitrix24-php-sdk
33
[![License](https://poser.pugx.org/mesilov/bitrix24-php-sdk/license.svg)](https://packagist.org/packages/mesilov/bitrix24-php-sdk) [![Total Downloads](https://poser.pugx.org/mesilov/bitrix24-php-sdk/downloads.svg)](https://packagist.org/packages/mesilov/bitrix24-php-sdk)
44

55
A powerful PHP library for the Bitrix24 REST API
6+
### BITRIX24-PHP-SDK Documentation
67

7-
[Bitrix24 API documentation - Russian](http://dev.1c-bitrix.ru/rest_help/)<br />
8-
[Bitrix24 API documentation - English](https://training.bitrix24.com/rest_help/)<br />
9-
[Register new Bitrix24 account](https://www.bitrix24.ru/create.php?p=255670)<br />
8+
- [Russian](/docs/RU/documentation.md)
9+
- [English](/docs/EN/documentation.md)
1010

11-
### SDK 2.0 core features
11+
### BITRIX24-PHP-SDK ✨FEATURES✨
1212

13-
Bitrix24 auth features
13+
Support both auth modes:
1414

15-
- ~~work with auth tokens~~
16-
- ~~work with incoming webhooks~~
15+
- [x] work with auth tokens for Bitrix24 applications in marketplace
16+
- [x] work with incoming webhooks for simple integration projects for current portal
1717

18-
add low-level tools to devs:
18+
Low-level tools to devs:
1919

20-
- ~~2.1 events (token expired, domain url changed)~~
21-
- 2.2 rate-limiter - wait for symfony/symfony#37471
22-
- 2.3 RetryHttpClient - symfony/symfony#38182
20+
- Domain core events:
21+
- [x] Access Token expired
22+
- [ ] Bitrix24 portal domain url changed
23+
- [ ] Rate-limit strategy
24+
- [ ] Retry strategy for safe methods
2325

2426
API - level features
2527

26-
- ~~3.1 auto renew access tokens~~
27-
- 3.2 batch queries (work in progress)
28-
- ~~3.2.1 read~~
29-
- ~~3.2.2 write~~
30-
- 3.2.3 read + write
31-
- 3.2.4 read without count flag
32-
- 3.3 list queries with «start=-1» support
33-
- 3.4 offline queues
34-
- 3.5 add change domain URL support
35-
36-
Core DTO
37-
38-
- ~~Response~~
39-
- ~~Scope~~
40-
- ~~Time~~
41-
- ~~OAuthToken~~
42-
- ~~ApplicationProfile~~
43-
- ~~Pagination~~
44-
45-
### SDK Documentation
46-
47-
- [Russian](/docs/RU/documentation.md)
48-
- [English](/docs/EN/documentation.md)
28+
- [x] Auto renew access tokens
29+
- [ ] List queries with «start=-1» support
30+
- [ ] offline queues
31+
32+
Performance improvements 🚀
33+
34+
- Batch queries implemented with [PHP Generators](https://www.php.net/manual/en/language.generators.overview.php) – constant low memory and
35+
low CPI usage
36+
- [x] batch read data from bitrix24
37+
- [x] batch write data to bitrix24
38+
- [ ] write and read in one batch package
39+
- [ ] composite batch queries to many entities (work in progress)
40+
- [ ] read without count flag
41+
42+
### Development principles
43+
44+
- Good developer experience
45+
- auto-completion of methods at the IDE
46+
- typed method call signatures
47+
- typed results of method calls
48+
- helpers for typical operations
49+
- Good documentation
50+
- documentation on the operation of a specific method containing a link to the official documentation
51+
- documentation for working with the SDK
52+
- Performance first:
53+
- minimal impact on client code
54+
- ability to work with large amounts of data with constant memory consumption
55+
- efficient operation of the API using butch requests
56+
- Modern technology stack
57+
- based on [Symfony HttpClient](https://symfony.com/doc/current/http_client.html)
58+
- actual PHP versions language features
59+
- Reliable:
60+
- test coverage: unit, integration, contract
61+
- typical examples typical for different modes of operation and they are optimized for memory \ performance
4962

5063
### Architecture
5164

@@ -94,11 +107,46 @@ Core DTO
94107
Add `"mesilov/bitrix24-php-sdk": "2.x"` to `composer.json` of your application. Or clone repo to your project.
95108

96109
### Tests
110+
Tests locate in folder `tests` and we have two test types
111+
112+
#### Unit tests
113+
**Fast**, in-memory tests without a network I\O
114+
For run unit tests you must call in command line
115+
116+
```shell
117+
composer phpunit-run-unit-test
118+
```
119+
120+
#### Integration tests
121+
**Slow** tests with full lifecycle with your **test** Bitrix24 portal via webhook.
122+
123+
❗️Do not run integration tests with production portals ❗️
124+
125+
For run integration test you must:
126+
1. Create [new Bitrix24 portal](https://www.bitrix24.ru/create.php?p=255670) for development tests
127+
2. Go to left menu, click «Sitemap»
128+
3. Find menu item «Developer resources»
129+
4. Click on menu item «Other»
130+
5. Click on menu item «Inbound webhook»
131+
6. Assign all permisions with webhook and click «save» button
132+
7. Create file `/tests/.env.local` with same settings, see comments in `/tests/.env` file.
133+
```yaml
134+
APP_ENV=dev
135+
BITRIX24_WEBHOOK=https:// your portal webhook url
136+
INTEGRATION_TEST_LOG_LEVEL=500
137+
```
138+
8. call in command line
139+
140+
```shell
141+
composer composer phpunit-run-integration-tests
142+
```
97143

98-
SDK test locate in folder `tests` and we have two test types
144+
#### PHP Static Analysis Tool – phpstan
145+
Call in command line
146+
```shell
147+
composer phpstan-analyse
148+
```
99149

100-
- Unit: **fast**, in-memory tests without a network I\O
101-
- Integration: **slow** tests with full lifecycle with test Bitrix24 portal via webhook
102150

103151
### Submitting bugs and feature requests
104152

@@ -119,6 +167,14 @@ email: <mesilov.maxim@gmail.com>
119167

120168
### Sponsors
121169

170+
### Documentation
171+
172+
[Bitrix24 API documentation - Russian](http://dev.1c-bitrix.ru/rest_help/)
173+
174+
[Bitrix24 API documentation - English](https://training.bitrix24.com/rest_help/)
175+
176+
[Register new Bitrix24 account](https://www.bitrix24.ru/create.php?p=255670)
177+
122178
## Русский
123179

124180
### Принципы по которым ведётся разработка

composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
},
3030
"require-dev": {
3131
"monolog/monolog": "2.1.*",
32-
"symfony/console": "5.2.*",
33-
"symfony/dotenv": "5.2.*",
34-
"symfony/debug-bundle": "5.2.*",
32+
"symfony/console": "5.3.*",
33+
"symfony/dotenv": "5.3.*",
34+
"symfony/debug-bundle": "5.3.*",
3535
"phpstan/phpstan": "1.1.*",
3636
"phpunit/phpunit": "9.5.*",
3737
"roave/security-advisories": "dev-master"
@@ -48,8 +48,11 @@
4848
}
4949
},
5050
"scripts": {
51-
"unit-tests": [
52-
"phpunit --colors=always --verbose"
51+
"phpunit-run-unit-tests": [
52+
"phpunit --testsuite unit_tests"
53+
],
54+
"phpunit-run-integration-tests": [
55+
"phpunit --testsuite integration_tests"
5356
],
5457
"phpstan-analyse": [
5558
"vendor/bin/phpstan analyse"

phpstan.neon.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parameters:
2-
level: 1
2+
level: 5
33
paths:
44
- src/
5-
- tests/
5+
# - tests/
66
bootstrapFiles:
77
- tests/bootstrap.php

phpunit.xml.dist

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
44
backupGlobals="false"
55
colors="true"
6-
bootstrap="vendor/autoload.php"
6+
bootstrap="tests/bootstrap.php"
77
failOnRisky="true"
88
failOnWarning="true">
99
<coverage>
@@ -15,8 +15,11 @@
1515
<ini name="error_reporting" value="-1"/>
1616
</php>
1717
<testsuites>
18-
<testsuite name="Bitrix24 PHP SDK unit tests suite">
18+
<testsuite name="unit_tests">
1919
<directory>./tests/Unit</directory>
2020
</testsuite>
21+
<testsuite name="integration_tests">
22+
<directory>./tests/Integration</directory>
23+
</testsuite>
2124
</testsuites>
2225
</phpunit>

src/Core/Batch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ public function getTraversable(bool $isHaltOnError): Generator
476476
}
477477

478478
$nextItem = null;
479-
if ($resultNextItems !== null && array_key_exists($singleQueryKey, $resultNextItems) && count($resultNextItems) > 0) {
479+
if ($resultNextItems !== null && array_key_exists($singleQueryKey, $resultNextItems)) {
480480
$nextItem = $resultNextItems[$singleQueryKey];
481481
}
482482

@@ -544,7 +544,7 @@ private function convertToApiCommands(): array
544544
$apiCommands = [];
545545
foreach ($this->commands as $itemCommand) {
546546
/**
547-
* @var $itemCommand Command
547+
* @var Command $itemCommand
548548
*/
549549
$apiCommands[$itemCommand->getName() ?? $itemCommand->getUuid()->toString()] = sprintf(
550550
'%s?%s',

0 commit comments

Comments
 (0)