/** * @covers ::array_append_values * @dataProvider provideArraysToAppend */ public function testCanAppendToArray($target, $extra, $expectedResult) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change $actualResult = array_append_values($target, $extra); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); }
/** * create a new exception about a value generated by / returned to your * function or method * * @param mixed $fieldOrVar * the value that you're throwing an exception about * @param string $fieldOrVarName * the name of the value in your code * @param array $extraData * extra data that you want to include in your exception * @param int|null $typeFlags * do we want any extra type information in the final exception message? * @param array $callStackFilter * are there any namespaces we want to filter out of the call stack? * @return UnsupportedType * an fully-built exception for you to throw */ public static function newFromVar($fieldOrVar, $fieldOrVarName, array $extraData = [], $typeFlags = null, array $callStackFilter = []) { // who called us? $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); // build the basic message and data list($message, $data) = self::buildFormatAndData(BuildThrownBy::class, static::$defaultFormat, $backtrace, $fieldOrVar, $fieldOrVarName, array_merge_keys(static::$defaultExtras, $extraData), $typeFlags, array_append_values(static::$defaultCallStackFilter, $callStackFilter)); // all done return new static($message, $data); }
/** * does a value pass inspection? * * @param mixed $fieldOrVar * the data to be examined * @return bool * TRUE if the inspection passes * FALSE otherwise */ public function inspect($fieldOrVar) { // what are we passing into our underlying check? $args = array_append_values([$fieldOrVar], $this->extra); // ask the check if it has been met return call_user_func_array($this->check, $args); }