Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -15,8 +15,9 @@ abstract class AbstractLogger implements LoggerInterface
* System is unusable.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function emergency($message, array $context = array())
{
@ -30,8 +31,9 @@ abstract class AbstractLogger implements LoggerInterface
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function alert($message, array $context = array())
{
@ -44,8 +46,9 @@ abstract class AbstractLogger implements LoggerInterface
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function critical($message, array $context = array())
{
@ -57,8 +60,9 @@ abstract class AbstractLogger implements LoggerInterface
* be logged and monitored.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function error($message, array $context = array())
{
@ -72,8 +76,9 @@ abstract class AbstractLogger implements LoggerInterface
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function warning($message, array $context = array())
{
@ -84,8 +89,9 @@ abstract class AbstractLogger implements LoggerInterface
* Normal but significant events.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function notice($message, array $context = array())
{
@ -98,8 +104,9 @@ abstract class AbstractLogger implements LoggerInterface
* Example: User logs in, SQL logs.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function info($message, array $context = array())
{
@ -110,8 +117,9 @@ abstract class AbstractLogger implements LoggerInterface
* Detailed debug information.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function debug($message, array $context = array())
{

View file

@ -3,16 +3,16 @@
namespace Psr\Log;
/**
* Describes log levels
* Describes log levels.
*/
class LogLevel
{
const EMERGENCY = 'emergency';
const ALERT = 'alert';
const CRITICAL = 'critical';
const ERROR = 'error';
const WARNING = 'warning';
const NOTICE = 'notice';
const INFO = 'info';
const DEBUG = 'debug';
const ALERT = 'alert';
const CRITICAL = 'critical';
const ERROR = 'error';
const WARNING = 'warning';
const NOTICE = 'notice';
const INFO = 'info';
const DEBUG = 'debug';
}

View file

@ -3,15 +3,16 @@
namespace Psr\Log;
/**
* Describes a logger-aware instance
* Describes a logger-aware instance.
*/
interface LoggerAwareInterface
{
/**
* Sets a logger instance on the object
* Sets a logger instance on the object.
*
* @param LoggerInterface $logger
* @return null
*
* @return void
*/
public function setLogger(LoggerInterface $logger);
}

View file

@ -7,12 +7,16 @@ namespace Psr\Log;
*/
trait LoggerAwareTrait
{
/** @var LoggerInterface */
/**
* The logger instance.
*
* @var LoggerInterface
*/
protected $logger;
/**
* Sets a logger.
*
*
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger)

View file

@ -3,14 +3,14 @@
namespace Psr\Log;
/**
* Describes a logger instance
* Describes a logger instance.
*
* The message MUST be a string or object implementing __toString().
*
* The message MAY contain placeholders in the form: {foo} where foo
* will be replaced by the context data in key "foo".
*
* The context array can contain arbitrary data, the only assumption that
* The context array can contain arbitrary data. The only assumption that
* can be made by implementors is that if an Exception instance is given
* to produce a stack trace, it MUST be in a key named "exception".
*
@ -23,8 +23,9 @@ interface LoggerInterface
* System is unusable.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function emergency($message, array $context = array());
@ -35,8 +36,9 @@ interface LoggerInterface
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function alert($message, array $context = array());
@ -46,8 +48,9 @@ interface LoggerInterface
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function critical($message, array $context = array());
@ -56,8 +59,9 @@ interface LoggerInterface
* be logged and monitored.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function error($message, array $context = array());
@ -68,8 +72,9 @@ interface LoggerInterface
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function warning($message, array $context = array());
@ -77,8 +82,9 @@ interface LoggerInterface
* Normal but significant events.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function notice($message, array $context = array());
@ -88,8 +94,9 @@ interface LoggerInterface
* Example: User logs in, SQL logs.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function info($message, array $context = array());
@ -97,18 +104,20 @@ interface LoggerInterface
* Detailed debug information.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function debug($message, array $context = array());
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param mixed $level
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function log($level, $message, array $context = array());
}

View file

@ -6,8 +6,8 @@ namespace Psr\Log;
* This is a simple Logger trait that classes unable to extend AbstractLogger
* (because they extend another class, etc) can include.
*
* It simply delegates all log-level-specific methods to the `log` method to
* reduce boilerplate code that a simple Logger that does the same thing with
* It simply delegates all log-level-specific methods to the `log` method to
* reduce boilerplate code that a simple Logger that does the same thing with
* messages regardless of the error level has to implement.
*/
trait LoggerTrait
@ -16,8 +16,9 @@ trait LoggerTrait
* System is unusable.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function emergency($message, array $context = array())
{
@ -31,8 +32,9 @@ trait LoggerTrait
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function alert($message, array $context = array())
{
@ -45,8 +47,9 @@ trait LoggerTrait
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function critical($message, array $context = array())
{
@ -58,8 +61,9 @@ trait LoggerTrait
* be logged and monitored.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function error($message, array $context = array())
{
@ -73,8 +77,9 @@ trait LoggerTrait
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function warning($message, array $context = array())
{
@ -85,8 +90,9 @@ trait LoggerTrait
* Normal but significant events.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function notice($message, array $context = array())
{
@ -99,8 +105,9 @@ trait LoggerTrait
* Example: User logs in, SQL logs.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function info($message, array $context = array())
{
@ -111,8 +118,9 @@ trait LoggerTrait
* Detailed debug information.
*
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function debug($message, array $context = array())
{
@ -122,10 +130,11 @@ trait LoggerTrait
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param mixed $level
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
abstract public function log($level, $message, array $context = array());
}

View file

@ -3,7 +3,7 @@
namespace Psr\Log;
/**
* This Logger can be used to avoid conditional log calls
* This Logger can be used to avoid conditional log calls.
*
* Logging should always be optional, and if no logger is provided to your
* library creating a NullLogger instance to have something to throw logs at
@ -15,10 +15,11 @@ class NullLogger extends AbstractLogger
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param mixed $level
* @param string $message
* @param array $context
* @return null
* @param array $context
*
* @return void
*/
public function log($level, $message, array $context = array())
{

View file

@ -2,28 +2,32 @@
namespace Psr\Log\Test;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
/**
* Provides a base test class for ensuring compliance with the LoggerInterface
* Provides a base test class for ensuring compliance with the LoggerInterface.
*
* Implementors can extend the class and implement abstract methods to run this as part of their test suite
* Implementors can extend the class and implement abstract methods to run this
* as part of their test suite.
*/
abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
{
/**
* @return LoggerInterface
*/
abstract function getLogger();
abstract public function getLogger();
/**
* This must return the log messages in order with a simple formatting: "<LOG LEVEL> <MESSAGE>"
* This must return the log messages in order.
*
* Example ->error('Foo') would yield "error Foo"
* The simple formatting of the messages is: "<LOG LEVEL> <MESSAGE>".
*
* Example ->error('Foo') would yield "error Foo".
*
* @return string[]
*/
abstract function getLogs();
abstract public function getLogs();
public function testImplements()
{
@ -61,7 +65,7 @@ abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException Psr\Log\InvalidArgumentException
* @expectedException \Psr\Log\InvalidArgumentException
*/
public function testThrowsOnInvalidLevel()
{
@ -80,12 +84,19 @@ abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
public function testObjectCastToString()
{
$dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
if (method_exists($this, 'createPartialMock')) {
$dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
} else {
$dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
}
$dummy->expects($this->once())
->method('__toString')
->will($this->returnValue('DUMMY'));
$this->getLogger()->warning($dummy);
$expected = array('warning DUMMY');
$this->assertEquals($expected, $this->getLogs());
}
public function testContextCanContainAnything()
@ -102,15 +113,28 @@ abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
);
$this->getLogger()->warning('Crazy context data', $context);
$expected = array('warning Crazy context data');
$this->assertEquals($expected, $this->getLogs());
}
public function testContextExceptionKeyCanBeExceptionOrOtherValues()
{
$this->getLogger()->warning('Random message', array('exception' => 'oops'));
$this->getLogger()->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
$logger = $this->getLogger();
$logger->warning('Random message', array('exception' => 'oops'));
$logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
$expected = array(
'warning Random message',
'critical Uncaught Exception!'
);
$this->assertEquals($expected, $this->getLogs());
}
}
class DummyTest
{
}
public function __toString()
{
}
}

View file

@ -2,6 +2,7 @@
"name": "psr/log",
"description": "Common interface for logging libraries",
"keywords": ["psr", "psr-3", "log"],
"homepage": "https://github.com/php-fig/log",
"license": "MIT",
"authors": [
{
@ -9,9 +10,17 @@
"homepage": "http://www.php-fig.org/"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-0": {
"Psr\\Log\\": ""
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}