Skip to content

Commit 32797f6

Browse files
Merge pull request #152 from spatie/v3
V3
2 parents 0f2c625 + 1b09b1c commit 32797f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+782
-1004
lines changed

.github/workflows/phpstan.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
- '.github/workflows/phpstan.yml'
8+
- 'phpstan.neon.dist'
9+
- 'phpstan-baseline.neon'
10+
11+
jobs:
12+
phpstan:
13+
name: phpstan
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.3'
22+
coverage: none
23+
24+
- name: Install composer dependencies
25+
uses: ramsey/composer-install@v3
26+
27+
- name: Run PHPStan
28+
run: ./vendor/bin/phpstan --error-format=github

.github/workflows/psalm.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,24 @@ You can also set the participation status of an attendee:
160160

161161
``` php
162162
Event::create()
163-
->attendee('[email protected]', 'Ruben', ParticipationStatus::accepted())
163+
->attendee('[email protected]', 'Ruben', ParticipationStatus::Accepted)
164164
...
165165
```
166166

167167
There are five participation statuses:
168168

169-
- `ParticipationStatus::accepted()`
170-
- `ParticipationStatus::declined()`
171-
- `ParticipationStatus::tentative()`
172-
- `ParticipationStatus::needs_action()`
173-
- `ParticipationStatus::delegated()`
169+
- `ParticipationStatus::Accepted`
170+
- `ParticipationStatus::Declined`
171+
- `ParticipationStatus::Tentative`
172+
- `ParticipationStatus::NeedsAction`
173+
- `ParticipationStatus::Delegated`
174174

175175

176176
You can indicate that an attendee is required to RSVP to an event:
177177

178178
``` php
179179
Event::create()
180-
->attendee('[email protected]', 'Ruben', ParticipationStatus::needs_action(), requiresResponse: true)
180+
->attendee('[email protected]', 'Ruben', ParticipationStatus::NeedsAction, requiresResponse: true)
181181
...
182182
```
183183

@@ -201,21 +201,21 @@ The status of an event can be set:
201201

202202
``` php
203203
Event::create()
204-
->status(EventStatus::cancelled())
204+
->status(EventStatus::Cancelled)
205205
...
206206
```
207207

208208
There are three event statuses:
209209

210-
- `EventStatus::confirmed()`
211-
- `EventStatus::cancelled()`
212-
- `EventStatus::tentative()`
210+
- `EventStatus::Confirmed`
211+
- `EventStatus::Cancelled`
212+
- `EventStatus::Tentative`
213213

214-
An event can be classified(`public`, `private`, `confidential`) as such:
214+
An event can be classified(`Public`, `Private`, `Confidential`) as such:
215215

216216
``` php
217217
Event::create()
218-
->classification(Classification::private())
218+
->classification(Classification::Private)
219219
...
220220
```
221221

@@ -244,16 +244,16 @@ You can add an image as such:
244244
Event::create()
245245
->image('https://spatie.be/logo.svg')
246246
->image('https://spatie.be/logo.svg', 'text/svg+xml')
247-
->image('https://spatie.be/logo.svg', 'text/svg+xml', Display::badge())
247+
->image('https://spatie.be/logo.svg', 'text/svg+xml', Display::Badge)
248248
...
249249
```
250250

251251
There are four different image display types:
252252

253-
- `Display::badge()`
254-
- `Display::graphic()`
255-
- `Display::fullsize()`
256-
- `Display::thumbnail()`
253+
- `Display::Badge`
254+
- `Display::Graphic`
255+
- `Display::Fullsize`
256+
- `Display::Thumbnail`
257257

258258
You can add a sequence to an event as such:
259259

@@ -348,7 +348,7 @@ You can manually add timezones to a calendar if desired as such:
348348

349349
```php
350350
$timezoneEntry = TimezoneEntry::create(
351-
TimezoneEntryType::daylight(),
351+
TimezoneEntryType::Daylight,
352352
new DateTime('23 march 2020'),
353353
'+00:00',
354354
'+02:00'
@@ -414,7 +414,7 @@ Event::create('Laracon Online')
414414
Recurrence rules or RRule's in short, make it possible to add a repeating event in your calendar by describing when it repeats within an RRule. First, we have to create an RRule:
415415

416416
```php
417-
$rrule = RRule::frequency(RecurrenceFrequency::daily());
417+
$rrule = RRule::frequency(RecurrenceFrequency::Daily);
418418
```
419419

420420
This rule describes an event that will be repeated daily. You can also set the frequency to `secondly`, `minutely`, `hourly`, `weekly`, `monthly` or `yearly`.
@@ -423,95 +423,95 @@ The RRULE can be added to an event as such:
423423

424424
``` php
425425
Event::create('Laracon Online')
426-
->rrule(RRule::frequency(RecurrenceFrequency::monthly()));
426+
->rrule(RRule::frequency(RecurrenceFrequency::Monthly));
427427
```
428428

429429
It is possible to finetune the RRule to your personal taste; let's have a look!
430430

431431
A RRule can start from a certain point in time:
432432

433433
```php
434-
$rrule = RRule::frequency(RecurrenceFrequency::daily())->starting(new DateTime('now'));
434+
$rrule = RRule::frequency(RecurrenceFrequency::Daily)->starting(new DateTime('now'));
435435
```
436436

437437
And stop at a certain point:
438438

439439
```php
440-
$rrule = RRule::frequency(RecurrenceFrequency::daily())->until(new DateTime('now'));
440+
$rrule = RRule::frequency(RecurrenceFrequency::Daily)->until(new DateTime('now'));
441441
```
442442

443443
It can only be repeated for a few times, 10 times for example:
444444

445445
```php
446-
$rrule = RRule::frequency(RecurrenceFrequency::daily())->times(10);
446+
$rrule = RRule::frequency(RecurrenceFrequency::Daily)->times(10);
447447
```
448448

449449
The interval of the repetition can be changed:
450450

451451
```php
452-
$rrule = RRule::frequency(RecurrenceFrequency::daily())->interval(2);
452+
$rrule = RRule::frequency(RecurrenceFrequency::Daily)->interval(2);
453453
```
454454

455455
When this event starts on Monday, for example, the next repetition of this event will not occur on Tuesday but Wednesday. You can do the same for all the frequencies.
456456

457457
It is also possible to repeat the event on a specific weekday:
458458

459459
```php
460-
$rrule = RRule::frequency(RecurrenceFrequency::monthly())->onWeekDay(
461-
RecurrenceDay::friday()
460+
$rrule = RRule::frequency(RecurrenceFrequency::Monthly)->onWeekDay(
461+
RecurrenceDay::Friday
462462
);
463463
```
464464

465465
Or on a specific weekday of a week in the month:
466466

467467
```php
468-
$rrule = RRule::frequency(RecurrenceFrequency::monthly())->onWeekDay(
469-
RecurrenceDay::friday(), 3
468+
$rrule = RRule::frequency(RecurrenceFrequency::Monthly)->onWeekDay(
469+
RecurrenceDay::Friday, 3
470470
);
471471
```
472472

473473
Or on the last weekday of a month:
474474

475475
```php
476-
$rrule = RRule::frequency(RecurrenceFrequency::monthly())->onWeekDay(
477-
RecurrenceDay::sunday(), -1
476+
$rrule = RRule::frequency(RecurrenceFrequency::Monthly)->onWeekDay(
477+
RecurrenceDay::Sunday, -1
478478
);
479479
```
480480

481481
You can repeat on a specific day in the month:
482482

483483
```php
484-
$rrule = RRule::frequency(RecurrenceFrequency::monthly())->onMonthDay(16);
484+
$rrule = RRule::frequency(RecurrenceFrequency::Monthly)->onMonthDay(16);
485485
```
486486

487487
It is even possible to give an array of days in the month:
488488

489489
```php
490-
$rrule = RRule::frequency(RecurrenceFrequency::monthly())->onMonthDay(
490+
$rrule = RRule::frequency(RecurrenceFrequency::Monthly)->onMonthDay(
491491
[5, 10, 15, 20]
492492
);
493493
```
494494

495495
Repeating can be done for certain months (for example only in the second quarter):
496496

497497
```php
498-
$rrule = RRule::frequency(RecurrenceFrequency::monthly())->onMonth(
499-
[RecurrenceMonth::april(), RecurrenceMonth::may(), RecurrenceMonth::june()]
498+
$rrule = RRule::frequency(RecurrenceFrequency::Monthly)->onMonth(
499+
[RecurrenceMonth::April, RecurrenceMonth::May, RecurrenceMonth::June]
500500
);
501501
```
502502

503503
Or just on one month only:
504504

505505
```php
506-
$rrule = RRule::frequency(RecurrenceFrequency::monthly())->onMonth(
507-
RecurrenceMonth::october()
506+
$rrule = RRule::frequency(RecurrenceFrequency::Monthly)->onMonth(
507+
RecurrenceMonth::October
508508
);
509509
```
510510

511511
It is possible to set the day when the week starts:
512512

513513
```php
514-
$rrule = RRule::frequency(RecurrenceFrequency::monthly())->weekStartsOn(
514+
$rrule = RRule::frequency(RecurrenceFrequency::Monthly)->weekStartsOn(
515515
ReccurenceDay::monday()
516516
);
517517
```
@@ -520,15 +520,15 @@ You can provide a specific date on which an event won't be repeated:
520520

521521
```php
522522
Event::create('Laracon Online')
523-
->rrule(RRule::frequency(RecurrenceFrequency::daily()))
523+
->rrule(RRule::frequency(RecurrenceFrequency::Daily))
524524
->doNotRepeatOn(new DateTime('05/16/2020 12:00:00'));
525525
```
526526

527527
It is also possible to give an array of dates on which the event won't be repeated:
528528

529529
```php
530530
Event::create('Laracon Online')
531-
->rrule(RRule::frequency(RecurrenceFrequency::daily()))
531+
->rrule(RRule::frequency(RecurrenceFrequency::Daily))
532532
->doNotRepeatOn([new DateTime('05/16/2020 12:00:00'), new DateTime('08/13/2020 15:00:00')]);
533533
```
534534

@@ -601,7 +601,7 @@ A timezone consists of multiple entries where the time of the timezone changed r
601601

602602
```php
603603
$entry = TimezoneEntry::create(
604-
TimezoneEntryType::standard(),
604+
TimezoneEntryType::Standard,
605605
new DateTime('16 may 2020 12:00:00'),
606606
'+00:00',
607607
'+02:00'
@@ -622,7 +622,7 @@ An RRule for the entry can be given as such:
622622

623623
```php
624624
$entry = TimezoneEntry::create(...)
625-
->rrule(RRule::frequency(RecurrenceFrequency::daily()));
625+
->rrule(RRule::frequency(RecurrenceFrequency::Daily));
626626
```
627627

628628
In the end you can add an entry to a timezone:
@@ -704,10 +704,6 @@ It is possible to create your subcomponents by extending the `Component` class.
704704
composer test
705705
```
706706

707-
### Alternatives
708-
709-
We strive for a simple and easy to use API. Want something more? Then check out this [package](https://github.com/markuspoerschke/iCal) by Markus Poerschke.
710-
711707
### Changelog
712708

713709
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

UPGRADING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Upgrading
22

3+
## Upgrading from 2.x to 3.x
4+
5+
Version 3 has some minor changes:
6+
7+
### Enums
8+
9+
We removed the dependency on spatie/enum and opted for PHP native enums. This means that you should update all the enums in your code belonging to the package:
10+
11+
- `Spatie\IcalendarGenerator\Enums\Classification`
12+
- `Spatie\IcalendarGenerator\Enums\Display`
13+
- `Spatie\IcalendarGenerator\Enums\EventStatus`
14+
- `Spatie\IcalendarGenerator\Enums\ParticipationStatus`
15+
- `Spatie\IcalendarGenerator\Enums\RecurrenceDay`
16+
- `Spatie\IcalendarGenerator\Enums\RecurrenceFrequency`
17+
- `Spatie\IcalendarGenerator\Enums\RecurrenceMonth`
18+
- `Spatie\IcalendarGenerator\Enums\TimezoneEntryType`
19+
20+
Like so:
21+
22+
```php
23+
RecurrenceMonth::january(); // old
24+
25+
RecurrenceMonth::January; // new
26+
```
27+
28+
### Payloads
29+
30+
If you were building your own payloads, please notice that the `optional` and `multiple` methods have been removed.
31+
32+
## Upgrading from 1.x to 2.x
33+
334
Version 2.0 adds some breaking changes:
435

536
- PHP 7.4|8.0 only

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
],
2121
"require": {
2222
"php": "^8.1",
23-
"ext-mbstring": "*",
24-
"spatie/enum": "^3.11"
23+
"ext-mbstring": "*"
2524
},
2625
"require-dev": {
2726
"ext-json": "*",
2827
"nesbot/carbon": "^3.5",
2928
"larapack/dd": "^1.1",
3029
"pestphp/pest": "^2.34",
31-
"spatie/pest-plugin-snapshots": "^2.1"
30+
"spatie/pest-plugin-snapshots": "^2.1",
31+
"phpstan/phpstan" : "^2.0"
3232
},
3333
"autoload": {
3434
"psr-4": {
@@ -42,7 +42,7 @@
4242
},
4343
"scripts": {
4444
"test": "vendor/bin/pest",
45-
"psalm": "vendor/bin/psalm",
45+
"analyse": "vendor/bin/phpstan analyse",
4646
"test-coverage": "vendor/bin/pest --coverage-html coverage"
4747
},
4848
"config": {

0 commit comments

Comments
 (0)