mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-23 11:29:10 -04:00
ALPHA 3.0.2a
This commit is contained in:
21
vendor/phpspec/prophecy/CHANGES.md
vendored
21
vendor/phpspec/prophecy/CHANGES.md
vendored
@@ -1,8 +1,27 @@
|
||||
1.7.5 / 2018/04/18
|
||||
1.8.0 / 2018/08/05
|
||||
==================
|
||||
|
||||
* Support for void return types without explicit will (@crellbar)
|
||||
* Clearer error message for unexpected method calls (@meridius)
|
||||
* Clearer error message for aggregate exceptions (@meridius)
|
||||
* More verbose `shouldBeCalledOnce` expectation (@olvlvl)
|
||||
* Ability to double Throwable, or methods that extend it (@ciaranmcnulty)
|
||||
* [fixed] Doubling methods where class has additional arguments to interface (@webimpress)
|
||||
* [fixed] Doubling methods where arguments are nullable but default is not null (@webimpress)
|
||||
* [fixed] Doubling magic methods on parent class (@dsnopek)
|
||||
* [fixed] Check method predictions only once (@dontub)
|
||||
* [fixed] Argument::containingString throwing error when called with non-string (@dcabrejas)
|
||||
|
||||
1.7.6 / 2018/04/18
|
||||
==================
|
||||
|
||||
* Allow sebastian/comparator ^3.0 (@sebastianbergmann)
|
||||
|
||||
1.7.5 / 2018/02/11
|
||||
==================
|
||||
|
||||
* Support for object return type hints (thanks @greg0ire)
|
||||
|
||||
1.7.4 / 2018/02/11
|
||||
==================
|
||||
|
||||
|
||||
4
vendor/phpspec/prophecy/composer.json
vendored
4
vendor/phpspec/prophecy/composer.json
vendored
@@ -27,7 +27,7 @@
|
||||
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^2.5|^3.2",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1"
|
||||
},
|
||||
|
||||
"autoload": {
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.7.x-dev"
|
||||
"dev-master": "1.8.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class StringContainsToken implements TokenInterface
|
||||
|
||||
public function scoreArgument($argument)
|
||||
{
|
||||
return strpos($argument, $this->value) !== false ? 6 : false;
|
||||
return is_string($argument) && strpos($argument, $this->value) !== false ? 6 : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace Prophecy\Call;
|
||||
|
||||
use Exception;
|
||||
use Prophecy\Argument\ArgumentsWildcard;
|
||||
|
||||
/**
|
||||
* Call object.
|
||||
@@ -26,6 +27,7 @@ class Call
|
||||
private $exception;
|
||||
private $file;
|
||||
private $line;
|
||||
private $scores;
|
||||
|
||||
/**
|
||||
* Initializes call.
|
||||
@@ -44,6 +46,7 @@ class Call
|
||||
$this->arguments = $arguments;
|
||||
$this->returnValue = $returnValue;
|
||||
$this->exception = $exception;
|
||||
$this->scores = new \SplObjectStorage();
|
||||
|
||||
if ($file) {
|
||||
$this->file = $file;
|
||||
@@ -124,4 +127,36 @@ class Call
|
||||
|
||||
return sprintf('%s:%d', $this->file, $this->line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the wildcard match score for the provided wildcard.
|
||||
*
|
||||
* @param ArgumentsWildcard $wildcard
|
||||
* @param false|int $score
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addScore(ArgumentsWildcard $wildcard, $score)
|
||||
{
|
||||
$this->scores[$wildcard] = $score;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns wildcard match score for the provided wildcard. The score is
|
||||
* calculated if not already done.
|
||||
*
|
||||
* @param ArgumentsWildcard $wildcard
|
||||
*
|
||||
* @return false|int False OR integer score (higher - better)
|
||||
*/
|
||||
public function getScore(ArgumentsWildcard $wildcard)
|
||||
{
|
||||
if (isset($this->scores[$wildcard])) {
|
||||
return $this->scores[$wildcard];
|
||||
}
|
||||
|
||||
return $this->scores[$wildcard] = $wildcard->scoreArguments($this->getArguments());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ class CallCenter
|
||||
// Sort matches by their score value
|
||||
@usort($matches, function ($match1, $match2) { return $match2[0] - $match1[0]; });
|
||||
|
||||
$score = $matches[0][0];
|
||||
// If Highest rated method prophecy has a promise - execute it or return null instead
|
||||
$methodProphecy = $matches[0][1];
|
||||
$returnValue = null;
|
||||
@@ -115,9 +116,10 @@ class CallCenter
|
||||
);
|
||||
}
|
||||
|
||||
$this->recordedCalls[] = new Call(
|
||||
$this->recordedCalls[] = $call = new Call(
|
||||
$methodName, $arguments, $returnValue, $exception, $file, $line
|
||||
);
|
||||
$call->addScore($methodProphecy->getArgumentsWildcard(), $score);
|
||||
|
||||
if (null !== $exception) {
|
||||
throw $exception;
|
||||
@@ -139,7 +141,7 @@ class CallCenter
|
||||
return array_values(
|
||||
array_filter($this->recordedCalls, function (Call $call) use ($methodName, $wildcard) {
|
||||
return $methodName === $call->getMethodName()
|
||||
&& 0 < $wildcard->scoreArguments($call->getArguments())
|
||||
&& 0 < $call->getScore($wildcard)
|
||||
;
|
||||
})
|
||||
);
|
||||
@@ -149,23 +151,79 @@ class CallCenter
|
||||
array $arguments)
|
||||
{
|
||||
$classname = get_class($prophecy->reveal());
|
||||
$argstring = implode(', ', array_map(array($this->util, 'stringify'), $arguments));
|
||||
$expected = implode("\n", array_map(function (MethodProphecy $methodProphecy) {
|
||||
return sprintf(' - %s(%s)',
|
||||
$indentationLength = 8; // looks good
|
||||
$argstring = implode(
|
||||
",\n",
|
||||
$this->indentArguments(
|
||||
array_map(array($this->util, 'stringify'), $arguments),
|
||||
$indentationLength
|
||||
)
|
||||
);
|
||||
|
||||
$expected = array();
|
||||
|
||||
foreach (call_user_func_array('array_merge', $prophecy->getMethodProphecies()) as $methodProphecy) {
|
||||
$expected[] = sprintf(
|
||||
" - %s(\n" .
|
||||
"%s\n" .
|
||||
" )",
|
||||
$methodProphecy->getMethodName(),
|
||||
$methodProphecy->getArgumentsWildcard()
|
||||
implode(
|
||||
",\n",
|
||||
$this->indentArguments(
|
||||
array_map('strval', $methodProphecy->getArgumentsWildcard()->getTokens()),
|
||||
$indentationLength
|
||||
)
|
||||
)
|
||||
);
|
||||
}, call_user_func_array('array_merge', $prophecy->getMethodProphecies())));
|
||||
}
|
||||
|
||||
return new UnexpectedCallException(
|
||||
sprintf(
|
||||
"Method call:\n".
|
||||
" - %s(%s)\n".
|
||||
"on %s was not expected, expected calls were:\n%s",
|
||||
"Unexpected method call on %s:\n".
|
||||
" - %s(\n".
|
||||
"%s\n".
|
||||
" )\n".
|
||||
"expected calls were:\n".
|
||||
"%s",
|
||||
|
||||
$methodName, $argstring, $classname, $expected
|
||||
$classname, $methodName, $argstring, implode("\n", $expected)
|
||||
),
|
||||
$prophecy, $methodName, $arguments
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
private function formatExceptionMessage(MethodProphecy $methodProphecy)
|
||||
{
|
||||
return sprintf(
|
||||
" - %s(\n".
|
||||
"%s\n".
|
||||
" )",
|
||||
$methodProphecy->getMethodName(),
|
||||
implode(
|
||||
",\n",
|
||||
$this->indentArguments(
|
||||
array_map(
|
||||
function ($token) {
|
||||
return (string) $token;
|
||||
},
|
||||
$methodProphecy->getArgumentsWildcard()->getTokens()
|
||||
),
|
||||
$indentationLength
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function indentArguments(array $arguments, $indentationLength)
|
||||
{
|
||||
return preg_replace_callback(
|
||||
'/^/m',
|
||||
function () use ($indentationLength) {
|
||||
return str_repeat(' ', $indentationLength);
|
||||
},
|
||||
$arguments
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,20 +58,25 @@ class MagicCallPatch implements ClassPatchInterface
|
||||
|
||||
foreach ($types as $type) {
|
||||
$reflectionClass = new \ReflectionClass($type);
|
||||
$tagList = $this->tagRetriever->getTagList($reflectionClass);
|
||||
|
||||
foreach($tagList as $tag) {
|
||||
$methodName = $tag->getMethodName();
|
||||
while ($reflectionClass) {
|
||||
$tagList = $this->tagRetriever->getTagList($reflectionClass);
|
||||
|
||||
if (empty($methodName)) {
|
||||
continue;
|
||||
foreach ($tagList as $tag) {
|
||||
$methodName = $tag->getMethodName();
|
||||
|
||||
if (empty($methodName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$reflectionClass->hasMethod($methodName)) {
|
||||
$methodNode = new MethodNode($methodName);
|
||||
$methodNode->setStatic($tag->isStatic());
|
||||
$node->addMethod($methodNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$reflectionClass->hasMethod($methodName)) {
|
||||
$methodNode = new MethodNode($methodName);
|
||||
$methodNode->setStatic($tag->isStatic());
|
||||
$node->addMethod($methodNode);
|
||||
}
|
||||
$reflectionClass = $reflectionClass->getParentClass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class ProphecySubjectPatch implements ClassPatchInterface
|
||||
$__call->addArgument(new ArgumentNode('name'));
|
||||
$__call->addArgument(new ArgumentNode('arguments'));
|
||||
|
||||
$node->addMethod($__call);
|
||||
$node->addMethod($__call, true);
|
||||
}
|
||||
|
||||
$__call->setCode(<<<PHP
|
||||
@@ -88,8 +88,8 @@ throw new \Prophecy\Exception\Doubler\MethodNotFoundException(
|
||||
PHP
|
||||
);
|
||||
|
||||
$node->addMethod($prophecySetter);
|
||||
$node->addMethod($prophecyGetter);
|
||||
$node->addMethod($prophecySetter, true);
|
||||
$node->addMethod($prophecyGetter, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -189,6 +189,8 @@ class ClassMirror
|
||||
$node->setAsPassedByReference();
|
||||
}
|
||||
|
||||
$node->setAsNullable($this->isNullable($parameter));
|
||||
|
||||
$methodNode->addArgument($node);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class ClassNode
|
||||
return $this->methods;
|
||||
}
|
||||
|
||||
public function addMethod(MethodNode $method)
|
||||
public function addMethod(MethodNode $method, $force = false)
|
||||
{
|
||||
if (!$this->isExtendable($method->getName())){
|
||||
$message = sprintf(
|
||||
@@ -108,7 +108,10 @@ class ClassNode
|
||||
);
|
||||
throw new MethodNotExtendableException($message, $this->getParentClass(), $method->getName());
|
||||
}
|
||||
$this->methods[$method->getName()] = $method;
|
||||
|
||||
if ($force || !isset($this->methods[$method->getName()])) {
|
||||
$this->methods[$method->getName()] = $method;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeMethod($name)
|
||||
|
||||
@@ -21,7 +21,8 @@ class AggregateException extends \RuntimeException implements PredictionExceptio
|
||||
public function append(PredictionException $exception)
|
||||
{
|
||||
$message = $exception->getMessage();
|
||||
$message = ' '.strtr($message, array("\n" => "\n "))."\n";
|
||||
$message = strtr($message, array("\n" => "\n "))."\n";
|
||||
$message = empty($this->exceptions) ? $message : "\n" . $message;
|
||||
|
||||
$this->message = rtrim($this->message.$message);
|
||||
$this->exceptions[] = $exception;
|
||||
|
||||
@@ -75,11 +75,11 @@ class MethodProphecy
|
||||
|
||||
if ('void' === $type) {
|
||||
$this->voidReturnType = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->will(function () use ($type) {
|
||||
switch ($type) {
|
||||
case 'void': return;
|
||||
case 'string': return '';
|
||||
case 'float': return 0.0;
|
||||
case 'int': return 0;
|
||||
@@ -278,6 +278,18 @@ class MethodProphecy
|
||||
return $this->should(new Prediction\CallTimesPrediction($count));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets call times prediction to the prophecy.
|
||||
*
|
||||
* @see \Prophecy\Prediction\CallTimesPrediction
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function shouldBeCalledOnce()
|
||||
{
|
||||
return $this->shouldBeCalledTimes(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks provided prediction immediately.
|
||||
*
|
||||
@@ -372,6 +384,18 @@ class MethodProphecy
|
||||
return $this->shouldHave(new Prediction\CallTimesPrediction($count));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks call times prediction.
|
||||
*
|
||||
* @see \Prophecy\Prediction\CallTimesPrediction
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function shouldHaveBeenCalledOnce()
|
||||
{
|
||||
return $this->shouldHaveBeenCalledTimes(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks currently registered [with should(...)] prediction.
|
||||
*/
|
||||
|
||||
@@ -52,6 +52,7 @@ class Prophet
|
||||
$doubler = new Doubler;
|
||||
$doubler->registerClassPatch(new ClassPatch\SplFileInfoPatch);
|
||||
$doubler->registerClassPatch(new ClassPatch\TraversablePatch);
|
||||
$doubler->registerClassPatch(new ClassPatch\ThrowablePatch);
|
||||
$doubler->registerClassPatch(new ClassPatch\DisableConstructorPatch);
|
||||
$doubler->registerClassPatch(new ClassPatch\ProphecySubjectPatch);
|
||||
$doubler->registerClassPatch(new ClassPatch\ReflectionClassNewInstancePatch);
|
||||
|
||||
@@ -20,6 +20,16 @@ use Prophecy\Call\Call;
|
||||
*/
|
||||
class StringUtil
|
||||
{
|
||||
private $verbose;
|
||||
|
||||
/**
|
||||
* @param bool $verbose
|
||||
*/
|
||||
public function __construct($verbose = true)
|
||||
{
|
||||
$this->verbose = $verbose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stringifies any provided value.
|
||||
*
|
||||
@@ -54,7 +64,7 @@ class StringUtil
|
||||
if (is_string($value)) {
|
||||
$str = sprintf('"%s"', str_replace("\n", '\\n', $value));
|
||||
|
||||
if (50 <= strlen($str)) {
|
||||
if (!$this->verbose && 50 <= strlen($str)) {
|
||||
return substr($str, 0, 50).'"...';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user