Yoast\WP\SEO\MyYoast_Client\Domain
Resource_Indicator::__construct
Resource_Indicator constructor.
Null yields the default-resource instance — no validation, no wire parameter, default storage bucket. Non-null is validated per RFC 8707 §2 (absolute URI per RFC 3986 §4.3, no fragment) and has its trailing slash canonicalized for storage-key stability.
Метод класса: Resource_Indicator{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Resource_Indicator = new Resource_Indicator(); $Resource_Indicator->__construct( ?string $value );
- ?string $value(обязательный)
- .
Код Resource_Indicator::__construct() Resource Indicator:: construct Yoast 28.9
public function __construct( ?string $value ) {
if ( $value === null ) {
$this->value = null;
return;
}
$trimmed = \trim( $value );
if ( $trimmed === '' ) {
throw new Invalid_Resource_Exception( 'Resource indicator must not be empty.' );
}
// Fragment forbidden by RFC 8707 §2. Checked before the absolute-URI
// regex so the caller gets a more specific error message.
if ( \strpos( $trimmed, '#' ) !== false ) {
throw new Invalid_Resource_Exception( 'Resource indicator must not contain a fragment (RFC 8707 §2).' );
}
// RFC 3986 §4.3 absolute-URI: scheme ":" hier-part [ "?" query ].
// We don't deeply validate hier-part — the authorization server will
// reject unrecognized formats via OAuth `invalid_target`.
//
// Anchors are \A (start-of-string) and \z (end-of-string), NOT ^ and $.
// ^/$ are line-aware: $ matches before a trailing \n by default, and
// with /m both match at every line boundary. That lets a two-line
// input smuggle a second URI past the check while still appearing to
// "match the whole string". \A and \z always mean literal start/end of
// the entire input regardless of newlines or regex flags, which is
// what we need when validating untrusted input that goes on the wire.
$absolute_uri_pattern = '/\A' . self::SCHEME_PATTERN . ':' . self::URI_TAIL_PATTERN . '\z/';
if ( \preg_match( $absolute_uri_pattern, $trimmed ) !== 1 ) {
throw new Invalid_Resource_Exception( 'Resource indicator must be an absolute URI (RFC 3986 §4.3, RFC 8707 §2).' );
}
$this->value = self::normalize_trailing_slash( $trimmed );
}