Skip to content

Commit

Permalink
push constructor back into trait for now
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrawley committed Sep 26, 2016
1 parent ce26806 commit f0686c7
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 56 deletions.
8 changes: 3 additions & 5 deletions composer.json
Expand Up @@ -18,11 +18,9 @@
"role": "Project Lead"
}
],
"require" : {
"php" : "~5.6 || ~7.0",
"src-run/augustus-polyfill-library" : "~0.6,<0.7",
"src-run/augustus-reflection-library" : "~0.6,<0.7",
"src-run/augustus-utility-library" : "~0.6,<0.7"
"require": {
"php": "~7.0",
"src-run/augustus-utility-library": "~0.6,<0.7"
},
"require-dev": {
"codacy/coverage": "~1.0",
Expand Down
9 changes: 0 additions & 9 deletions lib/BadFunctionCallException.php
Expand Up @@ -17,15 +17,6 @@
class BadFunctionCallException extends \BadFunctionCallException implements ExceptionInterface
{
use ExceptionTrait;

/**
* @param null|string $message
* @param mixed ...$parameters
*/
final public function __construct($message = null, ...$parameters)
{
parent::__construct($this->compileMessage($message, $parameters), 0, $this->filterThrowables($parameters));
}
}

/* EOF */
9 changes: 0 additions & 9 deletions lib/Exception.php
Expand Up @@ -17,15 +17,6 @@
class Exception extends \Exception implements ExceptionInterface
{
use ExceptionTrait;

/**
* @param null|string $message
* @param mixed ...$parameters
*/
final public function __construct($message = null, ...$parameters)
{
parent::__construct($this->compileMessage($message, $parameters), 0, $this->filterThrowables($parameters));
}
}

/* EOF */
1 change: 0 additions & 1 deletion lib/ExceptionInterface.php
Expand Up @@ -4,7 +4,6 @@
* This file is part of the `src-run/augustus-exception-library` project.
*
* (c) Rob Frawley 2nd <rmf@src.run>
* (c) Scribe Inc <scr@src.run>
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
9 changes: 9 additions & 0 deletions lib/ExceptionTrait.php
Expand Up @@ -23,6 +23,15 @@ trait ExceptionTrait
*/
protected $attributes = [];

/**
* @param null|string $message
* @param mixed ...$parameters
*/
public function __construct($message = null, ...$parameters)
{
parent::__construct($this->compileMessage($message, $parameters), 0, $this->filterThrowables($parameters));
}

/**
* @param null|string $message
* @param mixed ...$parameters
Expand Down
9 changes: 0 additions & 9 deletions lib/InvalidArgumentException.php
Expand Up @@ -17,15 +17,6 @@
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
use ExceptionTrait;

/**
* @param null|string $message
* @param mixed ...$parameters
*/
final public function __construct($message = null, ...$parameters)
{
parent::__construct($this->compileMessage($message, $parameters), 0, $this->filterThrowables($parameters));
}
}

/* EOF */
9 changes: 0 additions & 9 deletions lib/LogicException.php
Expand Up @@ -17,15 +17,6 @@
class LogicException extends \LogicException implements ExceptionInterface
{
use ExceptionTrait;

/**
* @param null|string $message
* @param mixed ...$parameters
*/
final public function __construct($message = null, ...$parameters)
{
parent::__construct($this->compileMessage($message, $parameters), 0, $this->filterThrowables($parameters));
}
}

/* EOF */
9 changes: 0 additions & 9 deletions lib/RuntimeException.php
Expand Up @@ -17,15 +17,6 @@
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
use ExceptionTrait;

/**
* @param null|string $message
* @param mixed ...$parameters
*/
final public function __construct($message = null, ...$parameters)
{
parent::__construct($this->compileMessage($message, $parameters), 0, $this->filterThrowables($parameters));
}
}

/* EOF */
10 changes: 5 additions & 5 deletions tests/ExceptionTest.php
Expand Up @@ -32,7 +32,7 @@ private function getException($message = 'A test exception', array $replacements
public function testDefaults()
{
$exception = $this->getException('A %s.', ['message']);
$this->assertEquals('A message.', $exception->getMessage());
$this->assertSame('A message.', $exception->getMessage());

$exception = $this->getException();
$this->assertNotNull($exception->getMessage());
Expand Down Expand Up @@ -69,16 +69,16 @@ public function testTypeQualified()
public function testCompileMessage()
{
$exception = $this->getException('A %s with number: "%d"', ['string', 10]);
$this->assertEquals('A string with number: "10"', $exception->getMessage());
$this->assertSame('A string with number: "10"', $exception->getMessage());

$exception->setMessage('Second string with number: "%d"', 100);
$this->assertEquals('Second string with number: "100"', $exception->getMessage());
$this->assertSame('Second string with number: "100"', $exception->getMessage());

$exception->setMessage('Second string with number "%04d" and undefined string "%s"', 100);
$this->assertEquals('Second string with number "0100" and undefined string "<string:undefined>"', $exception->getMessage());
$this->assertSame('Second string with number "0100" and undefined string "<string:undefined>"', $exception->getMessage());

$exception->setMessage('Second string with undefined number "%04d" and undefined string "%s"');
$this->assertEquals('Second string with undefined number "<integer:undefined>" and undefined string "<string:undefined>"', $exception->getMessage());
$this->assertSame('Second string with undefined number "<integer:undefined>" and undefined string "<string:undefined>"', $exception->getMessage());
}

public function testCreate()
Expand Down

0 comments on commit f0686c7

Please sign in to comment.