Skip to content
Merged
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
51 changes: 51 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
push:
pull_request:

name: PHPStan lint checks

jobs:
static-analysis:
name: "PHPStan"
runs-on: ${{ matrix.operating-system }}

strategy:
fail-fast: false
matrix:
php-version:
- "8.3"
dependencies: [ highest ]
operating-system: [ ubuntu-latest]

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
extensions: json, bcmath, curl, intl, mbstring
tools: composer:v2

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "PHPStan"
run: "make lint-phpstan"

- name: "is PHPStan check succeeded"
if: ${{ success() }}
run: |
echo '✅ PHPStan check pass, congratulations!'

- name: "is PHPStan check failed"
if: ${{ failure() }}
run: |
echo '::error:: ❗️ PHPStan check failed (╯°益°)╯彡┻━┻'
50 changes: 50 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "PHPUnit tests"

on:
push:
pull_request:

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"

jobs:
tests:
name: "PHPUnit tests"

runs-on: ${{ matrix.operating-system }}

strategy:
fail-fast: false
matrix:
php-version:
- "8.3"
dependencies: [ highest ]
operating-system: [ ubuntu-latest]

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
extensions: json, bcmath, curl, intl, mbstring

- name: "Install dependencies"
run: |
composer update ${{ env.COMPOSER_FLAGS }}

- name: "run unit tests"
run: "make test-unit"

- name: "is unit tests tests succeeded"
if: ${{ success() }}
run: |
echo '✅ unit tests pass, congratulations!'

- name: "is unit tests tests failed"
if: ${{ failure() }}
run: |
echo '::error:: ❗️ unit tests tests failed (╯°益°)╯彡┻━┻'
51 changes: 51 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
push:
pull_request:

name: Rector lint checks

jobs:
static-analysis:
name: "Rector"
runs-on: ${{ matrix.operating-system }}

strategy:
fail-fast: false
matrix:
php-version:
- "8.3"
dependencies: [ highest ]
operating-system: [ ubuntu-latest]

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
extensions: json, bcmath, curl, intl, mbstring
tools: composer:v2

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Rector"
run: "make lint-rector"

- name: "is Rector check succeeded"
if: ${{ success() }}
run: |
echo '✅ Rector check pass, congratulations!'

- name: "is PHPStan check failed"
if: ${{ failure() }}
run: |
echo '::error:: ❗️ Rector check failed (╯°益°)╯彡┻━┻'
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.idea*
/vendor
/.cache
composer.phar
composer.lock
.phpunit.result.cache
*.log
.env.local
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is part of the bitrix24-app-core package.
#
# © Maksim Mesilov <mesilov.maxim@gmail.com>
#
# For the full copyright and license information, please view the MIT-LICENSE.txt
# file that was distributed with this source code.

default:
@echo "make needs target:"
@egrep -e '^\S+' ./Makefile | grep -v default | sed -r 's/://' | sed -r 's/^/ - /'

# linters
lint-phpstan:
vendor/bin/phpstan --memory-limit=1G analyse
lint-rector:
vendor/bin/rector process --dry-run
lint-rector-fix:
vendor/bin/rector process

# unit tests
test-unit:
vendor/bin/phpunit --testsuite unit_tests --display-warnings

test-integration:
vendor/bin/phpunit --testsuite integration_tests --display-warnings
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# bitrix24-app-core

Bitrix24 application core

## Область применения

Библиотека предназначена для быстрой разработки приложений для Битркис24. Предоставляет слой хранения данных в СУБД
[PostgreSQL](https://www.postgresql.org/), использует [Doctrine ORM](https://www.doctrine-project.org/).

Реализует [контракты](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts) из
bitrix24-php-sdk.

## Поддерживаемые контракты

### Bitrix24Accounts

Отвечает за
хранение [аккаунтов Битрикс24](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/Bitrix24Accounts)
с токенами доступа к порталу.

### ApplicationInstallations

Отвечает за
хранение [фактов установок](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/ApplicationInstallations)
приложения на конкретный портал Битркис24

### ContactPersons

Отвечает за
хранение [контактных лиц](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/ContactPersons),
которые произвели установку приложения

### Bitrix24Partners

Отвечает за
хранение [партнёра](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/Bitrix24Partners
) Битрикс24, который произвёл установку или обслуживает портал




68 changes: 68 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "mesilov/bitrix24-app-core",
"description": "A powerful PHP library for rapid Bitrix24 application development",
"keywords": [
"Bitrix24",
"PHP",
"REST",
"API",
"Bitrix24 Application",
"SaaS"
],
"type": "library",
"homepage": "https://github.com/mesilov/bitrix24-app-core",
"license": "MIT",
"authors": [
{
"name": "Maksim Mesilov",
"homepage": "https://github.com/mesilov/"
}
],
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"require": {
"php": "8.3.*",
"ext-json": "*",
"ext-curl": "*",
"ext-intl": "*",
"psr/log": "^3",
"fig/http-message-util": "^1",
"giggsey/libphonenumber-for-php": "^8",
"darsyn/ip": "^5",
"nesbot/carbon": "^3",
"moneyphp/money": "^4",
"mesilov/bitrix24-php-sdk": "^2",
"doctrine/orm": "^2",
"doctrine/doctrine-bundle": "^2",
"doctrine/doctrine-migrations-bundle": "^3",
"symfony/event-dispatcher": "^7",
"symfony/uid": "^7",
"knplabs/knp-paginator-bundle": "^6"
},
"require-dev": {
"monolog/monolog": "^3",
"fakerphp/faker": "^1",
"phpstan/phpstan": "^1",
"phpunit/phpunit": "^11",
"psalm/phar": "^5",
"rector/rector": "^1",
"roave/security-advisories": "dev-master",
"symfony/debug-bundle": "^7",
"symfony/stopwatch": "^7"
},
"autoload": {
"psr-4": {
"Bitrix24\\SDK\\ApplicationCore\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Bitrix24\\SDK\\ApplicationCore\\Tests\\": "tests",
"Bitrix24\\SDK\\Tests\\":"vendor/mesilov/bitrix24-php-sdk/tests"
}
}
}
14 changes: 14 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
parameters:
level: 5
paths:
- src/
- tests/
bootstrapFiles:
- tests/bootstrap.php
parallel:
jobSize: 20
maximumNumberOfProcesses: 8
minimumNumberOfJobsPerProcess: 2
editorUrlTitle: '%%relFile%%:%%line%%'
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
treatPhpDocTypesAsCertain: false
22 changes: 22 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" colors="true"
bootstrap="tests/bootstrap.php" failOnRisky="true" failOnWarning="true"
displayDetailsOnTestsThatTriggerWarnings="true">
<php>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="unit_tests">
<directory>./tests/Unit</directory>
</testsuite>
<testsuite name="integration_tests">
<directory>./tests/Integration</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
52 changes: 52 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* This file is part of the bitrix24-app-core package.
*
* © Maksim Mesilov <mesilov.maxim@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\DowngradeLevelSetList;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src/',
__DIR__ . '/tests/',
])
->withCache(cacheDirectory: __DIR__ . '.cache/rector')
->withSets(
[
PHPUnitSetList::PHPUNIT_110
]
)
->withImportNames(
importNames: false,
importDocBlockNames: false,
importShortClasses: false,
removeUnusedImports: false,
)
->withPhpSets(
php83: true
)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
naming: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true
)
->withSkip([
RenamePropertyToMatchTypeRector::class
]);
Loading