Aggiornato Composer
This commit is contained in:
@@ -1,29 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Mockery
|
||||
* Mockery (https://docs.mockery.io/)
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://github.com/padraic/mockery/blob/master/LICENSE
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to padraic@php.net so we can send you a copy immediately.
|
||||
*
|
||||
* @category Mockery
|
||||
* @package Mockery
|
||||
* @copyright Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com)
|
||||
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
|
||||
* @copyright https://github.com/mockery/mockery/blob/HEAD/COPYRIGHT.md
|
||||
* @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License
|
||||
* @link https://github.com/mockery/mockery for the canonical source repository
|
||||
*/
|
||||
|
||||
namespace Mockery\Generator;
|
||||
|
||||
use function array_diff;
|
||||
|
||||
class MockConfigurationBuilder
|
||||
{
|
||||
protected $name;
|
||||
protected $blackListedMethods = array(
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $blackListedMethods = [
|
||||
'__call',
|
||||
'__callStatic',
|
||||
'__clone',
|
||||
@@ -36,45 +30,101 @@ class MockConfigurationBuilder
|
||||
'__debugInfo', ## mocking this makes it difficult to debug with xdebug
|
||||
|
||||
// below are reserved words in PHP
|
||||
"__halt_compiler", "abstract", "and", "array", "as",
|
||||
"break", "callable", "case", "catch", "class",
|
||||
"clone", "const", "continue", "declare", "default",
|
||||
"die", "do", "echo", "else", "elseif",
|
||||
"empty", "enddeclare", "endfor", "endforeach", "endif",
|
||||
"endswitch", "endwhile", "eval", "exit", "extends",
|
||||
"final", "for", "foreach", "function", "global",
|
||||
"goto", "if", "implements", "include", "include_once",
|
||||
"instanceof", "insteadof", "interface", "isset", "list",
|
||||
"namespace", "new", "or", "print", "private",
|
||||
"protected", "public", "require", "require_once", "return",
|
||||
"static", "switch", "throw", "trait", "try",
|
||||
"unset", "use", "var", "while", "xor"
|
||||
);
|
||||
|
||||
protected $php7SemiReservedKeywords = [
|
||||
"callable", "class", "trait", "extends", "implements", "static", "abstract", "final",
|
||||
"public", "protected", "private", "const", "enddeclare", "endfor", "endforeach", "endif",
|
||||
"endwhile", "and", "global", "goto", "instanceof", "insteadof", "interface", "namespace", "new",
|
||||
"or", "xor", "try", "use", "var", "exit", "list", "clone", "include", "include_once", "throw",
|
||||
"array", "print", "echo", "require", "require_once", "return", "else", "elseif", "default",
|
||||
"break", "continue", "switch", "yield", "function", "if", "endswitch", "finally", "for", "foreach",
|
||||
"declare", "case", "do", "while", "as", "catch", "die", "self", "parent",
|
||||
'__halt_compiler', 'abstract', 'and', 'array', 'as',
|
||||
'break', 'callable', 'case', 'catch', 'class',
|
||||
'clone', 'const', 'continue', 'declare', 'default',
|
||||
'die', 'do', 'echo', 'else', 'elseif',
|
||||
'empty', 'enddeclare', 'endfor', 'endforeach', 'endif',
|
||||
'endswitch', 'endwhile', 'eval', 'exit', 'extends',
|
||||
'final', 'for', 'foreach', 'function', 'global',
|
||||
'goto', 'if', 'implements', 'include', 'include_once',
|
||||
'instanceof', 'insteadof', 'interface', 'isset', 'list',
|
||||
'namespace', 'new', 'or', 'print', 'private',
|
||||
'protected', 'public', 'require', 'require_once', 'return',
|
||||
'static', 'switch', 'throw', 'trait', 'try',
|
||||
'unset', 'use', 'var', 'while', 'xor',
|
||||
];
|
||||
|
||||
protected $whiteListedMethods = array();
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $constantsMap = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $instanceMock = false;
|
||||
protected $parameterOverrides = array();
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $mockOriginalDestructor = false;
|
||||
protected $targets = array();
|
||||
|
||||
protected $constantsMap = array();
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $parameterOverrides = [];
|
||||
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $php7SemiReservedKeywords = [
|
||||
'callable', 'class', 'trait', 'extends', 'implements', 'static', 'abstract', 'final',
|
||||
'public', 'protected', 'private', 'const', 'enddeclare', 'endfor', 'endforeach', 'endif',
|
||||
'endwhile', 'and', 'global', 'goto', 'instanceof', 'insteadof', 'interface', 'namespace', 'new',
|
||||
'or', 'xor', 'try', 'use', 'var', 'exit', 'list', 'clone', 'include', 'include_once', 'throw',
|
||||
'array', 'print', 'echo', 'require', 'require_once', 'return', 'else', 'elseif', 'default',
|
||||
'break', 'continue', 'switch', 'yield', 'function', 'if', 'endswitch', 'finally', 'for', 'foreach',
|
||||
'declare', 'case', 'do', 'while', 'as', 'catch', 'die', 'self', 'parent',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $targets = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $whiteListedMethods = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->blackListedMethods = array_diff($this->blackListedMethods, $this->php7SemiReservedKeywords);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $blackListedMethod
|
||||
* @return self
|
||||
*/
|
||||
public function addBlackListedMethod($blackListedMethod)
|
||||
{
|
||||
$this->blackListedMethods[] = $blackListedMethod;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $blackListedMethods
|
||||
* @return self
|
||||
*/
|
||||
public function addBlackListedMethods(array $blackListedMethods)
|
||||
{
|
||||
foreach ($blackListedMethods as $method) {
|
||||
$this->addBlackListedMethod($method);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string $target
|
||||
* @return self
|
||||
*/
|
||||
public function addTarget($target)
|
||||
{
|
||||
$this->targets[] = $target;
|
||||
@@ -82,6 +132,10 @@ class MockConfigurationBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<class-string> $targets
|
||||
* @return self
|
||||
*/
|
||||
public function addTargets($targets)
|
||||
{
|
||||
foreach ($targets as $target) {
|
||||
@@ -91,73 +145,30 @@ class MockConfigurationBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addBlackListedMethod($blackListedMethod)
|
||||
{
|
||||
$this->blackListedMethods[] = $blackListedMethod;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addBlackListedMethods(array $blackListedMethods)
|
||||
{
|
||||
foreach ($blackListedMethods as $method) {
|
||||
$this->addBlackListedMethod($method);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setBlackListedMethods(array $blackListedMethods)
|
||||
{
|
||||
$this->blackListedMethods = $blackListedMethods;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public function addWhiteListedMethod($whiteListedMethod)
|
||||
{
|
||||
$this->whiteListedMethods[] = $whiteListedMethod;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public function addWhiteListedMethods(array $whiteListedMethods)
|
||||
{
|
||||
foreach ($whiteListedMethods as $method) {
|
||||
$this->addWhiteListedMethod($method);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setWhiteListedMethods(array $whiteListedMethods)
|
||||
{
|
||||
$this->whiteListedMethods = $whiteListedMethods;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInstanceMock($instanceMock)
|
||||
{
|
||||
$this->instanceMock = (bool) $instanceMock;
|
||||
}
|
||||
|
||||
public function setParameterOverrides(array $overrides)
|
||||
{
|
||||
$this->parameterOverrides = $overrides;
|
||||
}
|
||||
|
||||
public function setMockOriginalDestructor($mockDestructor)
|
||||
{
|
||||
$this->mockOriginalDestructor = $mockDestructor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setConstantsMap(array $map)
|
||||
{
|
||||
$this->constantsMap = $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockConfiguration
|
||||
*/
|
||||
public function getMockConfiguration()
|
||||
{
|
||||
return new MockConfiguration(
|
||||
@@ -171,4 +182,71 @@ class MockConfigurationBuilder
|
||||
$this->constantsMap
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $blackListedMethods
|
||||
* @return self
|
||||
*/
|
||||
public function setBlackListedMethods(array $blackListedMethods)
|
||||
{
|
||||
$this->blackListedMethods = $blackListedMethods;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public function setConstantsMap(array $map)
|
||||
{
|
||||
$this->constantsMap = $map;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $instanceMock
|
||||
*/
|
||||
public function setInstanceMock($instanceMock)
|
||||
{
|
||||
$this->instanceMock = (bool) $instanceMock;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $mockDestructor
|
||||
*/
|
||||
public function setMockOriginalDestructor($mockDestructor)
|
||||
{
|
||||
$this->mockOriginalDestructor = (bool) $mockDestructor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
public function setParameterOverrides(array $overrides)
|
||||
{
|
||||
$this->parameterOverrides = $overrides;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $whiteListedMethods
|
||||
* @return self
|
||||
*/
|
||||
public function setWhiteListedMethods(array $whiteListedMethods)
|
||||
{
|
||||
$this->whiteListedMethods = $whiteListedMethods;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user