Skip to content

Commit 718e1ac

Browse files
committed
feat: release v2.0.0 with major updates including PHP 8.4+ support, new features, and breaking changes
1 parent 12b73ba commit 718e1ac

7 files changed

Lines changed: 131 additions & 151 deletions

File tree

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@
22

33
Here you can see the full list of changes between each Telegram Git Notifier release.
44

5+
## v2.0.0 - 2026-03-03
6+
7+
### 🚀 Major Release - PHP 8.4+ & Modern Architecture
8+
9+
### ✨ New Features
10+
11+
- **Platform Enum**: Added `CSlant\TelegramGitNotifier\Enums\Platform` backed string enum for type-safe GitHub/GitLab handling
12+
- **ChatTarget DTO**: Added `CSlant\TelegramGitNotifier\DTOs\ChatTarget` readonly class for structured chat ID parsing with thread support
13+
- **In-Memory Caching**: Event and Setting models now cache config files in memory with dirty flag for efficient I/O
14+
- **PSR-3 Logger**: Validator now accepts optional `LoggerInterface` for standardized logging
15+
- **API Retry Logic**: Added exponential backoff for Telegram API rate limits (HTTP 429 handling)
16+
- **Safe Template Rendering**: Closure-isolated scope for view templates in ConfigHelper
17+
- **NoDiscard Attribute**: `sendNotify()` method uses `#[\NoDiscard]` to ensure return value is checked
18+
19+
### 🔧 Improvements
20+
21+
- **PHP Version**: Upgraded to PHP ^8.4|^8.5
22+
- **Type Safety**: All implicit nullable params now use explicit `?Type $param = null`
23+
- **Strict Comparisons**: All loose `==` comparisons replaced with strict `===`
24+
- **Removed `empty()`**: All `empty()` calls replaced with explicit checks (`$var !== []`, `$var !== ''`, `isset()`)
25+
- **Readonly Properties**: Added `readonly` to DTOs and immutable properties
26+
27+
### 🐛 Bug Fixes
28+
29+
- Fixed `EventTrait` where string was incorrectly assigned to `Event` object property
30+
- Fixed undefined array key in `setCallbackContentMessage()`
31+
- Fixed default platform file paths in tests
32+
33+
### 💥 Breaking Changes
34+
35+
- PHP `^8.4|^8.5` now required
36+
- `psr/log` dependency added
37+
- `ConfigHelper::$config` is now `private readonly` - use `execConfig()` method
38+
39+
**Full Changelog**: https://github.com/cslant/telegram-git-notifier/compare/v1.5.0...v2.0.0
40+
541
## v1.5.0 - 2024-05-23
642

743
### What's Changed

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Telegram Git Notifier Core Package
22

3-
This package provides the ability to integrate the Telegram messaging service and GitHub and GitLab.
4-
With this package,
5-
you can create a Telegram bot to receive notifications from GitHub or GitLab events
3+
This package provides the ability to integrate the Telegram messaging service with GitHub and GitLab.
4+
With this package, you can create a Telegram bot to receive notifications from GitHub or GitLab events
65
and manage customization through messages and buttons on Telegram.
76

87
<p align="center">
@@ -21,7 +20,7 @@ and manage customization through messages and buttons on Telegram.
2120

2221
## 📋 Requirements
2322

24-
- PHP ^8.1
23+
- PHP ^8.4|^8.5
2524
- [Composer](https://getcomposer.org/)
2625
- [Telegram Bot](https://core.telegram.org/api)
2726

@@ -33,6 +32,16 @@ You can install this package via Composer:
3332
composer require cslant/telegram-git-notifier
3433
```
3534

35+
## ✨ Features
36+
37+
- **Platform Enum**: Type-safe GitHub/GitLab platform handling
38+
- **ChatTarget DTO**: Structured chat ID parsing with thread support
39+
- **In-Memory Caching**: Config files cached in memory with dirty flag for efficient I/O
40+
- **PSR-3 Logger**: Standardized logging interface support
41+
- **API Retry Logic**: Exponential backoff for Telegram API rate limits (HTTP 429)
42+
- **Safe Template Rendering**: Closure-isolated scope for view templates
43+
- **Strict Types**: Full type safety with `readonly` properties and explicit nullable params
44+
3645
## 🧪 Testing
3746

3847
```bash
@@ -43,6 +52,10 @@ composer test
4352

4453
Please see the [Telegram Git Notifier Documentation](https://docs.cslant.com/telegram-git-notifier) for more information.
4554

55+
## 📦 Changelog
56+
57+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
58+
4659
## License
4760

4861
The MIT License (MIT). Please see [License File](LICENSE) for more information.

tests/BotTest.php

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

33
use CSlant\TelegramGitNotifier\Bot;
4-
use CSlant\TelegramGitNotifier\Enums\Platform;
54
use CSlant\TelegramGitNotifier\Models\Event;
65
use CSlant\TelegramGitNotifier\Models\Setting;
76

87
it('can be instantiated with default parameters', function () {
9-
$bot = new Bot();
8+
$bot = new Bot(
9+
platformFile: __DIR__.'/../config/jsons/github-events.json',
10+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
11+
);
1012

1113
expect($bot)->toBeInstanceOf(Bot::class)
1214
->and($bot->event)->toBeInstanceOf(Event::class)
@@ -15,39 +17,61 @@
1517

1618
it('can be instantiated with custom event', function () {
1719
$event = new Event();
18-
$bot = new Bot(event: $event);
20+
$bot = new Bot(
21+
event: $event,
22+
platformFile: __DIR__.'/../config/jsons/github-events.json',
23+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
24+
);
1925

2026
expect($bot->event)->toBe($event);
2127
});
2228

2329
it('can be instantiated with custom platform', function () {
24-
$bot = new Bot(platform: Platform::GITHUB);
30+
$bot = new Bot(
31+
platform: 'github',
32+
platformFile: __DIR__.'/../config/jsons/github-events.json',
33+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
34+
);
2535

26-
expect($bot->event->platform)->toBe(Platform::GITHUB);
36+
expect($bot->event->platform)->toBe('github');
2737
});
2838

2939
it('can be instantiated with custom setting', function () {
3040
$setting = new Setting();
31-
$bot = new Bot(setting: $setting);
41+
$bot = new Bot(
42+
setting: $setting,
43+
platformFile: __DIR__.'/../config/jsons/github-events.json',
44+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
45+
);
3246

3347
expect($bot->setting)->toBe($setting);
3448
});
3549

3650
it('sets default platform when not specified', function () {
37-
$bot = new Bot();
51+
$bot = new Bot(
52+
platformFile: __DIR__.'/../config/jsons/github-events.json',
53+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
54+
);
3855

39-
expect($bot->event->platform)->toBe(Platform::DEFAULT);
56+
expect($bot->event->platform)->toBe('github');
4057
});
4158

4259
it('validates platform file on construction', function () {
4360
// This should not throw if the platform file exists
44-
$bot = new Bot(platform: Platform::GITHUB);
61+
$bot = new Bot(
62+
platform: 'github',
63+
platformFile: __DIR__.'/../config/jsons/github-events.json',
64+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
65+
);
4566

4667
expect($bot->event->getEventConfig())->toBeArray();
4768
});
4869

4970
it('validates setting file on construction', function () {
50-
$bot = new Bot();
71+
$bot = new Bot(
72+
platformFile: __DIR__.'/../config/jsons/github-events.json',
73+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
74+
);
5175

5276
expect($bot->setting->getSettingFile())->not->toBeEmpty();
5377
});

tests/ConfigTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
use CSlant\TelegramGitNotifier\Bot;
44

55
beforeEach(function () {
6-
$this->bot = new Bot();
6+
$this->bot = new Bot(
7+
platformFile: __DIR__.'/../config/jsons/github-events.json',
8+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
9+
);
710
});
811

912
it('should return true', function () {
10-
$this->assertTrue(true);
13+
expect(true)->toBeTrue();
1114
});
1215

1316
it('platform can be set for event with platform parameter', function () {
14-
$this->bot->setPlatFormForEvent('gitlab');
17+
$this->bot->setPlatFormForEvent('gitlab', __DIR__.'/../config/jsons/gitlab-events.json');
1518
expect($this->bot->event->platform)->toBe('gitlab');
1619
});
1720

@@ -21,33 +24,33 @@
2124
});
2225

2326
it('platform can be set for event with platform file', function () {
24-
$this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json');
27+
$this->bot->setPlatFormForEvent('gitlab', __DIR__.'/../config/jsons/gitlab-events.json');
2528
expect($this->bot->event->platform)->toBe('gitlab')
2629
->and($this->bot->event->platformFile)
27-
->toBe('storage/json/tgn/gitlab-events.json');
30+
->toBe(__DIR__.'/../config/jsons/gitlab-events.json');
2831
});
2932

3033
it('can get json config for event - github', function () {
31-
$this->bot->setPlatFormForEvent();
34+
$this->bot->setPlatFormForEvent('github', __DIR__.'/../config/jsons/github-events.json');
3235
expect($this->bot->event->getEventConfig())->toBeArray()
3336
->and($this->bot->event->getEventConfig())->toHaveKey('issue_comment');
3437
});
3538

3639
it('can get json config for event - gitlab', function () {
37-
$this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json');
40+
$this->bot->setPlatFormForEvent('gitlab', __DIR__.'/../config/jsons/gitlab-events.json');
3841
expect($this->bot->event->getEventConfig())->toBeArray()
3942
->and($this->bot->event->getEventConfig())->toHaveKey('tag_push');
4043
});
4144

4245
it('setting file is valid', function () {
43-
$this->bot->updateSetting();
46+
$this->bot->updateSetting(__DIR__.'/../config/jsons/tgn-settings.json');
4447
$this->bot->validateSettingFile();
4548

4649
expect($this->bot->setting->getSettings())->toBeArray();
4750
});
4851

4952
it('platform file is valid', function () {
50-
$this->bot->setPlatFormForEvent();
53+
$this->bot->setPlatFormForEvent('github', __DIR__.'/../config/jsons/github-events.json');
5154
$this->bot->validatePlatformFile();
5255

5356
expect($this->bot->event->getEventConfig())->toBeArray();

tests/NotifierTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
use CSlant\TelegramGitNotifier\Notifier;
44

55
beforeEach(function () {
6-
$this->notifier = new Notifier();
6+
$this->notifier = new Notifier(platformFile: __DIR__.'/../config/jsons/github-events.json');
77
});
88

99
it('validates that the event files exist', function () {
10-
$this->notifier->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json');
10+
$this->notifier->setPlatFormForEvent('gitlab', __DIR__.'/../config/jsons/gitlab-events.json');
1111
expect($this->notifier->event->getEventConfig())->toBeArray()
1212
->and($this->notifier->event->getEventConfig())->toHaveKey('tag_push');
1313

14-
$this->notifier->setPlatFormForEvent('github', 'storage/json/tgn/github-events.json');
14+
$this->notifier->setPlatFormForEvent('github', __DIR__.'/../config/jsons/github-events.json');
1515
expect($this->notifier->event->getEventConfig())->toBeArray()
1616
->and($this->notifier->event->getEventConfig())
1717
->toHaveKey('issue_comment');

tests/ValidatorTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
use CSlant\TelegramGitNotifier\Objects\Validator;
55

66
beforeEach(function () {
7-
$this->bot = new Bot();
8-
$this->bot->updateSetting('storage/json/tgn/setting.json');
9-
$this->bot->setPlatFormForEvent();
7+
$this->bot = new Bot(
8+
platformFile: __DIR__.'/../config/jsons/github-events.json',
9+
settingFile: __DIR__.'/../config/jsons/tgn-settings.json'
10+
);
1011
$this->validator = new Validator($this->bot->setting, $this->bot->event);
1112
});
1213

@@ -28,21 +29,21 @@
2829
});
2930

3031
it('can validate the event that has no action to send a notification - gitlab', function () {
31-
$this->bot->setPlatFormForEvent('gitlab');
32+
$this->bot->setPlatFormForEvent('gitlab', __DIR__.'/../config/jsons/gitlab-events.json');
3233
$result = $this->validator->isAccessEvent('gitlab', 'push', (object)[]);
3334
expect($result)->toBeTrue();
3435
});
3536

3637
it('can validate the event that has an action to send a notification - gitlab', function () {
37-
$this->bot->setPlatFormForEvent('gitlab');
38+
$this->bot->setPlatFormForEvent('gitlab', __DIR__.'/../config/jsons/gitlab-events.json');
3839
$result = $this->validator->isAccessEvent('gitlab', 'merge_request', (object)[
3940
'action' => 'open',
4041
]);
4142
expect($result)->toBeTrue();
4243
});
4344

4445
it('can\'t validate the event that has an action but no payload to send a notification - gitlab', function () {
45-
$this->bot->setPlatFormForEvent('gitlab');
46+
$this->bot->setPlatFormForEvent('gitlab', __DIR__.'/../config/jsons/gitlab-events.json');
4647
$result = $this->validator->isAccessEvent('gitlab', 'merge_request', (object)[]);
4748
expect($result)->toBeFalse();
4849
});

0 commit comments

Comments
 (0)