diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 4acfdb1..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-# This is a basic workflow to help you get started with Actions
-
-name: CI
-
-# Controls when the action will run.
-on:
- # Triggers the workflow on push or pull request events but only for the master branch
- push:
- branches:
- - master
- - main
- - FRAMEWORK_6_0
- pull_request:
- branches:
- - master
- - main
- - FRAMEWORK_6_0
-
-
- # Allows you to run this workflow manually from the Actions tab
- workflow_dispatch:
-
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
-jobs:
- run:
- runs-on: ${{ matrix.operating-system }}
- strategy:
- matrix:
- operating-system: ['ubuntu-20.04']
- php-versions: ['7.4', '8.0', 'latest']
- # phpunit-versions: ['latest', '9.5']
- phpunit-versions: ['latest', '9.5']
- steps:
- - name: Setup github ssh key
- run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-versions }}
- extensions: bcmath, ctype, curl, dom, gd, fileinfo, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter
- ini-values: post_max_size=512M, max_execution_time=360
- coverage: xdebug
- tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2, phpstan
- - name: Setup Github Token as composer credential
- run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- - name: Install horde/test dependency and other dependencies
- run: |
- ## For unclear reasons, github action fails randomly if we do not install before we require.
- COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config minimum-stability dev
- COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install
- - name: Setup problem matchers for PHPUnit
- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- - name: run phpunit
- run: phpunit --bootstrap test/bootstrap.php
- - name: run phpstan
- run: phpstan analyze src/ --level 8
diff --git a/.github/workflows/on-pr-merged.yml b/.github/workflows/on-pr-merged.yml
new file mode 100644
index 0000000..36529bb
--- /dev/null
+++ b/.github/workflows/on-pr-merged.yml
@@ -0,0 +1,33 @@
+name: After-Merge Chores
+on:
+ pull_request:
+ types:
+ - closed
+ # branches:
+ # - FRAMEWORK_6_0
+ workflow_dispatch:
+
+jobs:
+ PostMerge:
+ if: github.event.pull_request.merged == true
+ runs-on: ubuntu-24.04
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: 8.3
+ extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter, xdebug
+ ini-values: post_max_size=512M, max_execution_time=360
+ coverage: xdebug
+ tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2
+ - name: Setup Github Token as composer credential
+ run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
+ - name: Install dependencies and local tools
+ run: |
+ COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config minimum-stability dev
+ COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config prefer-stable true
+ COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install --no-interaction --no-progress
+
diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml
new file mode 100644
index 0000000..bf68574
--- /dev/null
+++ b/.github/workflows/on-pr.yml
@@ -0,0 +1,44 @@
+name: Pull Request Chores
+on:
+ pull_request:
+ branches:
+ - FRAMEWORK_6_0
+ workflow_dispatch:
+
+jobs:
+ CI:
+ runs-on: ubuntu-24.04
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: 8.3
+ extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter, xdebug
+ ini-values: post_max_size=512M, max_execution_time=360
+ coverage: xdebug
+ tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2
+ - name: Setup Github Token as composer credential
+ run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
+ - name: Install dependencies and local tools
+ run: |
+ COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config minimum-stability dev
+ COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config prefer-stable true
+ COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install --no-interaction --no-progress
+
+ - name: Run PHPUnit
+ run: vendor/bin/phpunit --testdox
+
+ - name: Run php-cs-fixer
+ run: vendor/bin/php-cs-fixer check -vvv
+
+ - name: Run phpstan (mandatory level)
+ ## Deviation: We analyze the test dir and other non-essentials in the allowed-to-fail test. The unit test dir has some nasty stuff.
+ run: vendor/bin/phpstan --no-progress analyze src/
+
+ - name: Run phpstan (level 9, allowed to fail)
+ run: vendor/bin/phpstan --no-progress --level=9
+ continue-on-error: true
+
diff --git a/.github/workflows/phpdoc.yml b/.github/workflows/phpdoc.yml
deleted file mode 100644
index 365812f..0000000
--- a/.github/workflows/phpdoc.yml
+++ /dev/null
@@ -1,69 +0,0 @@
-# This is a basic workflow to help you get started with Actions
-
-name: PHPDOC
-
-# Controls when the action will run.
-on:
- # Triggers the workflow on push or pull request events but only for the master branch
- push:
- branches:
- - master
- - maintaina-composerfixed
- - FRAMEWORK_6_0
- # Allows you to run this workflow manually from the Actions tab
- workflow_dispatch:
-
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
-jobs:
- run:
- runs-on: ubuntu-20.04
- steps:
- - name: Setup github ssh key
- run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
- - name: Setup uut dir
- run: |
- export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
- export UUT_DIR=$(pwd)
- export WORK_DIR=~
- export BIN_DIR="${WORK_DIR}/bin"
- mkdir -p $BIN_DIR
- git config --global user.name "PHPDOC CI Job"
- git config --global user.email "ci-job@maintaina.com"
- - name: Checkout
- uses: actions/checkout@v2
- - name: Checkout Doc Dir
- uses: actions/checkout@v2
- with:
- repository: maintaina/phpdoc
- token: ${{secrets.PHPDOC_TOKEN}}
- path: "phpdoc-git"
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: 7.4
- extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter
- ini-values: post_max_size=512M, max_execution_time=360
- coverage: xdebug
- tools: composer:v2
- - name: Setup Github Token as composer credential
- run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- - name: phpdocumentor run
- run: |
- export UUT_DIR=$(pwd)
- export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
- export WORK_DIR=/home/runner/
- export BIN_DIR="${WORK_DIR}/bin"
- wget https://phpdoc.org/phpDocumentor.phar
- mkdir "${WORK_DIR}/phpdoc-out"
- mv phpDocumentor.phar $BIN_DIR/phpdocumentor
- chmod +x "${BIN_DIR}/phpdocumentor"
- echo "Creating UUT related dir in docu repo"
- mkdir -p $UUT_DIR/phpdoc-git/${GITHUB_REF##*/}/${REPO}/
- ## Look into any of lib, src, app (if they exist) but not test, migration, bin, locale or script dirs
- $BIN_DIR/phpdocumentor -d $UUT_DIR/lib/ -d $UUT_DIR/src/ -d $UUT_DIR/app/ -t "${UUT_DIR}/phpdoc-git/${GITHUB_REF##*/}/${REPO}/"
- cd ${UUT_DIR}/phpdoc-git
- git add "${GITHUB_REF##*/}/${REPO}"
- php indexer.php ${GITHUB_REF##*/} $REPO
- git add index.html index.json
- git commit -m "Updated phpdoc for $GITHUB_REPOSITORY (${GITHUB_REF##*/} branch) from ci"
- git push
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index 8a724f5..0000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,64 +0,0 @@
----
-name: make release
-
-# manual workflow to make a new release for the default branch
-on:
- workflow_dispatch:
- branches:
- - FRAMEWORK_6_0
-env:
- components: "/home/runner/.composer/web/components/bin/horde-components -c /home/runner/.composer/web/components/config/maintaina.conf.dist"
-
-jobs:
- run:
- runs-on: ${{ matrix.operating-system }}
- strategy:
- matrix:
- operating-system: ['ubuntu-20.04']
- php-versions: ['8.1']
- steps:
- - name: Setup git
- run: |
- mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
- git config --global user.name "Github CI Runner"
- git config --global user.email "ci-job@maintaina.com"
- - name: Checkout
- uses: actions/checkout@v2
- with:
- fetch-depth: 0
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-versions }}
- extensions: gettext
- ini-values: post_max_size=512M, max_execution_time=360
- tools: composer:v2
- - name: Setup composer
- run: |
- composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- composer global config repositories.0 composer https://horde-satis.maintaina.com
- composer global config minimum-stability dev
- composer config --no-plugins --global allow-plugins.horde/horde-installer-plugin true
- composer global require horde/horde-installer-plugin "2.3.0"
- composer global require horde/components "dev-FRAMEWORK_6_0"
- - name: write changelog
- run: |
- entries_amount=0; max_entries=100
- PATTERN="^\[.*\] .*"
-
- for commit in $(git rev-list FRAMEWORK_6_0)
- do
- msg=$(git log --format=%B -n 1 $commit | head -n 1)
- if [ $entries_amount -gt $max_entries ]; then break; fi
- if [[ $msg == 'Released'* ]]; then break; fi
- if [[ $msg == 'Development mode for'* ]]; then break; fi
- if [[ $msg =~ $PATTERN ]]; then
- $components changed "$msg"
- let "entries_amount+=1"
- fi
- done
- - name: make release and push
- run: |
- $components release for maintaina
- git push
- git push origin --tags
diff --git a/.github/workflows/update-composer-json.yml b/.github/workflows/update-composer-json.yml
deleted file mode 100644
index 5b73f05..0000000
--- a/.github/workflows/update-composer-json.yml
+++ /dev/null
@@ -1,47 +0,0 @@
----
-name: update composer.json
-
-# run whenever we push to the default branch and .horde.yml was changed
-on:
- push:
- branches:
- - FRAMEWORK_6_0
- paths:
- - '.horde.yml'
-
-jobs:
- run:
- runs-on: ${{ matrix.operating-system }}
- strategy:
- matrix:
- operating-system: ['ubuntu-20.04']
- php-versions: ['7.4']
- steps:
- - name: Setup git
- run: |
- mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
- git config --global user.name "Github CI Runner"
- git config --global user.email "ci-job@maintaina.com"
- - name: Checkout
- uses: actions/checkout@v2
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-versions }}
- extensions: gettext
- ini-values: post_max_size=512M, max_execution_time=360
- tools: composer:v2
- - name: Setup composer
- run: |
- composer global config github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- composer global config repositories.0 composer https://horde-satis.maintaina.com
- composer global config minimum-stability dev
- composer global require horde/components "dev-FRAMEWORK_6_0"
- alias horde-components="~/.config/composer/web/components/bin/horde-components"
- - name: create new composer.json
- run: horde-components -c doc/components.conf composer
- - name: push new composer.json
- run: |
- git add composer.json
- git commit -m "automatic generation of composer.json - [ci skip]"
- git push
diff --git a/.github/workflows/update-satis.yml b/.github/workflows/update-satis.yml
deleted file mode 100644
index 5049bd0..0000000
--- a/.github/workflows/update-satis.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-# This is a basic workflow to help you get started with Actions
-
-name: Update Satis
-
-# Controls when the action will run.
-on:
- # Triggers the workflow on push or pull request events but only for the master branch
- push:
- branches:
- - FRAMEWORK_6_0
- # Allows you to run this workflow manually from the Actions tab
- workflow_dispatch:
-
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
-jobs:
- run:
- runs-on: ubuntu-20.04
- steps:
- - name: Setup github ssh key
- run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
- - name: Setup uut dir
- run: |
- export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
- export UUT_DIR=$(pwd)
- export WORK_DIR=~
- export BIN_DIR="${WORK_DIR}/bin"
- mkdir -p $BIN_DIR
- git config --global user.name "PHPDOC CI Job"
- git config --global user.email "ci-job@maintaina.com"
- - name: Checkout
- uses: actions/checkout@v2
- - name: Checkout satis web dir
- uses: actions/checkout@v2
- with:
- repository: maintaina-com/maintaina-com.github.io
- token: ${{secrets.PHPDOC_TOKEN}}
- path: "maintaina-com.github.io"
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: 7.4
- extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter
- ini-values: post_max_size=512M, max_execution_time=3600
- coverage: xdebug
- tools: composer:v2
- - name: Setup Github Token as composer credential
- run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- - name: Run Satis
- run: |
- export UUT_DIR=$(pwd)
- export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
- export WORK_DIR=/home/runner/
- export BIN_DIR="${WORK_DIR}/bin"
- composer create-project composer/satis:dev-main
- php satis/bin/satis build -vvv maintaina-com.github.io/satis.json maintaina-com.github.io/ horde/${REPO,,}
- cd maintaina-com.github.io
- git add include/ index.html p2/ packages.json
- git commit -m "Update for horde/${REPO,,}"
- git push
diff --git a/.gitignore b/.gitignore
index 9c23fa4..dec60be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,42 @@ web/
.phpunit.cache
.phpdoc
composer.lock
+.DS_Store
+.buildpath
+.cache
+.project
+.settings
+nbproject/
+*~
+.#*
+*.bak
+*.orig
+*.rej
+*.swp
+*.kdev4
+.kdev4/*
+
+# Ignore ALL config files
+conf.php
+
+# Ignore testing files
+run-tests.log
+/test/*/*/*.diff
+/test/*/*/*.exp
+/test/*/*/*.log
+/test/*/*/*.out
+/test/*/*/*/*.diff
+/test/*/*/*/*.exp
+/test/*/*/*/*.log
+/test/*/*/*/*.out
+
+vendor/
+web/
+var/
+tools/
+.phive/
+.php-cs-fixer.php
+.php-cs-fixer.cache
+.phpunit.cache/
+composer.lock
+.phpunit.result.cache
diff --git a/.horde.yml b/.horde.yml
index a6caf9f..f6ebc73 100644
--- a/.horde.yml
+++ b/.horde.yml
@@ -21,8 +21,8 @@ authors:
role: lead
-
name: Ralf Lang
- user: lang
- email: lang@b1-systems.de
+ user: rlang
+ email: ralf.lang@ralf-lang.de
active: true
role: maintainer
version:
@@ -44,13 +44,15 @@ dependencies:
horde/util: ^3
dev:
composer:
- horde/test: ^3
+ composer:
+ phpunit/phpunit: ^12
+ friendsofphp/php-cs-fixer: ^3
+ phpstan/phpstan: ^2
horde/cli: ^3
horde/scribe: ^3
optional:
composer:
horde/cli: ^3
horde/scribe: ^3
- horde/test: ^3
ext:
dom: '*'
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 0000000..b930fd7
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,22 @@
+in($full);
+ }
+}
+
+$finder->exclude(['fixtures']);
+
+return (new PhpCsFixer\Config())
+ ->setRules([
+ '@PER-CS' => true,
+ '@PHP83Migration' => true,
+ 'php_unit_test_class_requires_covers' => true,
+ 'nullable_type_declaration_for_default_null_value' => true,
+ ])
+ ->setFinder($finder)
+;
diff --git a/composer.json b/composer.json
index 498a421..bd14f5a 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,4 @@
{
- "minimum-stability": "dev",
"name": "horde/log",
"description": "Logging library",
"type": "library",
@@ -18,11 +17,12 @@
},
{
"name": "Ralf Lang",
- "email": "lang@b1-systems.de",
+ "email": "ralf.lang@ralf-lang.de",
"role": "maintainer"
}
],
- "time": "2025-04-30",
+ "time": "2025-05-08",
+ "repositories": [],
"require": {
"php": "^8",
"psr/log": "^1 || ^2 || ^3",
@@ -31,14 +31,15 @@
"horde/util": "^3 || dev-FRAMEWORK_6_0"
},
"require-dev": {
- "horde/test": "^3 || dev-FRAMEWORK_6_0",
+ "phpunit/phpunit": "^12",
+ "friendsofphp/php-cs-fixer": "^3",
+ "phpstan/phpstan": "^2",
"horde/cli": "^3 || dev-FRAMEWORK_6_0",
"horde/scribe": "^3 || dev-FRAMEWORK_6_0"
},
"suggest": {
"horde/cli": "^3 || dev-FRAMEWORK_6_0",
"horde/scribe": "^3 || dev-FRAMEWORK_6_0",
- "horde/test": "^3 || dev-FRAMEWORK_6_0",
"ext-dom": "*"
},
"autoload": {
@@ -55,8 +56,8 @@
}
},
"config": {
- "allow-plugins": {
- "horde/horde-installer-plugin": true
- }
- }
-}
\ No newline at end of file
+ "allow-plugins": {}
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true
+}
diff --git a/lib/Horde/Log.php b/lib/Horde/Log.php
index cab889f..d438387 100644
--- a/lib/Horde/Log.php
+++ b/lib/Horde/Log.php
@@ -1,4 +1,5 @@
* @category Horde
@@ -27,7 +28,7 @@ class Horde_Log_Filter_Constraint implements Horde_Log_Filter
*
* @var array
*/
- protected $_constraints = array();
+ protected $_constraints = [];
/**
* Default constraint coupler.
@@ -45,7 +46,7 @@ class Horde_Log_Filter_Constraint implements Horde_Log_Filter
* multiple constraints.
* Defaults to And.
*/
- public function __construct(Horde_Constraint_Coupler $coupler = null)
+ public function __construct(?Horde_Constraint_Coupler $coupler = null)
{
$this->_coupler = is_null($coupler)
? new Horde_Constraint_And()
@@ -131,7 +132,7 @@ public function addRequiredFields()
public function accept($event)
{
foreach ($this->_constraints as $field => $constraint) {
- $value = isset($event[$field]) ? $event[$field] : null;
+ $value = $event[$field] ?? null;
if (!$constraint->evaluate($value)) {
return Horde_Log_Filter::IGNORE;
}
diff --git a/lib/Horde/Log/Filter/ExactLevel.php b/lib/Horde/Log/Filter/ExactLevel.php
index 62f29a3..7931985 100644
--- a/lib/Horde/Log/Filter/ExactLevel.php
+++ b/lib/Horde/Log/Filter/ExactLevel.php
@@ -1,4 +1,5 @@
_cli->red($flag);
- break;
+ case Horde_Log::EMERG:
+ case Horde_Log::ALERT:
+ case Horde_Log::CRIT:
+ case Horde_Log::ERR:
+ $type_message = $this->_cli->red($flag);
+ break;
- case Horde_Log::WARN:
- case Horde_Log::NOTICE:
- $type_message = $this->_cli->yellow($flag);
- break;
+ case Horde_Log::WARN:
+ case Horde_Log::NOTICE:
+ $type_message = $this->_cli->yellow($flag);
+ break;
- case Horde_Log::INFO:
- case Horde_Log::DEBUG:
- $type_message = $this->_cli->blue($flag);
- break;
+ case Horde_Log::INFO:
+ case Horde_Log::DEBUG:
+ $type_message = $this->_cli->blue($flag);
+ break;
- default:
- $type_message = $flag;
+ default:
+ $type_message = $flag;
}
return $type_message . $event['message'];
diff --git a/lib/Horde/Log/Formatter/Simple.php b/lib/Horde/Log/Formatter/Simple.php
index ce44388..2296b1c 100644
--- a/lib/Horde/Log/Formatter/Simple.php
+++ b/lib/Horde/Log/Formatter/Simple.php
@@ -1,4 +1,5 @@
'log',
'elementTimestamp' => 'timestamp',
'elementMessage' => 'message',
'elementLevel' => 'level',
- 'lineEnding' => PHP_EOL
- );
+ 'lineEnding' => PHP_EOL,
+ ];
/**
* Constructor.
*
* TODO
*/
- public function __construct($options = array())
+ public function __construct($options = [])
{
$this->_options = array_merge($this->_options, $options);
}
diff --git a/lib/Horde/Log/Handler/Base.php b/lib/Horde/Log/Handler/Base.php
index ca47c97..fe7dc26 100644
--- a/lib/Horde/Log/Handler/Base.php
+++ b/lib/Horde/Log/Handler/Base.php
@@ -1,4 +1,5 @@
''
- );
+ protected $_options = [
+ 'ident' => '',
+ ];
/**
* List of filter objects.
*
* @var array
*/
- protected $_filters = array();
+ protected $_filters = [];
/**
* Add a filter specific to this handler.
diff --git a/lib/Horde/Log/Handler/Cli.php b/lib/Horde/Log/Handler/Cli.php
index 6e37512..ff1f2cd 100644
--- a/lib/Horde/Log/Handler/Cli.php
+++ b/lib/Horde/Log/Handler/Cli.php
@@ -1,4 +1,5 @@
false,
- 'ident' => ''
- );
+ 'ident' => '',
+ ];
/**
* Array of buffered output.
*
* @var string
*/
- protected $_buffer = array();
+ protected $_buffer = [];
/**
* Mapping of log priorities to Firebug methods.
*
* @var array
*/
- protected static $_methods = array(
+ protected static $_methods = [
Horde_Log::EMERG => 'error',
Horde_Log::ALERT => 'error',
Horde_Log::CRIT => 'error',
@@ -58,14 +59,14 @@ class Horde_Log_Handler_Firebug extends Horde_Log_Handler_Base
Horde_Log::NOTICE => 'info',
Horde_Log::INFO => 'info',
Horde_Log::DEBUG => 'debug',
- );
+ ];
/**
* Class Constructor
*
* @param Horde_Log_Formatter $formatter Log formatter.
*/
- public function __construct(Horde_Log_Formatter $formatter = null)
+ public function __construct(?Horde_Log_Formatter $formatter = null)
{
$this->_formatter = is_null($formatter)
? new Horde_Log_Formatter_Simple()
@@ -107,7 +108,7 @@ public function flush()
return true;
}
- $output = array();
+ $output = [];
foreach ($this->_buffer as $event) {
$line = trim($this->_formatter->format($event));
@@ -121,9 +122,8 @@ public function flush()
$line = str_replace('"', '\\"', $line);
// Firebug call.
- $method = isset(self::$_methods[$event['level']])
- ? self::$_methods[$event['level']]
- : 'log';
+ $method = self::$_methods[$event['level']]
+ ?? 'log';
$output[] = 'console.' . $method . '("' . $line . '");';
}
@@ -133,7 +133,7 @@ public function flush()
. "}\n"
. "\n";
- $this->_buffer = array();
+ $this->_buffer = [];
}
}
diff --git a/lib/Horde/Log/Handler/Mock.php b/lib/Horde/Log/Handler/Mock.php
index 872fea8..d4f551b 100644
--- a/lib/Horde/Log/Handler/Mock.php
+++ b/lib/Horde/Log/Handler/Mock.php
@@ -1,4 +1,5 @@
false,
'category' => 'default',
- 'ident' => ''
- );
+ 'ident' => '',
+ ];
/**
* Constructor.
@@ -51,9 +52,10 @@ class Horde_Log_Handler_Scribe extends Horde_Log_Handler_Base
* @param Horde_Scribe_Client $scribe Scribe client.
* @param Horde_Log_Formatter $formatter Log formatter.
*/
- public function __construct(Horde_Scribe_Client $scribe,
- ?Horde_Log_Formatter $formatter = null)
- {
+ public function __construct(
+ Horde_Scribe_Client $scribe,
+ ?Horde_Log_Formatter $formatter = null
+ ) {
$this->_formatter = is_null($formatter)
? new Horde_Log_Formatter_Simple()
: $formatter;
@@ -73,9 +75,8 @@ public function write($event)
$event['message'] = $this->_options['ident'] . ' ' . $event['message'];
}
- $category = isset($event['category'])
- ? $event['category']
- : $this->_options['category'];
+ $category = $event['category']
+ ?? $this->_options['category'];
$message = $this->_formatter->format($event);
if (!$this->_options['addNewline']) {
diff --git a/lib/Horde/Log/Handler/Stream.php b/lib/Horde/Log/Handler/Stream.php
index d5b9ddd..02e1836 100644
--- a/lib/Horde/Log/Handler/Stream.php
+++ b/lib/Horde/Log/Handler/Stream.php
@@ -1,4 +1,5 @@
_formatter = is_null($formatter)
? new Horde_Log_Formatter_Simple()
: $formatter;
@@ -96,14 +99,14 @@ public function __wakeup()
{
$streamOrUrl = $this->_streamOrUrl;
try {
- $res = $this->_stream = @fopen($streamOrUrl, $this->_mode, false);
+ $res = $this->_stream = @fopen($streamOrUrl, $this->_mode, false);
} catch (Throwable $e) {
if (is_resource($streamOrUrl)) {
$streamOrUrl = 'resource';
} elseif (is_object($streamOrUrl) && !method_exists($streamOrUrl, '__toString')) {
- $streamOrUrl = get_class($streamOrUrl);
+ $streamOrUrl = get_class($streamOrUrl);
} else {
- $streamOrUrl = (string) $streamOrUrl;
+ $streamOrUrl = (string) $streamOrUrl;
}
throw new Horde_Log_Exception(__CLASS__ . ': "' . $streamOrUrl . '" cannot be opened with mode "' . $this->_mode . '"' . $e->getMessage());
}
@@ -130,7 +133,7 @@ public function write($event)
try {
$res = @fwrite($this->_stream, $line);
} catch (Throwable $e) {
- throw new Horde_Log_Exception(__CLASS__ . ': Unable to write to stream: ' . $this->_mode . '"' . $e->getMessage());
+ throw new Horde_Log_Exception(__CLASS__ . ': Unable to write to stream: ' . $this->_mode . '"' . $e->getMessage());
}
if (!$res) {
throw new Horde_Log_Exception(__CLASS__ . ': Unable to write to stream');
diff --git a/lib/Horde/Log/Handler/Syslog.php b/lib/Horde/Log/Handler/Syslog.php
index 89d7150..7b872b0 100644
--- a/lib/Horde/Log/Handler/Syslog.php
+++ b/lib/Horde/Log/Handler/Syslog.php
@@ -1,4 +1,5 @@
LOG_ERR,
'facility' => LOG_USER,
'ident' => false,
- 'openlogOptions' => false
- );
+ 'openlogOptions' => false,
+ ];
/**
* Last ident set by a syslog-handler instance.
@@ -52,7 +53,7 @@ class Horde_Log_Handler_Syslog extends Horde_Log_Handler_Base
*
* @var array
*/
- protected $_priorities = array(
+ protected $_priorities = [
Horde_Log::EMERG => LOG_EMERG,
Horde_Log::ALERT => LOG_ALERT,
Horde_Log::CRIT => LOG_CRIT,
@@ -61,7 +62,7 @@ class Horde_Log_Handler_Syslog extends Horde_Log_Handler_Base
Horde_Log::NOTICE => LOG_NOTICE,
Horde_Log::INFO => LOG_INFO,
Horde_Log::DEBUG => LOG_DEBUG,
- );
+ ];
/**
* Write a message to the log.
@@ -95,9 +96,8 @@ public function write($event)
*/
protected function _toSyslog($level)
{
- return isset($this->_priorities[$level])
- ? $this->_priorities[$level]
- : $this->_options['defaultPriority'];
+ return $this->_priorities[$level]
+ ?? $this->_options['defaultPriority'];
}
/**
diff --git a/lib/Horde/Log/Logger.php b/lib/Horde/Log/Logger.php
index 2dc0fdb..6ece1f3 100644
--- a/lib/Horde/Log/Logger.php
+++ b/lib/Horde/Log/Logger.php
@@ -1,4 +1,5 @@
_filters,
- $this->_handlers
- ));
+ $this->_handlers,
+ ]);
}
/**
@@ -95,7 +96,7 @@ public function __serialize(): array
return [
self::VERSION,
$this->_filters,
- $this->_handlers
+ $this->_handlers,
];
}
@@ -201,7 +202,7 @@ public function log($event, $level = null)
} else {
// Create an event array from the message and level
// arguments.
- $event = array('message' => $event, 'level' => $level);
+ $event = ['message' => $event, 'level' => $level];
}
if (($level = array_search($event['level'], $this->_levels)) === false) {
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..e3d9c03
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,7 @@
+parameters:
+ level: 5
+ errorFormat: github
+ treatPhpDocTypesAsCertain: false
+ paths:
+ - src
+ - test
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index a81c4fa..fbd5583 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,27 +1,26 @@
+ colors="true">
-
- test
+
+ test/
-
+
- lib
+ src
-
+
diff --git a/src/Filter/ConstraintFilter.php b/src/Filter/ConstraintFilter.php
index 2c09246..e556985 100644
--- a/src/Filter/ConstraintFilter.php
+++ b/src/Filter/ConstraintFilter.php
@@ -1,4 +1,5 @@
* @category Horde
@@ -57,7 +58,7 @@ class ConstraintFilter implements LogFilter
* multiple constraints.
* Defaults to And.
*/
- public function __construct(Horde_Constraint_Coupler $coupler = null)
+ public function __construct(?Horde_Constraint_Coupler $coupler = null)
{
$this->coupler = is_null($coupler)
? new Horde_Constraint_And()
diff --git a/src/Filter/ExactLevelFilter.php b/src/Filter/ExactLevelFilter.php
index 786ab3c..197fc51 100644
--- a/src/Filter/ExactLevelFilter.php
+++ b/src/Filter/ExactLevelFilter.php
@@ -1,4 +1,5 @@
level = $level;
$this->name = $name;
diff --git a/src/Filter/MaximumLevelFilter.php b/src/Filter/MaximumLevelFilter.php
index 32bdc15..09c2beb 100644
--- a/src/Filter/MaximumLevelFilter.php
+++ b/src/Filter/MaximumLevelFilter.php
@@ -1,4 +1,5 @@
level = $level;
}
diff --git a/src/Filter/SuppressFilter.php b/src/Filter/SuppressFilter.php
index d38c3ac..4ff4015 100644
--- a/src/Filter/SuppressFilter.php
+++ b/src/Filter/SuppressFilter.php
@@ -1,4 +1,5 @@
level();
- $flag = '['. str_pad($loglevel->name(), 7, ' ', STR_PAD_BOTH) . '] ';
+ $flag = '[' . str_pad($loglevel->name(), 7, ' ', STR_PAD_BOTH) . '] ';
switch ($loglevel->name()) {
- case 'emergency':
- case 'alert':
- case 'critical':
- case 'crit':
- case 'error':
- case 'err':
- $type_message = $this->cli->color('red', $flag);
- break;
+ case 'emergency':
+ case 'alert':
+ case 'critical':
+ case 'crit':
+ case 'error':
+ case 'err':
+ $type_message = $this->cli->color('red', $flag);
+ break;
- case 'warn':
- case 'warning':
- case 'notice':
- $type_message = $this->cli->color('yellow', $flag);
- break;
+ case 'warn':
+ case 'warning':
+ case 'notice':
+ $type_message = $this->cli->color('yellow', $flag);
+ break;
- case 'info':
- case 'debug':
- $type_message = $this->cli->color('blue', $flag);
- break;
+ case 'info':
+ case 'debug':
+ $type_message = $this->cli->color('blue', $flag);
+ break;
- default:
- $type_message = $flag;
+ default:
+ $type_message = $flag;
}
return $type_message . $event->message();
diff --git a/src/Formatter/Psr3Formatter.php b/src/Formatter/Psr3Formatter.php
index 9949d4c..874ae8c 100644
--- a/src/Formatter/Psr3Formatter.php
+++ b/src/Formatter/Psr3Formatter.php
@@ -1,4 +1,5 @@
options = $options ?? new Options();
$this->cli = $cli ?? new Horde_Cli();
diff --git a/src/Handler/FirebugHandler.php b/src/Handler/FirebugHandler.php
index 0f2ed0f..7355e0e 100644
--- a/src/Handler/FirebugHandler.php
+++ b/src/Handler/FirebugHandler.php
@@ -64,7 +64,7 @@ class FirebugHandler extends BaseHandler
* @param null|FirebugOptions $options Log options.
* @param LogFormatter[] $formatters Log formatter.
*/
- public function __construct(?FirebugOptions $options = null, array $formatters = null)
+ public function __construct(?FirebugOptions $options = null, ?array $formatters = null)
{
$this->options = $options ?? new FirebugOptions();
$this->formatters = is_null($formatters)
diff --git a/src/Handler/LoggerInterfaceHandler.php b/src/Handler/LoggerInterfaceHandler.php
index fb12c8d..b0458e7 100644
--- a/src/Handler/LoggerInterfaceHandler.php
+++ b/src/Handler/LoggerInterfaceHandler.php
@@ -1,4 +1,5 @@
@@ -36,12 +38,10 @@ class MockHandler extends BaseHandler
private Options $options;
- /** Check variables used for testing
- * @var mixed;
- */
- public $check;
+ /** Check variables used for testing */
+ public string|Stringable $check;
- public function __construct(Options $options = null)
+ public function __construct(?Options $options = null)
{
$this->options = $options ?? new Options();
}
diff --git a/src/Handler/NullHandler.php b/src/Handler/NullHandler.php
index 39c04ff..8f58892 100644
--- a/src/Handler/NullHandler.php
+++ b/src/Handler/NullHandler.php
@@ -1,4 +1,5 @@
options = $options ?? new Options();
}
diff --git a/src/Handler/ScribeHandler.php b/src/Handler/ScribeHandler.php
index a41b769..a2dbc52 100644
--- a/src/Handler/ScribeHandler.php
+++ b/src/Handler/ScribeHandler.php
@@ -1,4 +1,5 @@
formatters = is_null($formatters)
? [new SimpleFormatter()]
: $formatters;
diff --git a/src/Handler/StreamHandler.php b/src/Handler/StreamHandler.php
index d35d794..05e72fc 100644
--- a/src/Handler/StreamHandler.php
+++ b/src/Handler/StreamHandler.php
@@ -1,4 +1,5 @@
options = $options ?? new Options();
$this->formatters = $formatters ?? [new SimpleFormatter()];
$this->mode = $mode;
diff --git a/src/Handler/SyslogHandler.php b/src/Handler/SyslogHandler.php
index 9e15c50..a2d51c8 100644
--- a/src/Handler/SyslogHandler.php
+++ b/src/Handler/SyslogHandler.php
@@ -20,6 +20,7 @@
use Horde\Log\LogHandler;
use Horde\Log\LogMessage;
use Horde\Log\LogException;
+use syslog;
/**
* @author Mike Naberezny
@@ -85,9 +86,7 @@ public function write(LogMessage $event): bool
}
$priority = $event->level()->criticality();
- if (!syslog($priority, $event->formattedMessage())) {
- throw new LogException('Unable to log message');
- }
+ syslog($priority, $event->formattedMessage());
return true;
}
@@ -104,12 +103,7 @@ protected function initializeSyslog(): void
if (!is_string($this->lastIdent)) {
throw new LogException('Please set the indent to a String');
}
- if (!is_int($this->options->openLogOptions)) {
- throw new LogException('Please set the openlogOptions to a log constant with integer value (e.g. LOG_PERROR). For more information look at PHP documentation about openlog() and its options parameter');
- }
- if (!openlog($this->options->ident, $this->options->openLogOptions, $this->options->facility)) {
- throw new LogException('Unable to open syslog');
- }
+ openlog($this->options->ident, $this->options->openLogOptions, $this->options->facility);
}
}
diff --git a/src/LogException.php b/src/LogException.php
index 8ac3f2f..ef92be6 100644
--- a/src/LogException.php
+++ b/src/LogException.php
@@ -1,4 +1,5 @@
levels = $levels;
diff --git a/src/LoggerBuilder.php b/src/LoggerBuilder.php
index 1fd4541..2453bbc 100644
--- a/src/LoggerBuilder.php
+++ b/src/LoggerBuilder.php
@@ -1,12 +1,15 @@
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
@@ -17,15 +20,15 @@ class LoggerBuilder
private LogLevels $loglevels;
private Logger $logger;
- public function __construct(LogLevels $loglevels = null)
+ public function __construct(?LogLevels $loglevels = null)
{
$this->reset($loglevels);
}
/**
* Create an all-new logger instance without any handler or filter
- *
+ *
*/
- public function reset(LogLevels $loglevels = null): self
+ public function reset(?LogLevels $loglevels = null): self
{
$this->loglevels = $loglevels ?? LogLevels::initWithCanonicalLevels();
$this->logger = new Logger([], $loglevels);
@@ -62,7 +65,7 @@ public function withLogHandler(LogHandler $handler): self
/**
* Return a logger
- *
+ *
* Resets the builder to default state
*
* @return Logger
@@ -85,4 +88,4 @@ public function withGlobalFilter(LogFilter $filter): self
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/test/AllTests.php b/test/AllTests.php
deleted file mode 100644
index 1f7a9bf..0000000
--- a/test/AllTests.php
+++ /dev/null
@@ -1,5 +0,0 @@
-run();
diff --git a/test/Filter/ChainingTest.php b/test/Filter/ChainingTest.php
index f4c0a0a..0c2da80 100644
--- a/test/Filter/ChainingTest.php
+++ b/test/Filter/ChainingTest.php
@@ -1,4 +1,5 @@
@@ -27,6 +31,7 @@
* @package Log
* @subpackage UnitTests
*/
+#[CoversNothing]
class ChainingTest extends TestCase
{
public function setUp(): void
diff --git a/test/Filter/ConstraintFilterTest.php b/test/Filter/ConstraintFilterTest.php
index b691def..c9581d4 100644
--- a/test/Filter/ConstraintFilterTest.php
+++ b/test/Filter/ConstraintFilterTest.php
@@ -1,4 +1,5 @@
getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
+ $const = $this->getMockBuilder('Horde_Constraint', ['evaluate'])->getMock();
$const->expects($this->once())
->method('evaluate')
- ->will($this->returnValue($returnVal));
+ ->willReturn($returnVal);
return $const;
}
@@ -109,7 +111,7 @@ public function testFilterStopsWhenItFindsAFalseCondition()
$filterator->addConstraint('fieldname', $this->getConstraintMock(true));
$filterator->addConstraint('fieldname', new Horde_Constraint_AlwaysFalse());
- $const = $this->getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
+ $const = $this->getMockBuilder('Horde_Constraint', ['evaluate'])->getMock();
$const->expects($this->never())
->method('evaluate');
$filterator->addConstraint('fieldname', $const);
@@ -119,7 +121,7 @@ public function testFilterStopsWhenItFindsAFalseCondition()
public function testFilterAcceptCallsConstraintOnNullWhenFieldDoesnotExist()
{
$filterator = new ConstraintFilter();
- $const = $this->getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
+ $const = $this->getMockBuilder('Horde_Constraint', ['evaluate'])->getMock();
$const->expects($this->once())
->method('evaluate')
->with(null);
diff --git a/test/Filter/ConstraintTest.php b/test/Filter/ConstraintTest.php
index b0ad248..9ceef80 100644
--- a/test/Filter/ConstraintTest.php
+++ b/test/Filter/ConstraintTest.php
@@ -1,4 +1,5 @@
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
-class ConstraintTest extends Horde_Test_Case
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
+class ConstraintTest extends TestCase
{
public function testFilterDoesNotAcceptWhenRequiredFieldIsMissing()
{
- $event = array(
+ $event = [
'someotherfield' => 'other value',
- );
+ ];
$filterator = new Horde_Log_Filter_Constraint();
$filterator->addRequiredField('required_field');
@@ -35,10 +40,10 @@ public function testFilterDoesNotAcceptWhenRequiredFieldIsMissing()
public function testFilterAcceptsWhenRequiredFieldisPresent()
{
- $event = array(
+ $event = [
'required_field' => 'somevalue',
'someotherfield' => 'other value',
- );
+ ];
$filterator = new Horde_Log_Filter_Constraint();
$filterator->addRequiredField('required_field');
@@ -47,10 +52,10 @@ public function testFilterAcceptsWhenRequiredFieldisPresent()
public function testFilterAcceptsWhenRegexMatchesField()
{
- $event = array(
+ $event = [
'regex_field' => 'somevalue',
'someotherfield' => 'other value',
- );
+ ];
$filterator = new Horde_Log_Filter_Constraint();
$filterator->addRegex('regex_field', '/somevalue/');
@@ -59,10 +64,10 @@ public function testFilterAcceptsWhenRegexMatchesField()
public function testFilterAcceptsWhenRegex_DOESNOT_MatcheField()
{
- $event = array(
+ $event = [
'regex_field' => 'somevalue',
'someotherfield' => 'other value',
- );
+ ];
$filterator = new Horde_Log_Filter_Constraint();
$filterator->addRegex('regex_field', '/someothervalue/');
@@ -71,10 +76,10 @@ public function testFilterAcceptsWhenRegex_DOESNOT_MatcheField()
private function getConstraintMock($returnVal)
{
- $const = $this->getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
+ $const = $this->getMockBuilder('Horde_Constraint', ['evaluate'])->getMock();
$const->expects($this->once())
->method('evaluate')
- ->will($this->returnValue($returnVal));
+ ->willReturn($returnVal);
return $const;
}
@@ -84,7 +89,7 @@ public function testFilterCallsEvalOnAllConstraintsWhenTheyAreAllTrue()
$filterator->addConstraint('fieldname', $this->getConstraintMock(true));
$filterator->addConstraint('fieldname', $this->getConstraintMock(true));
- $filterator->accept(array('fieldname' => 'foo'));
+ $filterator->accept(['fieldname' => 'foo']);
}
public function testFilterStopsWhenItFindsAFalseCondition()
@@ -94,22 +99,22 @@ public function testFilterStopsWhenItFindsAFalseCondition()
$filterator->addConstraint('fieldname', $this->getConstraintMock(true));
$filterator->addConstraint('fieldname', new Horde_Constraint_AlwaysFalse());
- $const = $this->getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
+ $const = $this->getMockBuilder('Horde_Constraint', ['evaluate'])->getMock();
$const->expects($this->never())
->method('evaluate');
$filterator->addConstraint('fieldname', $const);
- $filterator->accept(array('fieldname' => 'foo'));
+ $filterator->accept(['fieldname' => 'foo']);
}
public function testFilterAcceptCallsConstraintOnNullWhenFieldDoesnotExist()
{
$filterator = new Horde_Log_Filter_Constraint();
- $const = $this->getMockBuilder('Horde_Constraint', array('evaluate'))->getMock();
+ $const = $this->getMockBuilder('Horde_Constraint', ['evaluate'])->getMock();
$const->expects($this->once())
->method('evaluate')
->with(null);
$filterator->addConstraint('fieldname', $const);
- $filterator->accept(array('someotherfield' => 'foo'));
+ $filterator->accept(['someotherfield' => 'foo']);
}
}
diff --git a/test/Filter/ExactLevelFilterTest.php b/test/Filter/ExactLevelFilterTest.php
index ba531b5..159d2ba 100644
--- a/test/Filter/ExactLevelFilterTest.php
+++ b/test/Filter/ExactLevelFilterTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -29,7 +30,10 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class ExactLevelFilterTest extends TestCase
{
public function setUp(): void
@@ -63,6 +67,6 @@ public function testLevelFilterReject()
public function testConstructorThrowsOnInvalidLevel()
{
$this->expectException(TypeError::class);
- new ExactLevelFilter('foo','bar');
+ new ExactLevelFilter('foo', 'bar');
}
}
diff --git a/test/Filter/ExactLevelTest.php b/test/Filter/ExactLevelTest.php
index 88d7328..0632156 100644
--- a/test/Filter/ExactLevelTest.php
+++ b/test/Filter/ExactLevelTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -25,7 +27,10 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class ExactLevelTest extends TestCase
{
public function setUp(): void
@@ -36,13 +41,13 @@ public function setUp(): void
public function testLevelFilterAccept()
{
- $this->assertTrue($this->filter->accept(array('message' => '', 'level' => 2)));
+ $this->assertTrue($this->filter->accept(['message' => '', 'level' => 2]));
}
public function testLevelFilterReject()
{
- $this->assertFalse($this->filter->accept(array('message' => '', 'level' => 1)));
- $this->assertFalse($this->filter->accept(array('message' => '', 'level' => 3)));
+ $this->assertFalse($this->filter->accept(['message' => '', 'level' => 1]));
+ $this->assertFalse($this->filter->accept(['message' => '', 'level' => 3]));
}
public function testConstructorThrowsOnInvalidLevel()
diff --git a/test/Filter/LevelTest.php b/test/Filter/LevelTest.php
index 78ddd63..a5c5fbf 100644
--- a/test/Filter/LevelTest.php
+++ b/test/Filter/LevelTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -24,7 +26,10 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class LevelTest extends TestCase
{
public function setUp(): void
@@ -35,13 +40,13 @@ public function setUp(): void
public function testLevelFilterAccept()
{
- $this->assertTrue($this->filter->accept(array('message' => '', 'level' => 2)));
- $this->assertTrue($this->filter->accept(array('message' => '', 'level' => 1)));
+ $this->assertTrue($this->filter->accept(['message' => '', 'level' => 2]));
+ $this->assertTrue($this->filter->accept(['message' => '', 'level' => 1]));
}
public function testLevelFilterReject()
{
- $this->assertFalse($this->filter->accept(array('message' => '', 'level' => 3)));
+ $this->assertFalse($this->filter->accept(['message' => '', 'level' => 3]));
}
public function testConstructorThrowsOnInvalidLevel()
diff --git a/test/Filter/MaximumLevelFilterTest.php b/test/Filter/MaximumLevelFilterTest.php
index 0936351..b11fb9f 100644
--- a/test/Filter/MaximumLevelFilterTest.php
+++ b/test/Filter/MaximumLevelFilterTest.php
@@ -1,4 +1,5 @@
level1 = new LogLevel(1, 'testName1');
@@ -36,7 +35,8 @@ public function setUp(): void
$this->logMessage2 = new LogMessage($this->level2, $this->message2);
}
- public function testMessageFilterRecognizesInvalidRegularExpression(){
+ public function testMessageFilterRecognizesInvalidRegularExpression()
+ {
$this->expectException('InvalidArgumentException');
new MessageFilter('invalid regexp');
}
@@ -48,4 +48,4 @@ public function testMessageFilter()
$this->assertFalse($filter->accept($this->logMessage2));
}
-}
\ No newline at end of file
+}
diff --git a/test/Filter/MessageTest.php b/test/Filter/MessageTest.php
index f07896d..c7aebf7 100644
--- a/test/Filter/MessageTest.php
+++ b/test/Filter/MessageTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -24,10 +26,12 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class MessageTest extends TestCase
{
-
public function testMessageFilterRecognizesInvalidRegularExpression()
{
$this->expectException('InvalidArgumentException');
@@ -37,8 +41,8 @@ public function testMessageFilterRecognizesInvalidRegularExpression()
public function testMessageFilter()
{
$filter = new Horde_Log_Filter_Message('/accept/');
- $this->assertTrue($filter->accept(array('message' => 'foo accept bar', 'level' => 0)));
- $this->assertFalse($filter->accept(array('message' => 'foo reject bar', 'level' => 0)));
+ $this->assertTrue($filter->accept(['message' => 'foo accept bar', 'level' => 0]));
+ $this->assertFalse($filter->accept(['message' => 'foo reject bar', 'level' => 0]));
}
}
diff --git a/test/Filter/MinimumLevelFilterTest.php b/test/Filter/MinimumLevelFilterTest.php
index e4107b3..fb3c999 100644
--- a/test/Filter/MinimumLevelFilterTest.php
+++ b/test/Filter/MinimumLevelFilterTest.php
@@ -1,9 +1,10 @@
assertFalse($this->filter->accept($logMessage1));
$this->assertTrue($this->filter->accept($logMessage2));
}
-
+
public function testLevelFilterReject()
{
$level = new LogLevel(5, 'testName2');
diff --git a/test/Filter/SuppressFilterTest.php b/test/Filter/SuppressFilterTest.php
index d8bb8b1..a548bd6 100644
--- a/test/Filter/SuppressFilterTest.php
+++ b/test/Filter/SuppressFilterTest.php
@@ -1,4 +1,5 @@
logMessage3 = new LogMessage($this->level3, $this->message3);
}
-
+
public function testSuppressIsInitiallyOff()
{
$this->assertTrue($this->filter->accept($this->logMessage1));
@@ -47,7 +48,7 @@ public function testSuppressIsInitiallyOff()
public function testSuppressOn()
{
-
+
$this->filter->suppress(true);
$this->assertFalse($this->filter->accept($this->logMessage1));
$this->assertFalse($this->filter->accept($this->logMessage2));
@@ -69,4 +70,4 @@ public function testSuppressCanBeReset()
$this->filter->suppress(true);
$this->assertFalse($this->filter->accept($this->logMessage3));
}
-}
\ No newline at end of file
+}
diff --git a/test/Filter/SuppressTest.php b/test/Filter/SuppressTest.php
index 6786872..b7637ba 100644
--- a/test/Filter/SuppressTest.php
+++ b/test/Filter/SuppressTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -24,7 +26,10 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class SuppressTest extends TestCase
{
public function setUp(): void
@@ -34,30 +39,30 @@ public function setUp(): void
public function testSuppressIsInitiallyOff()
{
- $this->assertTrue($this->filter->accept(array()));
+ $this->assertTrue($this->filter->accept([]));
}
public function testSuppressOn()
{
$this->filter->suppress(true);
- $this->assertFalse($this->filter->accept(array()));
- $this->assertFalse($this->filter->accept(array()));
+ $this->assertFalse($this->filter->accept([]));
+ $this->assertFalse($this->filter->accept([]));
}
public function testSuppressOff()
{
$this->filter->suppress(false);
- $this->assertTrue($this->filter->accept(array()));
- $this->assertTrue($this->filter->accept(array()));
+ $this->assertTrue($this->filter->accept([]));
+ $this->assertTrue($this->filter->accept([]));
}
public function testSuppressCanBeReset()
{
$this->filter->suppress(true);
- $this->assertFalse($this->filter->accept(array()));
+ $this->assertFalse($this->filter->accept([]));
$this->filter->suppress(false);
- $this->assertTrue($this->filter->accept(array()));
+ $this->assertTrue($this->filter->accept([]));
$this->filter->suppress(true);
- $this->assertFalse($this->filter->accept(array()));
+ $this->assertFalse($this->filter->accept([]));
}
}
diff --git a/test/Formatter/CliFormatterTest.php b/test/Formatter/CliFormatterTest.php
index 2a5ed4b..f0ace65 100644
--- a/test/Formatter/CliFormatterTest.php
+++ b/test/Formatter/CliFormatterTest.php
@@ -16,13 +16,13 @@
namespace Horde\Log\Test\Formatter;
use PHPUnit\Framework\TestCase;
-
use Horde_Cli;
use Horde\Log\Formatter\CliFormatter;
-
use Horde\Log\LogMessage;
use Horde\Log\LogLevel;
+use PHPUnit\Framework\Attributes\CoversNothing;
+#[coversnothing]
class CliFormatterTest extends TestCase
{
public function setUp(): void
diff --git a/test/Formatter/Psr3FormatterTest.php b/test/Formatter/Psr3FormatterTest.php
index f3c749f..7f1e00b 100644
--- a/test/Formatter/Psr3FormatterTest.php
+++ b/test/Formatter/Psr3FormatterTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -28,7 +27,10 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class SimpleTest extends TestCase
{
public function testConstructorThrowsOnBadFormatString()
@@ -40,11 +42,11 @@ public function testConstructorThrowsOnBadFormatString()
public function testDefaultFormat()
{
$f = new Horde_Log_Formatter_Simple();
- $line = $f->format(array(
+ $line = $f->format([
'message' => $message = 'message',
'level' => $level = Horde_Log::ALERT,
- 'levelName' => $levelName = 'ALERT'
- ));
+ 'levelName' => $levelName = 'ALERT',
+ ]);
$this->assertStringContainsString($message, $line);
$this->assertStringContainsString($levelName, $line);
diff --git a/test/Formatter/XmlTest.php b/test/Formatter/XmlTest.php
index 631bcc0..973777a 100644
--- a/test/Formatter/XmlTest.php
+++ b/test/Formatter/XmlTest.php
@@ -18,14 +18,16 @@
use PHPUnit\Framework\TestCase;
use Horde_Log_Formatter_Xml;
-
/**
* @author Mike Naberezny
* @author Chuck Hagenbuch
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class XmlTest extends TestCase
{
public function setUp(): void
@@ -36,16 +38,16 @@ public function setUp(): void
public function testDefaultFormat()
{
$f = new Horde_Log_Formatter_Xml();
- $line = $f->format(array('message' => $message = 'message', 'level' => $level = 1));
+ $line = $f->format(['message' => $message = 'message', 'level' => $level = 1]);
$this->assertStringContainsString($message, $line);
- $this->assertStringContainsString((string)$level, $line);
+ $this->assertStringContainsString((string) $level, $line);
}
public function testXmlDeclarationIsStripped()
{
$f = new Horde_Log_Formatter_Xml();
- $line = $f->format(array('message' => $message = 'message', 'level' => $level = 1));
+ $line = $f->format(['message' => $message = 'message', 'level' => $level = 1]);
$this->assertStringNotContainsString('<\?xml version=', $line);
}
@@ -53,7 +55,7 @@ public function testXmlDeclarationIsStripped()
public function testXmlValidates()
{
$f = new Horde_Log_Formatter_Xml();
- $line = $f->format(array('message' => $message = 'message', 'level' => $level = 1));
+ $line = $f->format(['message' => $message = 'message', 'level' => $level = 1]);
$sxml = @simplexml_load_string($line);
$this->assertInstanceOf('SimpleXMLElement', $sxml, 'Formatted XML is invalid');
diff --git a/test/Handler/BaseHandlerTest.php b/test/Handler/BaseHandlerTest.php
index ce42fb6..0bac01b 100644
--- a/test/Handler/BaseHandlerTest.php
+++ b/test/Handler/BaseHandlerTest.php
@@ -1,4 +1,5 @@
baseHandlerMock = $this->getMockForAbstractClass(BaseHandler::class);
+ $this->baseHandlerMock = $this->createMock(BaseHandler::class);
# Own Mock class for testing the base class
$this->mockhandler = new MockHandler();
@@ -40,9 +60,19 @@ public function setUp(): void
$this->constraintFilter = new ConstraintFilter();
}
+ // This test breaks in phpunit 12 and is not trivial to fix without further work
public function testWriteFunctionIsExecutedByLog(): void
{
- $baseHandlerMock = $this->baseHandlerMock;
+ // Traditionally we used a mock created by getMockForAbstractClass() which is deprecated
+ // We cannot use the BaseHandlerMock here because we really want to test the BaseHandler
+ // We can use the NullHandler as it does not implement/override log()
+ // As opposed to the MockHandler which does override log() :D
+
+ $baseHandlerMock = $this->getMockBuilder(BaseHandlerImplementation::class)
+ ->disableOriginalConstructor()
+ ->onlyMethods(['write'])
+ ->getMock();
+ // We need to set the log level to a higher level than the one we are testing
$baseHandlerMock->expects($this->once())->method('write');
$baseHandlerMock->log($this->logMessage1);
}
@@ -53,9 +83,7 @@ public function testWriteFunctionsReturnsBoolean(): void
$this->assertFalse($this->baseHandlerMock->write($this->logMessage1));
}
- /**
- * @doesNotPerformAssertions
- */
+ #[DoesNotPerformAssertions]
public function testFilterMethodExistsAndDoesNotFail(): void
{
$this->baseHandlerMock->addFilter($this->constraintFilter);
diff --git a/test/Handler/FirebugTest.php b/test/Handler/FirebugTest.php
index 286b56d..573a42e 100644
--- a/test/Handler/FirebugTest.php
+++ b/test/Handler/FirebugTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -26,7 +28,10 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class FirebugTest extends TestCase
{
public function setUp(): void
@@ -46,10 +51,10 @@ public function testWrite()
ob_start();
$handler = new Horde_Log_Handler_Firebug();
- $handler->write(array('message' => $message = 'message-to-log',
- 'level' => $level = Horde_Log::ALERT,
- 'levelName' => $levelName = 'ALERT',
- 'timestamp' => date('c')));
+ $handler->write(['message' => $message = 'message-to-log',
+ 'level' => $level = Horde_Log::ALERT,
+ 'levelName' => $levelName = 'ALERT',
+ 'timestamp' => date('c')]);
$contents = ob_get_clean();
diff --git a/test/Handler/LoggerInterfaceHandlerTest.php b/test/Handler/LoggerInterfaceHandlerTest.php
index cacedeb..3327271 100644
--- a/test/Handler/LoggerInterfaceHandlerTest.php
+++ b/test/Handler/LoggerInterfaceHandlerTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -24,12 +26,15 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class NullTest extends TestCase
{
public function testWrite()
{
$handler = new Horde_Log_Handler_Null();
- $this->assertTrue($handler->write(array('message' => 'foo', 'level' => 42)));
+ $this->assertTrue($handler->write(['message' => 'foo', 'level' => 42]));
}
}
diff --git a/test/Handler/SetOptionTraitTest.php b/test/Handler/SetOptionTraitTest.php
index 891bad4..9c1ec84 100644
--- a/test/Handler/SetOptionTraitTest.php
+++ b/test/Handler/SetOptionTraitTest.php
@@ -1,4 +1,5 @@
setOptionsTrait = $this->getMockForTrait(SetOptionsTrait::class);
+ $this->setOptionsTrait = new SetOptionsTraitImplementation();
}
// Testing if new Options is set (without mockhandler)
diff --git a/test/Handler/StreamHandlerTest.php b/test/Handler/StreamHandlerTest.php
index 5881e6a..e4ea8c2 100644
--- a/test/Handler/StreamHandlerTest.php
+++ b/test/Handler/StreamHandlerTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -25,7 +27,10 @@
* @license http://www.horde.org/licenses/bsd BSD
* @package Log
* @subpackage UnitTests
- */
+*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class StreamTest extends TestCase
{
public function setUp(): void
@@ -83,10 +88,10 @@ public function testWrite()
$stream = fopen('php://memory', 'a');
$handler = new Horde_Log_Handler_Stream($stream);
- $handler->write(array('message' => $message = 'message-to-log',
- 'level' => $level = Horde_Log::ALERT,
- 'levelName' => $levelName = 'ALERT',
- 'timestamp' => date('c')));
+ $handler->write(['message' => $message = 'message-to-log',
+ 'level' => $level = Horde_Log::ALERT,
+ 'levelName' => $levelName = 'ALERT',
+ 'timestamp' => date('c')]);
rewind($stream);
$contents = stream_get_contents($stream);
@@ -103,7 +108,7 @@ public function testWriteThrowsWhenStreamWriteFails()
$stream = fopen('php://memory', 'a');
$handler = new Horde_Log_Handler_Stream($stream);
fclose($stream);
- $handler->write(array('message' => 'foo', 'level' => 1));
+ $handler->write(['message' => 'foo', 'level' => 1]);
}
}
diff --git a/test/Handler/SyslogHandlerTest.php b/test/Handler/SyslogHandlerTest.php
index 0139388..bdd6e55 100644
--- a/test/Handler/SyslogHandlerTest.php
+++ b/test/Handler/SyslogHandlerTest.php
@@ -1,4 +1,5 @@
syshandler->setOption('openlogOptions', 'this should be a log constant or at least an integer');
$this->syshandler->write($this->logMessage1);
}
-
- # I have not found a way to make the function syslog() throw errors (it is located within the if-satement of the write()-method...). That would be needed to test the errormessages
- public function testSysLogErrorThrows()
- {
- $this->markTestSkipped('should be revisited?');
- }
}
diff --git a/test/LogLevelsTest.php b/test/LogLevelsTest.php
index fbd5a09..1eeac5f 100644
--- a/test/LogLevelsTest.php
+++ b/test/LogLevelsTest.php
@@ -1,4 +1,5 @@
'warning',
5 => 'notice',
6 => 'info',
- 7 => 'debug'
+ 7 => 'debug',
];
$levelNamesAliases = [
@@ -88,7 +91,7 @@ public function testBothInitMethods()
3 => 'err',
4 => 'warn',
5 => 'information',
- 6 => 'informational'
+ 6 => 'informational',
];
// testing cannonical names and levels
@@ -115,7 +118,7 @@ public function testBothInitMethods()
} else {
$this->assertStringContainsString($bynameAlias->name(), $bycriticalityAlias->name());
}
- $count ++;
+ $count++;
}
// checking that all the aliases are passed through the function
diff --git a/test/LogTest.php b/test/LogTest.php
index 309a8f8..076c9e6 100644
--- a/test/LogTest.php
+++ b/test/LogTest.php
@@ -1,4 +1,5 @@
* @author Chuck Hagenbuch
@@ -27,6 +29,9 @@
* @package Log
* @subpackage UnitTests
*/
+use PHPUnit\Framework\Attributes\CoversNothing;
+
+#[coversnothing]
class LogTest extends TestCase
{
public function setUp(): void
diff --git a/test/LoggerTest.php b/test/LoggerTest.php
index 7e14bff..33c104a 100644
--- a/test/LoggerTest.php
+++ b/test/LoggerTest.php
@@ -1,4 +1,5 @@