Skip to content

Commit

Permalink
update php version and all classes, create ListenerException and crea…
Browse files Browse the repository at this point in the history
…te github workflows
  • Loading branch information
mulertech committed Dec 29, 2024
1 parent 44466dc commit feea235
Show file tree
Hide file tree
Showing 21 changed files with 340 additions and 71 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
linux_tests:
runs-on: ubuntu-24.04

strategy:
fail-fast: true
matrix:
php: [8.2, 8.3, 8.4]
phpunit: ['10', '11']
stability: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: none

- name: Set PHPUnit
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer require phpunit/phpunit:^${{ matrix.phpunit }} --dev --no-interaction --no-update

- name: Install dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit --display-deprecation

windows_tests:
runs-on: windows-2022

strategy:
fail-fast: true
matrix:
php: [8.2, 8.3, 8.4]
phpunit: ['10', '11']
stability: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }} - Windows

steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Set PHPUnit
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer require phpunit/phpunit:^${{ matrix.phpunit }} --dev --no-interaction --no-update
shell: bash

- name: Install dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit
28 changes: 28 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Update Changelog"

on:
release:
types: [released]

jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.tag_name }}
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: ${{ github.event.release.target_commitish }}
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea
.phpunit.cache
vendor
.phpunit.result.cache
composer.lock
mt-compose.yml
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Release notes for event-manager
23 changes: 11 additions & 12 deletions Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@
*/
class Event implements EventInterface, StoppableEventInterface
{

/**
* @var string
*/
private $name = '';
private string $name = '';

/**
* @var mixed
*/
private $target;
private mixed $target;

/**
* @var array
*/
private $params = [];
private array $params = [];

/**
* @var bool
*/
private static $propagationStopped = false;
private bool $propagationStopped = false;

/**
* @return string
Expand All @@ -43,7 +42,7 @@ public function getName(): string
/**
* @return mixed
*/
public function getTarget()
public function getTarget(): mixed
{
return $this->target;
}
Expand All @@ -58,9 +57,9 @@ public function getParams(): array

/**
* @param string $name
* @return mixed|null
* @return mixed
*/
public function getParam(string $name)
public function getParam(string $name): mixed
{
return $this->params[$name] ?? null;
}
Expand All @@ -75,10 +74,10 @@ public function setName(string $name): void
}

/**
* @param null|string|object $target
* @param object|string|null $target
* @return void
*/
public function setTarget($target): void
public function setTarget(object|string|null $target): void
{
$this->target = $target;
}
Expand All @@ -98,14 +97,14 @@ public function setParams(array $params): void
*/
public function stopPropagation(bool $flag = true): void
{
self::$propagationStopped = $flag;
$this->propagationStopped = $flag;
}

/**
* @return bool
*/
public function isPropagationStopped(): bool
{
return self::$propagationStopped;
return $this->propagationStopped;
}
}
10 changes: 4 additions & 6 deletions EventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
interface EventInterface
{

/**
* @return string
*/
Expand All @@ -18,7 +17,7 @@ public function getName(): string;
/**
* @return mixed
*/
public function getTarget();
public function getTarget(): mixed;

/**
* @return array
Expand All @@ -29,7 +28,7 @@ public function getParams(): array;
* @param string $name
* @return mixed
*/
public function getParam(string $name);
public function getParam(string $name): mixed;

/**
* @param string $name
Expand All @@ -38,10 +37,10 @@ public function getParam(string $name);
public function setName(string $name): void;

/**
* @param null|string|object $target
* @param object|string|null $target
* @return void
*/
public function setTarget($target): void;
public function setTarget(object|string|null $target): void;

/**
* @param array $params
Expand All @@ -54,5 +53,4 @@ public function setParams(array $params): void;
* @return void
*/
public function stopPropagation(bool $flag): void;

}
Loading

0 comments on commit feea235

Please sign in to comment.