code
stringlengths
15
9.96M
docstring
stringlengths
1
10.1k
func_name
stringlengths
1
124
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
6
186
url
stringlengths
50
236
license
stringclasses
4 values
protected function shrinkingTimeLimit($shrinkingTimeLimit) { $this->shrinkingTimeLimit = $shrinkingTimeLimit; return $this; }
The maximum time to spend trying to shrink the input after a failed test. The default is no limit. @param integer in seconds @return self
shrinkingTimeLimit
php
giorgiosironi/eris
src/TestTrait.php
https://github.com/giorgiosironi/eris/blob/master/src/TestTrait.php
MIT
protected function withRand($randFunction) { if ($randFunction === 'mt_rand') { $this->randRange = new RandomRange(new MtRandSource()); return $this; } if ($randFunction === 'rand') { $this->randRange = new RandomRange(new RandSource()); return $this; } if ($randFunction instanceof RandomRange) { $this->randRange = $randFunction; return $this; } throw new BadMethodCallException("When specifying random generators different from the standard ones, you must pass an instance of Eris\\Random\\RandomRange."); }
@param string|RandomRange $randFunction mt_rand, rand or a RandomRange @return self
withRand
php
giorgiosironi/eris
src/TestTrait.php
https://github.com/giorgiosironi/eris/blob/master/src/TestTrait.php
MIT
public function sample(Generator $generator, $times = 10, $size = null) { return Sample::of($generator, $this->randRange, $size)->repeat($times); }
@return Sample
sample
php
giorgiosironi/eris
src/TestTrait.php
https://github.com/giorgiosironi/eris/blob/master/src/TestTrait.php
MIT
public function sampleShrink(Generator $generator, $fromValue = null, $size = null) { return Sample::of($generator, $this->randRange, $size)->shrink($fromValue); }
@return Sample
sampleShrink
php
giorgiosironi/eris
src/TestTrait.php
https://github.com/giorgiosironi/eris/blob/master/src/TestTrait.php
MIT
function log($file) { return Listeners::log($file); }
@see Listeners::log()
log
php
giorgiosironi/eris
src/Listener/Log.php
https://github.com/giorgiosironi/eris/blob/master/src/Listener/Log.php
MIT
function collectFrequencies(?callable $collectFunction = null) { return Listeners::collectFrequencies($collectFunction); }
@see Listeners::collectFrequencies()
collectFrequencies
php
giorgiosironi/eris
src/Listener/CollectFrequencies.php
https://github.com/giorgiosironi/eris/blob/master/src/Listener/CollectFrequencies.php
MIT
public static function ratio($threshold) { return new self($threshold); }
@param float $threshold from 0.0 to 1.0
ratio
php
giorgiosironi/eris
src/Listener/MinimumEvaluations.php
https://github.com/giorgiosironi/eris/blob/master/src/Listener/MinimumEvaluations.php
MIT
public function __construct($maximumIntervalLength, callable $clock) { $this->maximumIntervalLength = $maximumIntervalLength; $this->clock = $clock; }
@param int $maximumIntervalLength in seconds
__construct
php
giorgiosironi/eris
src/Shrinker/FixedTimeLimit.php
https://github.com/giorgiosironi/eris/blob/master/src/Shrinker/FixedTimeLimit.php
MIT
public function __construct(array $options) { $this->options = $options; }
@param array $options 'timeLimit' => null|integer in seconds. The maximum time that should be allocated to a Shrinker before giving up
__construct
php
giorgiosironi/eris
src/Shrinker/ShrinkerFactory.php
https://github.com/giorgiosironi/eris/blob/master/src/Shrinker/ShrinkerFactory.php
MIT
function constant($value) { return Generators::constant($value); }
@param mixed $value the only value to generate @return ConstantGenerator
constant
php
giorgiosironi/eris
src/Generator/ConstantGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/ConstantGenerator.php
MIT
function filter($filter, Generator $generator, $maximumAttempts = 100) { return Generators::suchThat($filter, $generator, $maximumAttempts); }
@param callable|Constraint $filter @return SuchThatGenerator
filter
php
giorgiosironi/eris
src/Generator/SuchThatGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/SuchThatGenerator.php
MIT
function suchThat($filter, Generator $generator, $maximumAttempts = 100) { return Generators::suchThat($filter, $generator, $maximumAttempts); }
@param callable|Constraint $filter @return SuchThatGenerator
suchThat
php
giorgiosironi/eris
src/Generator/SuchThatGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/SuchThatGenerator.php
MIT
public function __construct($filter, $generator, $maximumAttempts = 100) { $this->filter = $filter; $this->generator = $generator; $this->maximumAttempts = $maximumAttempts; }
@param callable|Constraint $filter
__construct
php
giorgiosironi/eris
src/Generator/SuchThatGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/SuchThatGenerator.php
MIT
private function filterForPredicate(Traversable $options) { $goodOnes = []; foreach ($options as $option) { if ($this->predicate($option)) { $goodOnes[] = $option; } } return $goodOnes; }
@return array of GeneratedValueSingle
filterForPredicate
php
giorgiosironi/eris
src/Generator/SuchThatGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/SuchThatGenerator.php
MIT
function choose($lowerLimit, $upperLimit) { return Generators::choose($lowerLimit, $upperLimit); }
Generates a number in the range from the lower bound to the upper bound, inclusive. The result shrinks towards smaller absolute values. The order of the parameters does not care since they are re-ordered by the generator itself. @param $x int One of the 2 boundaries of the range @param $y int The other boundary of the range @return Generator\ChooseGenerator
choose
php
giorgiosironi/eris
src/Generator/ChooseGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/ChooseGenerator.php
MIT
function set($singleElementGenerator) { return Generators::set($singleElementGenerator); }
@param Generator $singleElementGenerator @return SetGenerator
set
php
giorgiosironi/eris
src/Generator/SetGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/SetGenerator.php
MIT
function regex($expression) { return Generators::regex($expression); }
Note * and + modifiers cause an unbounded number of character to be generated (up to plus infinity) and as such they are not supported. Please use {1,N} and {0,N} instead of + and *. @param string $expression @return Generator\RegexGenerator
regex
php
giorgiosironi/eris
src/Generator/RegexGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/RegexGenerator.php
MIT
function associative(array $generators) { return Generators::associative($generators); }
@return AssociativeArrayGenerator
associative
php
giorgiosironi/eris
src/Generator/AssociativeArrayGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/AssociativeArrayGenerator.php
MIT
function int() { return Generators::int(); }
Generates a positive or negative integer (with absolute value bounded by the generation size).
int
php
giorgiosironi/eris
src/Generator/IntegerGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/IntegerGenerator.php
MIT
function pos() { return Generators::pos(); }
Generates a positive integer (bounded by the generation size).
pos
php
giorgiosironi/eris
src/Generator/IntegerGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/IntegerGenerator.php
MIT
function neg() { return Generators::neg(); }
Generates a negative integer (bounded by the generation size).
neg
php
giorgiosironi/eris
src/Generator/IntegerGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/IntegerGenerator.php
MIT
private function fromOffset($offset) { $chosenTimestamp = $this->lowerLimit->getTimestamp() + $offset; $element = new DateTime(); $element->setTimestamp($chosenTimestamp); return $element; }
@param integer $offset seconds to be added to lower limit @return DateTime
fromOffset
php
giorgiosironi/eris
src/Generator/DateGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/DateGenerator.php
MIT
function tuple() { return call_user_func_array( [Generators::class, 'tuple'], func_get_args() ); }
One Generator for each member of the Tuple: tuple(Generator, Generator, Generator...) Or an array of generators: tuple(array $generators) @return Generator\TupleGenerator
tuple
php
giorgiosironi/eris
src/Generator/TupleGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/TupleGenerator.php
MIT
public static function fromValueAndInput($value, $input, $generatorName = null) { return new self($value, $input, $generatorName); }
A value and the input that was used to derive it. The input usually comes from another Generator. @template T @psalm-param T $value @param mixed $value @param GeneratedValueSingle|mixed $input @param string $generatorName 'tuple' @return GeneratedValueSingle
fromValueAndInput
php
giorgiosironi/eris
src/Generator/GeneratedValueSingle.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueSingle.php
MIT
public static function fromJustValue($value, $generatorName = null) { return new self($value, $value, $generatorName); }
Input will be copied from value. @template T @psalm-param T $value @param mixed $value @param string $generatorName 'tuple' @return GeneratedValueSingle
fromJustValue
php
giorgiosironi/eris
src/Generator/GeneratedValueSingle.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueSingle.php
MIT
public function input() { return $this->input; }
@return GeneratedValueSingle|mixed
input
php
giorgiosironi/eris
src/Generator/GeneratedValueSingle.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueSingle.php
MIT
public function unbox() { return $this->value; }
@psalm-return T @return mixed
unbox
php
giorgiosironi/eris
src/Generator/GeneratedValueSingle.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueSingle.php
MIT
public function generatorName() { return $this->generatorName; }
@return string
generatorName
php
giorgiosironi/eris
src/Generator/GeneratedValueSingle.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueSingle.php
MIT
public function map(callable $applyToValue, $generatorName) { return new self( $applyToValue($this->value), $this, $generatorName ); }
Produces a new GeneratedValueSingle that wraps this one, and that is labelled with $generatorName. $applyToValue is mapped over the value to build the outer GeneratedValueSingle object $this->value field. @return GeneratedValueSingle
map
php
giorgiosironi/eris
src/Generator/GeneratedValueSingle.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueSingle.php
MIT
public function derivedIn($generatorName) { return $this->map( function ($value) { return $value; }, $generatorName ); }
Basically changes the name of the Generator, but without introducing an additional layer of wrapping of GeneratedValueSingle objects. @param string $generatorName 'tuple', 'vector' @return GeneratedValueSingle
derivedIn
php
giorgiosironi/eris
src/Generator/GeneratedValueSingle.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueSingle.php
MIT
public function add(GeneratedValueSingle $value) { return new self(array_merge( $this->generatedValues, [$value] )); }
@return self
add
php
giorgiosironi/eris
src/Generator/GeneratedValueOptions.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueOptions.php
MIT
public function unbox() { return $this->last()->unbox(); }
@override
unbox
php
giorgiosironi/eris
src/Generator/GeneratedValueOptions.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueOptions.php
MIT
public function input() { return $this->last()->input(); }
@override
input
php
giorgiosironi/eris
src/Generator/GeneratedValueOptions.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueOptions.php
MIT
public function generatorName() { return $this->last()->generatorName(); }
@override @return string
generatorName
php
giorgiosironi/eris
src/Generator/GeneratedValueOptions.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/GeneratedValueOptions.php
MIT
function subset($input) { return Generators::subset($input); }
@param array $input @return SubsetGenerator
subset
php
giorgiosironi/eris
src/Generator/SubsetGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/SubsetGenerator.php
MIT
private function shrinkTheElements($sequence) { return $this->vector(count($sequence->unbox()))->shrink($sequence); }
@return GeneratedValueOptions
shrinkTheElements
php
giorgiosironi/eris
src/Generator/SequenceGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/SequenceGenerator.php
MIT
function frequency(/*$frequencyAndGenerator, $frequencyAndGenerator, ...*/) { return call_user_func_array( [Generators::class, 'frequency'], func_get_args() ); }
@return FrequencyGenerator
frequency
php
giorgiosironi/eris
src/Generator/FrequencyGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/FrequencyGenerator.php
MIT
private function pickFrom($generators, RandomRange $rand) { $acc = 0; $frequencies = $this->frequenciesFrom($generators); $random = $rand->rand(1, array_sum($frequencies)); foreach ($generators as $index => $generator) { $acc += $generator['frequency']; if ($random <= $acc) { return [$index, $generator['generator']]; } } throw new \Exception( 'Unable to pick a generator with frequencies: ' . var_export($frequencies, true) ); }
@return array two elements: index and Generator object
pickFrom
php
giorgiosironi/eris
src/Generator/FrequencyGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/FrequencyGenerator.php
MIT
function char(array $characterSets = ['basic-latin'], $encoding = 'utf-8') { return Generators::char($characterSets, $encoding); }
Generates character in the ASCII 0-127 range. @param array $characterSets Only supported charset: "basic-latin" @param string $encoding Only supported encoding: "utf-8" @return Generator\CharacterGenerator
char
php
giorgiosironi/eris
src/Generator/CharacterGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/CharacterGenerator.php
MIT
function charPrintableAscii() { return Generators::charPrintableAscii(); }
Generates character in the ASCII 32-127 range, excluding non-printable ones or modifiers such as CR, LF and Tab. @return Generator\CharacterGenerator
charPrintableAscii
php
giorgiosironi/eris
src/Generator/CharacterGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/CharacterGenerator.php
MIT
function oneOf(/*$a, $b, ...*/) { return call_user_func_array( [Generators::class, 'oneOf'], func_get_args() ); }
@return OneOfGenerator
oneOf
php
giorgiosironi/eris
src/Generator/OneOfGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/OneOfGenerator.php
MIT
public static function defaultDataSet() { return new self( array_map( function ($line) { return trim($line, " \n"); }, file(__DIR__ . "/first_names.txt") ) ); }
@link http://data.bfontaine.net/names/firstnames.txt
defaultDataSet
php
giorgiosironi/eris
src/Generator/NamesGenerator.php
https://github.com/giorgiosironi/eris/blob/master/src/Generator/NamesGenerator.php
MIT
private static function triangleNumber($n) { if ($n === 0) { return 0; } return ($n * ($n + 1)) / 2; }
Growth which approximates (n^2)/2. Returns the number of dots needed to compose a triangle with n dots on a side. E.G.: when n=3 the function evaluates to 6 . . . . . .
triangleNumber
php
giorgiosironi/eris
src/Quantifier/Size.php
https://github.com/giorgiosironi/eris/blob/master/src/Quantifier/Size.php
MIT
public function withMaxSize($maxSize) { $this->maxSize = $maxSize; return $this; }
@param integer $maxSize @return self
withMaxSize
php
giorgiosironi/eris
src/Quantifier/ForAll.php
https://github.com/giorgiosironi/eris/blob/master/src/Quantifier/ForAll.php
MIT
public function hook(Listener $listener) { $this->listeners[] = $listener; return $this; }
@return self
hook
php
giorgiosironi/eris
src/Quantifier/ForAll.php
https://github.com/giorgiosironi/eris/blob/master/src/Quantifier/ForAll.php
MIT
public function stopOn(TerminationCondition $terminationCondition) { $this->terminationConditions[] = $terminationCondition; return $this; }
@return self
stopOn
php
giorgiosironi/eris
src/Quantifier/ForAll.php
https://github.com/giorgiosironi/eris/blob/master/src/Quantifier/ForAll.php
MIT
public function disableShrinking() { $this->shrinkingEnabled = false; return $this; }
@return self
disableShrinking
php
giorgiosironi/eris
src/Quantifier/ForAll.php
https://github.com/giorgiosironi/eris/blob/master/src/Quantifier/ForAll.php
MIT
public function __call($method, $arguments) { if (isset($this->aliases[$method])) { return call_user_func_array( [$this, $this->aliases[$method]], $arguments ); } throw new BadMethodCallException("Method " . __CLASS__ . "::{$method} does not exist"); }
@see $this->aliases @method then($assertion) @method implies($assertion) @method imply($assertion)
__call
php
giorgiosironi/eris
src/Quantifier/ForAll.php
https://github.com/giorgiosironi/eris/blob/master/src/Quantifier/ForAll.php
MIT
function printableCharacter() { return Antecedents::printableCharacter(); }
@see Antecedents::printableCharacter()
printableCharacter
php
giorgiosironi/eris
src/Antecedent/PrintableCharacter.php
https://github.com/giorgiosironi/eris/blob/master/src/Antecedent/PrintableCharacter.php
MIT
function printableCharacters() { return Antecedents::printableCharacters(); }
@see Antecedents::printableCharacters()
printableCharacters
php
giorgiosironi/eris
src/Antecedent/PrintableCharacter.php
https://github.com/giorgiosironi/eris/blob/master/src/Antecedent/PrintableCharacter.php
MIT
public function evaluate(array $values) { foreach ($values as $char) { if (ord($char) < 32) { return false; } if (ord($char) === 127) { return false; } } return true; }
Assumes utf-8.
evaluate
php
giorgiosironi/eris
src/Antecedent/PrintableCharacter.php
https://github.com/giorgiosironi/eris/blob/master/src/Antecedent/PrintableCharacter.php
MIT
public function extractNumber() { return mt_rand(0, $this->max()); }
Returns a random number between 0 and @see max(). @return integer
extractNumber
php
giorgiosironi/eris
src/Random/MtRandSource.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/MtRandSource.php
MIT
public function max() { return mt_getrandmax(); }
@return integer
max
php
giorgiosironi/eris
src/Random/MtRandSource.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/MtRandSource.php
MIT
public function seed($seed) { mt_srand($seed); return $this; }
@param integer $seed @return self
seed
php
giorgiosironi/eris
src/Random/MtRandSource.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/MtRandSource.php
MIT
public function extractNumber() { return rand(0, $this->max()); }
Returns a random number between 0 and @see max(). @return integer
extractNumber
php
giorgiosironi/eris
src/Random/RandSource.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/RandSource.php
MIT
public function max() { return getrandmax(); }
@return integer
max
php
giorgiosironi/eris
src/Random/RandSource.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/RandSource.php
MIT
public function seed($seed) { srand($seed); return $this; }
@param integer $seed @return self
seed
php
giorgiosironi/eris
src/Random/RandSource.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/RandSource.php
MIT
function purePhpMtRand() { return new RandomRange(new MersenneTwister()); }
@return RandomRange
purePhpMtRand
php
giorgiosironi/eris
src/Random/RandomRange.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/RandomRange.php
MIT
public function seed($seed) { $this->source->seed($seed); }
@return void
seed
php
giorgiosironi/eris
src/Random/RandomRange.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/RandomRange.php
MIT
public function rand($lower = null, $upper = null) { if ($lower === null && $upper === null) { return $this->source->extractNumber(); } if ($lower > $upper) { list($lower, $upper) = [$upper, $lower]; } $delta = $upper - $lower; $divisor = ($this->source->max()) / ($delta + 1); do { $retval = (int) floor($this->source->extractNumber() / $divisor); } while ($retval > $delta); return $retval + $lower; }
Return a random number. If $lower and $upper are specified, the number will fall into their inclusive range. Otherwise the number from the source will be directly returned. @param integer|null $lower @param integer|null $upper @return integer
rand
php
giorgiosironi/eris
src/Random/RandomRange.php
https://github.com/giorgiosironi/eris/blob/master/src/Random/RandomRange.php
MIT
public function __construct( int|string|null $Value = null ) { $this->Data = gmp_init( 0 ); if( $Value === null ) { return; } // SetFromString if( preg_match( '/^STEAM_(?P<universe>[0-4]):(?P<authServer>[0-1]):(?P<id>0|[1-9][0-9]{0,9})$/', (string)$Value, $Matches ) === 1 ) { $AccountID = $Matches[ 'id' ]; // Check for max unsigned 32-bit number if( gmp_cmp( $AccountID, '4294967295' ) > 0 ) { throw new InvalidArgumentException( 'Provided SteamID exceeds max unsigned 32-bit integer.' ); } $Universe = (int)$Matches[ 'universe' ]; // Games before orange box used to incorrectly display universe as 0, we support that if( $Universe === self::UniverseInvalid ) { $Universe = self::UniversePublic; } $AuthServer = (int)$Matches[ 'authServer' ]; $AccountID = ( (int)$AccountID << 1 ) | $AuthServer; $this->SetAccountUniverse( $Universe ); $this->SetAccountInstance( self::DesktopInstance ); $this->SetAccountType( self::TypeIndividual ); $this->SetAccountID( $AccountID ); } // SetFromSteam3String else if( preg_match( '/^\\[(?P<type>[AGMPCgcLTIUai]):(?P<universe>[0-4]):(?P<id>0|[1-9][0-9]{0,9})(?:\:(?P<instance>[0-9]+))?\\]$/', (string)$Value, $Matches ) === 1 ) { $AccountID = $Matches[ 'id' ]; // Check for max unsigned 32-bit number if( gmp_cmp( $AccountID, '4294967295' ) > 0 ) { throw new InvalidArgumentException( 'Provided SteamID exceeds max unsigned 32-bit integer.' ); } $Type = $Matches[ 'type' ]; if( $Type === 'i' ) { $Type = 'I'; } if( $Type === 'T' || $Type === 'g' ) { $InstanceID = self::AllInstances; } else if( isset( $Matches[ 'instance' ] ) ) { $InstanceID = (int)$Matches[ 'instance' ]; } else if( $Type === 'U' ) { $InstanceID = self::DesktopInstance; } else { $InstanceID = self::AllInstances; } if( $Type === 'c' ) { $InstanceID = self::InstanceFlagClan; $this->SetAccountType( self::TypeChat ); } else if( $Type === 'L' ) { $InstanceID = self::InstanceFlagLobby; $this->SetAccountType( self::TypeChat ); } else { /** @var int $AccountType */ $AccountType = array_search( $Type, self::$AccountTypeChars, true ); $this->SetAccountType( $AccountType ); } $this->SetAccountUniverse( (int)$Matches[ 'universe' ] ); $this->SetAccountInstance( $InstanceID ); $this->SetAccountID( $AccountID ); } else if( self::IsNumeric( $Value ) ) { $this->Data = gmp_init( $Value, 10 ); } else { throw new InvalidArgumentException( 'Provided SteamID is invalid.' ); } }
Initializes a new instance of the SteamID class. It automatically guesses which type the input is, and works from there.
__construct
php
xPaw/SteamID.php
src/SteamID.php
https://github.com/xPaw/SteamID.php/blob/master/src/SteamID.php
MIT
function deep_clone($value) { static $deepCopy; if (null === $deepCopy) { $deepCopy = (new DeepCopy())->skipUncloneable(true); } return $deepCopy->copy($value); }
Deep clone the given value. @param mixed $value
deep_clone
php
nelmio/alice
src/deep_clone.php
https://github.com/nelmio/alice/blob/master/src/deep_clone.php
MIT
public function __construct(array $parameters = []) { $this->parameters = deep_clone($parameters); }
@param mixed[] $parameters Keys/values pair of parameters
__construct
php
nelmio/alice
src/ParameterBag.php
https://github.com/nelmio/alice/blob/master/src/ParameterBag.php
MIT
public function get(string $key) { if ($this->has($key)) { return deep_clone($this->parameters[$key]); } throw ParameterNotFoundExceptionFactory::create($key); }
@throws ParameterNotFoundException
get
php
nelmio/alice
src/ParameterBag.php
https://github.com/nelmio/alice/blob/master/src/ParameterBag.php
MIT
private function propertyExists($objectOrArray, $propertyPath) { return null !== $this->getPropertyReflectionProperty($objectOrArray, $propertyPath); }
@param object|array $objectOrArray @param string $propertyPath @return bool Whether the property exists or not.
propertyExists
php
nelmio/alice
src/PropertyAccess/ReflectionPropertyAccessor.php
https://github.com/nelmio/alice/blob/master/src/PropertyAccess/ReflectionPropertyAccessor.php
MIT
public function __construct(array $parsers) { $this->parsers = (static fn (ChainableParserInterface ...$parsers) => $parsers)(...$parsers); }
@param ChainableParserInterface[] $parsers
__construct
php
nelmio/alice
src/Parser/ParserRegistry.php
https://github.com/nelmio/alice/blob/master/src/Parser/ParserRegistry.php
MIT
public function getCachedValue(string $key) { if (false === array_key_exists($key, $this->cache)) { throw CachedValueNotFound::create($key); } return $this->cache[$key]; }
@throws CachedValueNotFound
getCachedValue
php
nelmio/alice
src/Generator/GenerationContext.php
https://github.com/nelmio/alice/blob/master/src/Generator/GenerationContext.php
MIT
public function __construct(array $instantiators) { $this->instantiators = ( static fn (ChainableInstantiatorInterface ...$instantiators) => $instantiators )(...$instantiators); }
@param ChainableInstantiatorInterface[] $instantiators
__construct
php
nelmio/alice
src/Generator/Instantiator/InstantiatorRegistry.php
https://github.com/nelmio/alice/blob/master/src/Generator/Instantiator/InstantiatorRegistry.php
MIT
public function __construct(array $resolvers) { foreach ($resolvers as $index => $resolver) { if (false === $resolver instanceof ChainableParameterResolverInterface) { throw TypeErrorFactory::createForInvalidChainableParameterResolver($resolver); } if ($resolver instanceof ParameterResolverAwareInterface) { $resolvers[$index] = $resolver->withResolver($this); } } $this->resolvers = $resolvers; }
@param ChainableParameterResolverInterface[] $resolvers
__construct
php
nelmio/alice
src/Generator/Resolver/Parameter/ParameterResolverRegistry.php
https://github.com/nelmio/alice/blob/master/src/Generator/Resolver/Parameter/ParameterResolverRegistry.php
MIT
public function __construct(array $resolvers, ?ObjectGeneratorInterface $generator = null) { $this->resolvers = ( function (?ObjectGeneratorInterface $generator = null, ChainableValueResolverInterface ...$resolvers) { foreach ($resolvers as $index => $resolver) { if ($resolver instanceof ValueResolverAwareInterface) { $resolvers[$index] = $resolver = $resolver->withValueResolver($this); } if (null !== $generator && $resolver instanceof ObjectGeneratorAwareInterface) { /** @var ObjectGeneratorAwareInterface $resolver */ $resolvers[$index] = $resolver->withObjectGenerator($generator); } } return $resolvers; } )($generator, ...$resolvers); }
@param ChainableValueResolverInterface[] $resolvers
__construct
php
nelmio/alice
src/Generator/Resolver/Value/ValueResolverRegistry.php
https://github.com/nelmio/alice/blob/master/src/Generator/Resolver/Value/ValueResolverRegistry.php
MIT
private function resolveRealValue(ValueInterface $value, int $quantifier) { // TODO: keeping mt_rand for BC purposes. The generator should be made // non-nullable in 4.x and mt_rand usage removed $random = null !== $this->faker ? $this->faker->numberBetween(0, 99) : random_int(0, 99); return ($random < $quantifier) ? $value->getFirstMember() // @phpstan-ignore-line : $value->getSecondMember(); // @phpstan-ignore-line }
@return ValueInterface|mixed
resolveRealValue
php
nelmio/alice
src/Generator/Resolver/Value/Chainable/OptionalValueResolver.php
https://github.com/nelmio/alice/blob/master/src/Generator/Resolver/Value/Chainable/OptionalValueResolver.php
MIT
public function __construct(array $functionBlacklist, ValueResolverInterface $decoratedResolver) { $this->functionBlacklist = array_flip($functionBlacklist); $this->resolver = $decoratedResolver; }
@param string[] $functionBlacklist List of PHP native function that will be skipped, i.e. will be considered as non existent
__construct
php
nelmio/alice
src/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolver.php
https://github.com/nelmio/alice/blob/master/src/Generator/Resolver/Value/Chainable/PhpFunctionCallValueResolver.php
MIT
public function getConstructor() { return $this->constructor; }
@return MethodCallInterface|null
getConstructor
php
nelmio/alice
src/Definition/SpecificationBag.php
https://github.com/nelmio/alice/blob/master/src/Definition/SpecificationBag.php
MIT
public function __construct(string $name, $value) { $this->name = $name; $this->value = $value; }
@param string $name Fixture property name, e.g. 'username' (no flags expected) @param ValueInterface|mixed $value
__construct
php
nelmio/alice
src/Definition/Property.php
https://github.com/nelmio/alice/blob/master/src/Definition/Property.php
MIT
public function getValue() { return $this->value; }
@return ValueInterface|mixed
getValue
php
nelmio/alice
src/Definition/Property.php
https://github.com/nelmio/alice/blob/master/src/Definition/Property.php
MIT
public function __construct(string $key) { $this->key = $key; }
@param string $key String elements from which the flags come from stripped from its flags.
__construct
php
nelmio/alice
src/Definition/FlagBag.php
https://github.com/nelmio/alice/blob/master/src/Definition/FlagBag.php
MIT
public function __construct(string $id, string $className, SpecificationBag $specs, $valueForCurrent = null) { $this->id = $id; $this->className = $className; $this->specs = $specs; $this->valueForCurrent = $valueForCurrent; }
@param string|int|FixtureInterface|null $valueForCurrent
__construct
php
nelmio/alice
src/Definition/Fixture/SimpleFixture.php
https://github.com/nelmio/alice/blob/master/src/Definition/Fixture/SimpleFixture.php
MIT
public function __construct(FixtureReference $extendedFixture) { $this->extendedFixture = $extendedFixture; $this->stringValue = 'extends '.$extendedFixture->getId(); }
@param FixtureReference $extendedFixture Reference of the extended fixture. @example For (extends user0), $extendedFixture is 'user0'
__construct
php
nelmio/alice
src/Definition/Flag/ExtendFlag.php
https://github.com/nelmio/alice/blob/master/src/Definition/Flag/ExtendFlag.php
MIT
public function __construct(int $percentage) { if ($percentage < 0 || $percentage > 100) { throw InvalidArgumentExceptionFactory::createForInvalidOptionalFlagBoundaries($percentage); } $this->percentage = $percentage; }
@param int $percentage Element of ]0;100[.
__construct
php
nelmio/alice
src/Definition/Flag/OptionalFlag.php
https://github.com/nelmio/alice/blob/master/src/Definition/Flag/OptionalFlag.php
MIT
public function __construct(string $name, array $arguments = []) { $this->name = $name; $this->arguments = deep_clone($arguments); }
@param string $name e.g. 'randomElement'
__construct
php
nelmio/alice
src/Definition/Value/FunctionCallValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/FunctionCallValue.php
MIT
public function __construct(string $variable) { $this->variable = $variable; }
@param string $variable e.g. 'username'
__construct
php
nelmio/alice
src/Definition/Value/VariableValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/VariableValue.php
MIT
public function __construct(array $values) { $this->values = deep_clone($values); }
@param ValueInterface[]|array $values
__construct
php
nelmio/alice
src/Definition/Value/ListValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/ListValue.php
MIT
public function __construct(string $id, $value) { $this->id = $id; if ($value instanceof self) { throw InvalidArgumentExceptionFactory::createForRedundantUniqueValue($id); } $this->value = deep_clone($value); }
@param string $id Unique across a fixture set, is used to generate unique values. @param mixed $value
__construct
php
nelmio/alice
src/Definition/Value/UniqueValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/UniqueValue.php
MIT
public function __construct(array $values) { $this->values = deep_clone($values); }
@param ValueInterface[]|array $values
__construct
php
nelmio/alice
src/Definition/Value/ArrayValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/ArrayValue.php
MIT
public function getQuantifier() { return deep_clone($this->quantifier); }
@return int|ValueInterface
getQuantifier
php
nelmio/alice
src/Definition/Value/DynamicArrayValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/DynamicArrayValue.php
MIT
public function getElement() { return deep_clone($this->element); }
@return string|ValueInterface
getElement
php
nelmio/alice
src/Definition/Value/DynamicArrayValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/DynamicArrayValue.php
MIT
public function __construct($parameterKey) { if (false === is_string($parameterKey) && false === $parameterKey instanceof ValueInterface) { throw TypeErrorFactory::createForInvalidParameterKey($parameterKey); } $this->parameterKey = $parameterKey; }
@param string|ValueInterface $parameterKey e.g. 'dummy_param'
__construct
php
nelmio/alice
src/Definition/Value/ParameterValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/ParameterValue.php
MIT
public function __construct(string $name, array $arguments = []) { $this->name = $name; $this->arguments = $arguments; }
@param string $name e.g. 'randomElement'
__construct
php
nelmio/alice
src/Definition/Value/ResolvedFunctionCallValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/ResolvedFunctionCallValue.php
MIT
public function __construct(array $values) { $this->values = $values; }
@param ValueInterface[]|array $values
__construct
php
nelmio/alice
src/Definition/Value/NestedValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/NestedValue.php
MIT
public function getQuantifier() { return is_object($this->quantifier) ? clone $this->quantifier : $this->quantifier; }
@return int|ValueInterface
getQuantifier
php
nelmio/alice
src/Definition/Value/OptionalValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/OptionalValue.php
MIT
public function getFirstMember() { return is_object($this->firstMember) ? clone $this->firstMember : $this->firstMember; }
@return string|ValueInterface
getFirstMember
php
nelmio/alice
src/Definition/Value/OptionalValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/OptionalValue.php
MIT
public function getSecondMember() { return is_object($this->secondMember) ? clone $this->secondMember : $this->secondMember; }
@return ValueInterface|null|string
getSecondMember
php
nelmio/alice
src/Definition/Value/OptionalValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/OptionalValue.php
MIT
public function __construct($reference) { if (false === is_string($reference) && false === $reference instanceof ValueInterface) { if (null === $reference) { $referenceString = 'null'; } elseif (is_array($reference)) { $referenceString = 'array'; } else { $referenceString = is_scalar($reference) ? gettype($reference) : $reference::class; } throw InvalidArgumentExceptionFactory::createForInvalidReferenceType($referenceString); } $this->reference = $reference; }
@param string|ValueInterface $reference e.g. "user0"
__construct
php
nelmio/alice
src/Definition/Value/FixtureReferenceValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/FixtureReferenceValue.php
MIT
public function getValue() { return $this->reference; }
@return string|ValueInterface
getValue
php
nelmio/alice
src/Definition/Value/FixtureReferenceValue.php
https://github.com/nelmio/alice/blob/master/src/Definition/Value/FixtureReferenceValue.php
MIT
public function __construct(string $method, ?array $arguments = null) { $this->method = $method; $this->arguments = $arguments; }
@param ValueInterface[]|array|null $arguments
__construct
php
nelmio/alice
src/Definition/MethodCall/SimpleMethodCall.php
https://github.com/nelmio/alice/blob/master/src/Definition/MethodCall/SimpleMethodCall.php
MIT
public function __construct(ServiceReferenceInterface $caller, string $method, ?array $arguments = null) { $this->caller = clone $caller; $this->method = $method; $this->arguments = $arguments; if ($caller instanceof StaticReference) { $this->stringValue = $caller->getId().'::'.$method; } else { $this->stringValue = $caller->getId().'->'.$method; } }
@param ValueInterface[]|array|null $arguments
__construct
php
nelmio/alice
src/Definition/MethodCall/MethodCallWithReference.php
https://github.com/nelmio/alice/blob/master/src/Definition/MethodCall/MethodCallWithReference.php
MIT
public function __construct(string $className) { $this->id = $className; }
@param string $className FQCN
__construct
php
nelmio/alice
src/Definition/ServiceReference/StaticReference.php
https://github.com/nelmio/alice/blob/master/src/Definition/ServiceReference/StaticReference.php
MIT
public function __construct(string $fixtureId) { $this->id = $fixtureId; }
@param string $fixtureId e.g. 'user0'
__construct
php
nelmio/alice
src/Definition/ServiceReference/FixtureReference.php
https://github.com/nelmio/alice/blob/master/src/Definition/ServiceReference/FixtureReference.php
MIT
public function __construct(array $parsers) { $this->parsers = ( static fn (ChainableTokenParserInterface ...$parsers) => $parsers )(...$parsers); }
@param ChainableTokenParserInterface[] $parsers
__construct
php
nelmio/alice
src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistry.php
https://github.com/nelmio/alice/blob/master/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/TokenParserRegistry.php
MIT
public function parse(Token $token) { if (null === $this->parser) { throw ExpressionLanguageExceptionFactory::createForExpectedMethodCallOnlyIfHasAParser(__METHOD__); } }
@throws ParseThrowable @return ValueInterface|string|array
parse
php
nelmio/alice
src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParser.php
https://github.com/nelmio/alice/blob/master/src/FixtureBuilder/ExpressionLanguage/Parser/TokenParser/Chainable/AbstractChainableParserAwareParser.php
MIT