generated from Pierre-Lannoy/wp-plugin-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 5
/
functions.php
41 lines (39 loc) · 949 Bytes
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* Global functions.
*
* @package Functions
* @author Pierre Lannoy <https://pierre.lannoy.fr/>.
* @since 2.3.0
*/
if ( ! function_exists('decalog_get_psr_log_version') ) {
/**
* Get the needed version of PSR-3.
*
* @return int The PSR-3 needed version.
* @since 4.0.0
*/
function decalog_get_psr_log_version() {
$required = 1;
if ( ! defined( 'DECALOG_PSR_LOG_VERSION') ) {
define( 'DECALOG_PSR_LOG_VERSION', 'V1' );
}
switch ( strtolower( DECALOG_PSR_LOG_VERSION ) ) {
case 'v3':
$required = 3;
break;
case 'auto':
if ( class_exists( '\Psr\Log\NullLogger') ) {
$reflection = new \ReflectionMethod(\Psr\Log\NullLogger::class, 'log');
foreach ( $reflection->getParameters() as $param ) {
if ( 'message' === $param->getName() ) {
if ( str_contains($param->getType() ?? '', '|') ) {
$required = 3;
}
}
}
}
}
return $required;
}
}