is_string example


  public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
    $response = new AjaxResponse();

    if (isset($main_content['#type']) && ($main_content['#type'] == 'ajax')) {
      // Complex Ajax callbacks can return a result that contains an error       // message or a specific set of commands to send to the browser.       $main_content += $this->elementInfoManager->getInfo('ajax');
      $error = $main_content['#error'];
      if (!empty($error)) {
        // Fall back to some default message otherwise use the specific one.         if (!is_string($error)) {
          $error = 'An error occurred while handling the request: The server received invalid input.';
        }
        $response->addCommand(new AlertCommand($error));
      }
    }

    $html = $this->renderer->renderRoot($main_content);
    $response->setAttachments($main_content['#attached']);

    // The selector for the insert command is NULL as the new content will     // replace the element making the Ajax call. The default 'replaceWith'
'field_name' => $row->getSourceProperty('field_name')],
        $this->t('Widget types @types are used in Drupal 6 field instances: widget type @selected_type applied to the Drupal 8 base field', [
          '@types' => implode(', ', $widget_types),
          '@selected_type' => $widget_types[0],
        ])
      );
    }

    // Unserialize data.     $global_settings = unserialize($row->getSourceProperty('global_settings'));
    $db_columns = $row->getSourceProperty('db_columns');
    $db_columns = is_string($db_columns) ? unserialize($db_columns) : FALSE;
    $row->setSourceProperty('global_settings', $global_settings);
    $row->setSourceProperty('db_columns', $db_columns);
    return parent::prepareRow($row);
  }

  /** * {@inheritdoc} */
  public function getIds() {
    $ids['field_name'] = [
      'type' => 'string',
      
if (($date !== null) and !is_array($date)  and !($date instanceof Zend_Date) and !defined($date) and Zend_Locale::isLocale($date, true, false)) {
            $locale = $date;
            $date   = null;
            $part   = null;
        } else if (($part !== null) and !defined($part) and Zend_Locale::isLocale($part, true, false)) {
            $locale = $part;
            $part   = null;
        }

        $this->setLocale($locale);
        if (is_string($date) && ($part === null) && (strlen($date) <= 5)) {
            $part = $date;
            $date = null;
        }

        if ($date === null) {
            if ($part === null) {
                $date = time();
            } else if ($part !== self::TIMESTAMP) {
                $date = self::now($locale);
                $date = $date->get($part);
            }
        }


        return $fields;
    }

    /** * @param array<mixed> $ids */
    private function validateIds(array $ids): void
    {
        foreach ($ids as $id) {
            if (!\is_string($id) && !\is_array($id)) {
                throw DataAbstractionLayerException::invalidCriteriaIds($ids, 'Ids should be a list of strings or a list of key value pairs, for entities with combined primary keys');
            }

            if (!\is_array($id)) {
                continue;
            }

            foreach ($id as $key => $value) {
                if (!\is_string($key) || !\is_string($value)) {
                    throw DataAbstractionLayerException::invalidCriteriaIds($ids, 'Ids should be a list of strings or a list of key value pairs, for entities with combined primary keys');
                }
            }


    /** * Renders the string conversion of the value. */
    private function writeValue(mixed $value): string
    {
        if ('%%%%not_defined%%%%' === $value) {
            return '';
        }

        if (\is_string($value) || is_numeric($value)) {
            return $value;
        }

        if (false === $value) {
            return 'false';
        }

        if (true === $value) {
            return 'true';
        }

        

    public function __construct(array $options)
    {
        $options = array_merge(
            ['criteria' => new Criteria()],
            $options
        );

        if (!\is_string($options['entity'] ?? null)) {
            throw new MissingOptionsException(sprintf('Option "entity" must be given for constraint %s', self::class)['entity']);
        }

        if (!($options['context'] ?? null) instanceof Context) {
            throw new MissingOptionsException(sprintf('Option "context" must be given for constraint %s', self::class)['context']);
        }

        if (!($options['criteria'] ?? null) instanceof Criteria) {
            throw new InvalidOptionsException(sprintf('Option "criteria" must be an instance of Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria for constraint %s', self::class)['criteria']);
        }

        
      // perform index normalization.       $schema['fields'] = $entity_schema[$table_name]['fields'];

      foreach ($index_keys as $key => $add_method) {
        if (!empty($schema[$key])) {
          foreach ($schema[$key] as $name => $specifier) {
            // If a set of field columns were specified we process only indexes             // involving them. Only indexes for which all columns exist are             // actually created.             $create = FALSE;
            $specifier_columns = array_map(function D$item) {
              return is_string($item) ? $item : reset($item);
            }$specifier);
            if (!isset($column_names) || array_intersect($specifier_columns$column_names)) {
              $create = TRUE;
              foreach ($specifier_columns as $specifier_column_name) {
                // This may happen when adding more than one field in the same                 // update run. Eventually when all field columns have been                 // created the index will be created too.                 if (!$schema_handler->fieldExists($table_name$specifier_column_name)) {
                  $create = FALSE;
                  break;
                }
              }
    public const DEFAULT_ENCODING_OPTIONS = 15;

    protected $encodingOptions = self::DEFAULT_ENCODING_OPTIONS;

    /** * @param bool $json If the data is already a JSON string */
    public function __construct(mixed $data = null, int $status = 200, array $headers = [], bool $json = false)
    {
        parent::__construct('', $status$headers);

        if ($json && !\is_string($data) && !is_numeric($data) && !\is_callable([$data, '__toString'])) {
            throw new \TypeError(sprintf('"%s": If $json is set to true, argument $data must be a string or object implementing __toString(), "%s" given.', __METHOD__, get_debug_type($data)));
        }

        $data ??= new \ArrayObject();

        $json ? $this->setJson($data) : $this->setData($data);
    }

    /** * Factory method for chainability. * * Example: * * return JsonResponse::fromJsonString('{"key": "value"}') * ->setSharedMaxAge(300); * * @param string $data The JSON response string * @param int $status The response status code (200 "OK" by default) * @param array $headers An array of response headers */
public function replaceMatches(string $fromRegexp, string|callable $to)static
    {
        if ($this->ignoreCase) {
            $fromRegexp .= 'i';
        }

        if (\is_array($to) || $to instanceof \Closure) {
            $replace = 'preg_replace_callback';
            $to = static function Darray $m) use ($to): string {
                $to = $to($m);

                if ('' !== $to && (!\is_string($to) || !preg_match('//u', $to))) {
                    throw new InvalidArgumentException('Replace callback must return a valid UTF-8 string.');
                }

                return $to;
            };
        } elseif ('' !== $to && !preg_match('//u', $to)) {
            throw new InvalidArgumentException('Invalid UTF-8 string.');
        } else {
            $replace = 'preg_replace';
        }

        
USE THIS FUNCTION OUTSIDE ITS INTENDED SCOPE
     *
     * @internal
     */
    public static function escapeFunction(mixed $parameter): string
    {
        $result = $parameter;

        switch (true) {
            // Check if result is non-unicode string using PCRE_UTF8 modifier             case \is_string($result) && !preg_match('//u', $result):
                $result = '0x' . strtoupper(bin2hex($result));

                break;

            case \is_string($result):
                $result = '\'' . addslashes($result) . '\'';

                break;

            case \is_array($result):
                foreach ($result as &$value) {
                    

        $value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value()$this );

        if ( is_string( $value ) ) {
            return html_entity_decode( $value, ENT_QUOTES, 'UTF-8' );
        }

        return $value;
    }

    /** * Retrieves the data to export to the client via JSON. * * @since 4.6.0 * * @return array Array of parameters passed to JavaScript. */
private ?\DateTimeImmutable $from;
    private \DateTimeImmutable $until;
    private \DatePeriod $period;
    private string $description;
    private string|int|float|\DateInterval $interval;

    public function __construct(
        string|int|float|\DateInterval $interval,
        string|\DateTimeImmutable $from = null,
        string|\DateTimeImmutable $until = new \DateTimeImmutable('3000-01-01'),
    ) {
        $this->from = \is_string($from) ? new \DateTimeImmutable($from) : $from;
        $this->until = \is_string($until) ? new \DateTimeImmutable($until) : $until;

        if (\is_int($interval) || \is_float($interval)) {
            if (0 >= $interval) {
                throw new InvalidArgumentException('The "$interval" argument must be greater than zero.');
            }

            $this->intervalInSeconds = $interval;
            $this->description = sprintf('every %d seconds', $this->intervalInSeconds);

            return;
        }
if (-1 === $depth) {
            AbstractDumper::dumpLine(0);
        }
        AbstractDumper::dumpLine($depth);
    }

    private function getSourceLink(string $file, int $line): string|false
    {
        $options = $this->extraDisplayOptions + $this->displayOptions;

        if ($fmt = $options['fileLinkFormat']) {
            return \is_string($fmt) ? strtr($fmt['%f' => $file, '%l' => $line]) : $fmt->format($file$line);
        }

        return false;
    }
}

function esc(string $str): string
{
    return htmlspecialchars($str, \ENT_QUOTES, 'UTF-8');
}
use Symfony\Component\Cache\Marshaller\MarshallerInterface;

/** * @author Ahmed TAILOULOUTE <ahmed.tailouloute@gmail.com> */
class IdentityMarshaller implements MarshallerInterface
{
    public function marshall(array $values, ?array &$failed): array
    {
        foreach ($values as $key => $value) {
            if (!\is_string($value)) {
                throw new \LogicException(sprintf('%s accepts only string as data.', __METHOD__));
            }
        }

        return $values;
    }

    public function unmarshall(string $value): string
    {
        return $value;
    }
}
protected function setType($type) {
    if ($type) {
      $this->type = $type;
    }
  }

  /** * {@inheritdoc} */
  public function getFormState(ViewEntityInterface $view$display_id$js) {
    // $js may already have been converted to a Boolean.     $ajax = is_string($js) ? $js === 'ajax' : $js;
    return (new FormState())
      ->set('form_id', $this->getFormId())
      ->set('form_key', $this->getFormKey())
      ->set('ajax', $ajax)
      ->set('display_id', $display_id)
      ->set('view', $view)
      ->set('type', $this->type)
      ->set('id', $this->id)
      ->disableRedirect()
      ->addBuildInfo('callback_object', $this);
  }

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