-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from kamioftea/final-constructors
[Bugfix] Prevent final methods from being manually extended.
- Loading branch information
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
spec/Prophecy/Exception/Doubler/MethodNotExtendableExceptionSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace spec\Prophecy\Exception\Doubler; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use spec\Prophecy\Exception\Prophecy; | ||
|
||
class MethodNotExtendableExceptionSpec extends ObjectBehavior | ||
{ | ||
function let() | ||
{ | ||
$this->beConstructedWith('', 'User', 'getName'); | ||
} | ||
|
||
function it_is_DoubleException() | ||
{ | ||
$this->shouldHaveType('Prophecy\Exception\Doubler\DoubleException'); | ||
} | ||
|
||
function it_has_MethodName() | ||
{ | ||
$this->getMethodName()->shouldReturn('getName'); | ||
} | ||
|
||
function it_has_classname() | ||
{ | ||
$this->getClassName()->shouldReturn('User'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/Prophecy/Exception/Doubler/MethodNotExtendableException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: jeff | ||
* Date: 25/08/2015 | ||
* Time: 19:14 | ||
*/ | ||
|
||
namespace Prophecy\Exception\Doubler; | ||
|
||
class MethodNotExtendableException extends DoubleException | ||
{ | ||
private $methodName; | ||
|
||
private $className; | ||
|
||
/** | ||
* @param string $message | ||
* @param string $className | ||
* @param string $methodName | ||
*/ | ||
public function __construct($message, $className, $methodName) | ||
{ | ||
parent::__construct($message); | ||
|
||
$this->methodName = $methodName; | ||
$this->className = $className; | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMethodName() | ||
{ | ||
return $this->methodName; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getClassName() | ||
{ | ||
return $this->className; | ||
} | ||
|
||
} |