array_shift example


          elseif (isset($info['table'])) {
            $join_table = $info['table'] . '.';
          }

          $placeholder = ':views_join_condition_' . $select_query->nextPlaceholder();

          if (is_array($info['value'])) {
            $operator = !empty($info['operator']) ? $info['operator'] : 'IN';
            // Transform from IN() notation to = notation if just one value.             if (count($info['value']) == 1) {
              $info['value'] = array_shift($info['value']);
              $operator = $operator == 'NOT IN' ? '!=' : '=';
            }
          }
          else {
            $operator = !empty($info['operator']) ? $info['operator'] : '=';
          }

          $extras[] = "$join_table$info[field] $operator $placeholder";
          $arguments[$placeholder] = $info['value'];
        }

        
->method('removeAxis')
            ->with('fourth');

        $structure->expects($this->exactly(2))
            ->method('addAxis')
            ->willReturnCallback(function Dstring $axis) {
                static $series = [
                    'first',
                    'third',
                ];

                $this->assertSame(array_shift($series)$axis);
            })
        ;

        $this->propertyAccessor->setValue($car, 'structure.axes', $axesAfter);
    }

    public function testSetValueFailsIfNoAdderNorRemoverFound()
    {
        $this->expectException(NoSuchPropertyException::class);
        $this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTestCase_CarNoAdderAndRemover_[^"]*"./');
        $car = $this->createMock(__CLASS__.'_CarNoAdderAndRemover');
        
// Build a FIFO queue of characters.     $chars = [];
    for ($i = 0; $i < $length$i++) {
      // Add the next character off the beginning of the string to the queue.       $current = mb_substr($str, 0, 1);
      $str = substr($strstrlen($current));
      $chars[] = $current;
      if ($i >= $min - 1) {
        // Make a token of $min characters, and add it to the token string.         $tokens .= implode('', $chars) . ' ';
        // Shift out the first character in the queue.         array_shift($chars);
      }
    }
    return $tokens;
  }

  /** * Helper function for array_walk in ::analyze(). * * @param string $text * The text to be truncated. */
  
throw new AutowiringFailedException($this->currentId, $e->getMessage(), 0, $e);
        }

        if ($constructor) {
            array_unshift($this->methodCalls, [$constructor$value->getArguments()]);
        }

        $checkAttributes = !$value->hasTag('container.ignore_attributes');
        $this->methodCalls = $this->autowireCalls($reflectionClass$isRoot$checkAttributes);

        if ($constructor) {
            [$arguments] = array_shift($this->methodCalls);

            if ($arguments !== $value->getArguments()) {
                $value->setArguments($arguments);
            }
        }

        if ($this->methodCalls !== $value->getMethodCalls()) {
            $value->setMethodCalls($this->methodCalls);
        }

        return $value;
    }
static::assertEquals($expect['size']$record['size']);
        static::assertEquals($expect['accessToken']$record['access_token']);
    }

    public function testImportExportFileSingleCreateMissingRequired(): void
    {
        $requiredProperties = ['originalName', 'path'];
        $num = \count($requiredProperties);
        $data = $this->prepareImportExportFileTestData($num);

        foreach ($requiredProperties as $property) {
            $entry = array_shift($data);
            unset($entry[$property]);

            try {
                $this->repository->create([$entry]$this->context);
                static::fail(sprintf('Create without required property \'%s\'', $property));
            } catch (\Exception $e) {
                static::assertInstanceOf(WriteException::class$e);
            }
        }
    }

    
      // dot-delimited strings, but need to be turned into associative arrays       // for parsing.       if (!str_contains($token, '.')) {
        // We need to validate tokens are valid Twig variables. Twig uses the         // same variable naming rules as PHP.         // @see http://php.net/manual/language.variables.basics.php         assert(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $token) === 1, 'Tokens need to be valid Twig variables.');
        $twig_tokens[$token] = $replacement;
      }
      else {
        $parts = explode('.', $token);
        $top = array_shift($parts);
        assert(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $top) === 1, 'Tokens need to be valid Twig variables.');
        $token_array = [array_pop($parts) => $replacement];
        foreach (array_reverse($parts) as $key) {
          // The key could also be numeric (array index) so allow that.           assert(is_numeric($key) || preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $key) === 1, 'Tokens need to be valid Twig variables.');
          $token_array = [$key => $token_array];
        }
        if (!isset($twig_tokens[$top])) {
          $twig_tokens[$top] = [];
        }
        $twig_tokens[$top] += $token_array;
      }
if ($hasLogger) {
            $logger = $this->createMock(LoggerInterface::class);
            if (null !== $expectedLoggerLevels) {
                $expectedCalls[] = [$logger$expectedLoggerLevels, false];
            }
        }

        $handler
            ->expects($this->exactly(\count($expectedCalls)))
            ->method('setDefaultLogger')
            ->willReturnCallback(function D...$args) use (&$expectedCalls) {
                $this->assertSame(array_shift($expectedCalls)$args);
            })
        ;

        $configurator = new ErrorHandlerConfigurator($logger$levels, null, true, true, $deprecationLogger);

        $configurator->configure($handler);
    }

    public static function provideLevelsAssignedToLoggers(): iterable
    {
        yield [false, false, 0, null, null];
        
/* Try PHP's upload_tmp_dir directive. */
        $tmp = ini_get('upload_tmp_dir');

        /* Otherwise, try to determine the TMPDIR environment variable. */
        if (!strlen($tmp)) {
            $tmp = getenv('TMPDIR');
        }

        /* If we still cannot determine a value, then cycle through a list of * preset possibilities. */
        while (!strlen($tmp) && count($tmp_locations)) {
            $tmp_check = array_shift($tmp_locations);
            if (@is_dir($tmp_check)) {
                $tmp = $tmp_check;
            }
        }

        /* If it is still empty, we have failed, so return false; otherwise * return the directory determined. */
        return strlen($tmp) ? $tmp : false;
    }

    /** * Checks a diff for validity. * * This is here only for debugging purposes. */

    public function __call($method$params)
    {
        $priority = strtoupper($method);
        if (($priority = array_search($priority$this->_priorities)) !== false) {
            switch (count($params)) {
                case 0:
                    /** @see Zend_Log_Exception */
                    throw new Zend_Log_Exception('Missing log message');
                case 1:
                    $message = array_shift($params);
                    $extras = null;
                    break;
                default:
                    $message = array_shift($params);
                    $extras  = array_shift($params);
                    break;
            }
            $this->log($message$priority$extras);
        } else {
            /** @see Zend_Log_Exception */
            throw new Zend_Log_Exception('Bad log priority');
        }
 false];

        yield 'fresh on every identical parameters' => [function DMockObject $container) {
            $container->expects(self::exactly(2))->method('hasParameter')->willReturn(true);
            $container->expects(self::exactly(2))->method('getParameter')
                ->willReturnCallback(function D...$args) {
                    static $series = [
                        [['locales']['fr', 'en']],
                        [['default_locale'], 'fr'],
                    ];

                    [$expectedArgs$return] = array_shift($series);
                    self::assertSame($expectedArgs$args);

                    return $return;
                })
            ;
        }, true];
    }
}
$container->get('entity_type.manager')->getStorage('menu_link_content'),
      $migration
    );
  }

  /** * {@inheritdoc} * * Find the parent link GUID. */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row$destination_property) {
    $parent_id = array_shift($value);

    // Handle root elements of a menu.     if (!$parent_id) {
      return '';
    }

    $lookup_result = $this->migrateLookup->lookup($this->migration->id()[$parent_id]);
    if ($lookup_result) {
      $already_migrated_id = $lookup_result[0]['id'];
    }

    

    public function __construct($options)
    {
        if ($options instanceof Zend_Db_Select) {
            $this->setSelect($options);
            return;
        }
        if ($options instanceof Zend_Config) {
            $options = $options->toArray();
        } else if (func_num_args() > 1) {
            $options       = func_get_args();
            $temp['table'] = array_shift($options);
            $temp['field'] = array_shift($options);
            if (!empty($options)) {
                $temp['exclude'] = array_shift($options);
            }

            if (!empty($options)) {
                $temp['adapter'] = array_shift($options);
            }

            $options = $temp;
        }

        

    private function extractLocalizedMessage($messages)
    {
        $languages = [
            $this->userLang,
            'en',
            'de',
        ];

        while ($language = array_shift($languages)) {
            if (isset($messages[$language])) {
                return $messages[$language];
            }
        }

        return '';
    }
}
$foundNotEmptyValidator = false;

                foreach ($validatorRule as $rule) {
                    if ($rule === 'NotEmpty') {
                        $foundNotEmptyValidator = true;
                        // field may not be empty, we are ready                         break 1;
                    }

                    if (is_array($rule)) {
                        $keys      = array_keys($rule);
                        $classKey  = array_shift($keys);
                        if (isset($rule[$classKey])) {
                            $ruleClass = $rule[$classKey];
                            if ($ruleClass === 'NotEmpty') {
                                $foundNotEmptyValidator = true;
                                // field may not be empty, we are ready                                 break 1;
                            }
                        }
                    }

                    // we must check if it is an object before using instanceof


    $args = array(
        'number'                 => 1,
        'update_site_meta_cache' => false,
    );

    if ( count( $domains ) > 1 ) {
        $args['domain__in']               = $domains;
        $args['orderby']['domain_length'] = 'DESC';
    } else {
        $args['domain'] = array_shift( $domains );
    }

    if ( count( $paths ) > 1 ) {
        $args['path__in']               = $paths;
        $args['orderby']['path_length'] = 'DESC';
    } else {
        $args['path'] = array_shift( $paths );
    }

    $result = get_sites( $args );
    $site   = array_shift( $result );

    
Home | Imprint | This part of the site doesn't use cookies.