@param mixed $var
@param string $target
@param \WP_REST_Request $request

@return bool|\WP_Error
433010
protected function validate_confirmation( $var, $target, $request ) {
		$validate = $this->validate_not_empty( $var );
		if ( true === $validate ) {
			$compare = $request->get_param( $target );
			if ( $compare !== $var ) {
				return new \WP_Error( 400, $this->app->translate( 'The confirmation value does not match.' ) );
			}
		}

		return $validate;
	}
931981
public static function update($target, $content, $message = '', $append = false, $style = null) {
		$args = ['content' => $content, 'append' => $append];

		return new JsonView([
			'code'    => self::SUCCESS,
			'target'  => $target,
			'message' => $message,
			'style'   => $style,
			'args'    => $args,
			'action'  => self::ACT_UPDATE
		], ['ajax' => '1']);
	}
378317
protected function cookieMatchesTarget ($cookie, $target)
    {
        if (!is_array($target)) {
            throw new CAS_InvalidArgumentException(
                '$target must be an array of URL attributes as generated by parse_url().'
            );
        }
        if (!isset($target['host'])) {
            throw new CAS_InvalidArgumentException(
                '$target must be an array of URL attributes as generated by parse_url().'
            );
        }

        // Verify that the scheme matches
        if ($cookie['secure'] && $target['scheme'] != 'https') {
            return false;
        }

        // Verify that the host matches
        // Match domain and mulit-host cookies
        if (strpos($cookie['domain'], '.') === 0) {
            // .host.domain.edu cookies are valid for host.domain.edu
            if (substr($cookie['domain'], 1) == $target['host']) {
                // continue with other checks
            } else {
                // non-exact host-name matches.
                // check that the target host a.b.c.edu is within .b.c.edu
                $pos = strripos($target['host'], $cookie['domain']);
                if (!$pos) {
                    return false;
                }
                // verify that the cookie domain is the last part of the host.
                if ($pos + strlen($cookie['domain']) != strlen($target['host'])) {
                    return false;
                }
                // verify that the host name does not contain interior dots as per
                // RFC 2965 section 3.3.2  Rejecting Cookies
                // http://www.ietf.org/rfc/rfc2965.txt
                $hostname = substr($target['host'], 0, $pos);
                if (strpos($hostname, '.') !== false) {
                    return false;
                }
            }
        } else {
            // If the cookie host doesn't begin with '.',
            // the host must case-insensitive match exactly
            if (strcasecmp($target['host'], $cookie['domain']) !== 0) {
                return false;
            }
        }

        // Verify that the port matches
        if (isset($cookie['ports'])
            && !in_array($target['port'], $cookie['ports'])
        ) {
            return false;
        }

        // Verify that the path matches
        if (strpos($target['path'], $cookie['path']) !== 0) {
            return false;
        }

        return true;
    }
149549
public function match(RequestInterface $request, $pathOffset = 0)
    {
        if (!$request instanceof Request) {
            return null;
        }

        $pageUrl = substr($request->getUri()->getPath(), $pathOffset);

        $type = $this->getPageType();

        $pageParams = $this->parseUrl($pageUrl);

        if (empty($pageParams)) {
            return null;
        }

        try {
            $page = $this->getPage($pageParams['pageName'], $type);
        } catch (\Exception $e) {
            return null;
        }

        if (empty($page)) {
            return false;
        }

        $cms_params = array(
            'page' => $page,
            'controller' => $this->getController($type),
            'action' => $this->getAction($type),
            'revision' => $pageParams['revision']
        );

        return new RouteMatch($cms_params, strlen($pageUrl));
    }
994961
public function get_item( $request ) {
		$id = (int) $request['id'];
		$user = get_userdata( $id );

		if ( empty( $id ) || empty( $user->ID ) ) {
			return new WP_Error( 'rest_user_invalid_id', __( 'Invalid resource id.' ), array( 'status' => 404 ) );
		}

		$user = $this->prepare_item_for_response( $user, $request );
		$response = rest_ensure_response( $user );

		return $response;
	}
570995
public function getAction(Request $request, User $loggedUser, Portfolio $portfolio, $type)
    {
        $this->checkPortfolioToolAccess($loggedUser, $portfolio);

        $data = [];

        /** @var \Icap\PortfolioBundle\Entity\PortfolioWidget[] $portfolioWidgets */
        $portfolioWidgets = $this->getWidgetsManager()->getPortfolioWidgetsForWidgetPicker($portfolio, $loggedUser, $type);

        foreach ($portfolioWidgets as $widget) {
            $data[] = $this->getWidgetsManager()->getPortfolioWidgetData($widget);
        }

        $response = new JsonResponse();
        $response->setData($data);

        return $response;
    }
365409
public function updateTarget(Target $target): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_rule_target')
            ->set('rule_id', ':rule_id')
            ->set('type', ':type')
            ->set('value', ':value')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $target->id, Type::INTEGER)
            ->setParameter('rule_id', $target->ruleId, Type::INTEGER)
            ->setParameter('type', $target->type, Type::STRING)
            ->setParameter('value', $target->value, is_array($target->value) ? Type::JSON_ARRAY : Type::STRING);

        $this->applyStatusCondition($query, $target->status);

        $query->execute();
    }
120187
public function get_shared_object( $key, $target = null ) {
		! isset( $target ) and $target = $this->app->plugin_name;

		return isset( self::$_shared_object[ $target ][ $key ] ) ? self::$_shared_object[ $target ][ $key ] : null;
	}
402623
public function get_item( $request ) {
		$tax_obj = get_taxonomy( $request['taxonomy'] );
		if ( empty( $tax_obj ) ) {
			return new WP_Error( 'rest_taxonomy_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );
		}
		$data = $this->prepare_item_for_response( $tax_obj, $request );
		return rest_ensure_response( $data );
	}
1287335
public static function dump($val, HTTPRequest $request = null)
    {
        echo self::create_debug_view($request)
            ->renderVariable($val, self::caller());
    }
517163
public function validateTarget($target)
    {
        if ($target instanceof Application) {
            $validator = new ApplicationValidator();
            $response = $validator->validate($target);
        } elseif ($target instanceof ApplicationGroup) {
            $validator = new ApplicationGroupValidator();
            $response = $validator->validate($target);
        } else {
            $this->addError('target', 'Target must be a valid instance of Application or ApplicationGroup');
            return false;
        }

        if (!$response) {
            $this->addError('target', 'Target must be a valid instance of Application or ApplicationGroup class - ' . $validator->getErrorsAsString());
        }

        return $response;
    }
583957
protected function determineTargetUrl(Request $request)
    {
        if ($this->options['always_use_default_target_path']) {
            return $this->options['default_target_path'];
        }

        if ($targetUrl = $request->get($this->options['target_path_parameter'], null, true)) {
            return $targetUrl;
        }

        if (null !== $this->providerKey && $targetUrl = $request->getSession()->get('_security.'.$this->providerKey.'.target_path')) {
            $request->getSession()->remove('_security.'.$this->providerKey.'.target_path');

            return $targetUrl;
        }

        if ($this->options['use_referer'] && ($targetUrl = $request->headers->get('Referer')) && $targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) {
            return $targetUrl;
        }
        return $this->options['default_target_path'];
    }
566154
public function __doRequest($request, $location, $action, $version, $oneway=0){
      if (self::$logger->isDebugEnabled()) {
        self::$logger->debug("Request:");
        self::$logger->debug($request);
      }
      $response = trim(parent::__doRequest($request, $location, $action, $version, $oneway));
      if (self::$logger->isDebugEnabled()) {
        self::$logger->debug("Response:");
        self::$logger->debug($response);
        self::$logger->debug($this->getDebugInfos());
      }
      $parsedResponse = preg_replace('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $response);
      // fix missing last e> caused by php's built-in webserver
      if (preg_match('/^<\?xml/', $parsedResponse) && !preg_match('/e>$/', $parsedResponse)) {
        $parsedResponse .= 'e>';
      }
      return $parsedResponse;
  }
26318
public function Target($Target = FALSE) {
      if ($Target === FALSE) {
         $Target = $this->Form->GetFormValue('Target', FALSE);
         if (!$Target)
            $Target = $this->Request->Get('Target', '/');
      }
      
      // Make sure that the target is a valid url.
      if (!preg_match('`(^https?://)`', $Target)) {
         $Target = '/'.ltrim($Target, '/');
         
         // Never redirect back to signin.
         if (preg_match('`^/entry/signin`i', $Target))
            $Target = '/';
      } else {
         $MyHostname = parse_url(Gdn::Request()->Domain(),PHP_URL_HOST);
         $TargetHostname = parse_url($Target, PHP_URL_HOST);
         
         // Only allow external redirects to trusted domains.
         $TrustedDomains = C('Garden.TrustedDomains', TRUE);
         
         if (is_array($TrustedDomains)) {
            // Add this domain to the trusted hosts.
            $TrustedDomains[] = $MyHostname;
            $Sender->EventArguments['TrustedDomains'] = &$TrustedDomains;
            $this->FireEvent('BeforeTargetReturn');
         }
			
         if ($TrustedDomains === TRUE) {
            return $Target;
			} elseif (count($TrustedDomains) == 0) {
				// Only allow http redirects if they are to the same host name.
				if ($MyHostname != $TargetHostname)
					$Target = '';
			} else {
				// Loop the trusted domains looking for a match
				$Match = FALSE;
				foreach ($TrustedDomains as $TrustedDomain) {
					if (StringEndsWith($TargetHostname, $TrustedDomain, TRUE))
						$Match = TRUE;
				}
				if (!$Match)
					$Target = '';
			}
      }
      return $Target;
   }
1007651
protected function validateRequestTarget($requestTarget) : void
	{
		if (! \is_string($requestTarget))
		{
			throw new \InvalidArgumentException('HTTP request-target must be a string');
		}
		else if (! \preg_match('/^[\x21-\x7E\x80-\xFF]+$/', $requestTarget))
		{
			throw new \InvalidArgumentException(\sprintf('The given request-target "%s" is not valid', $requestTarget));
		}
	}
904519
public function text(string $text, string $source = 'auto', string $target = 'auto')
    {
        if (!('auto' === $source && 'auto' === $target)) {
            $this->checkTextTarget($source, $target);
        }

        return Request::exec(self::TEXT, compact('text', 'source', 'target'));
    }
232290
public function callback( \WP_REST_Request $request ) {
		$method_name = 'handle_' . strtolower( $request->get_method() );
		try {
			$result = $this->{$method_name}( $request );
			if ( is_wp_error( $result ) ) {
				return $result;
			} elseif( is_a( $result, 'WP_REST_Response' ) ) {
				return $result;
			} else {
				return new \WP_REST_Response( $result );
			}
		} catch ( \Exception $e ) {
			return new \WP_Error( $e->getCode(), $e->getMessage(), [
				'response' => $e->getCode(),
			] );
		}
	}