# Expressions And Operators: Scope Resolution

When the left-hand operand of operator `::` is an enumerated type, the right-hand operand must be the name of an enumeration constant within that type. For example:

``````enum ControlStatus: int {
Stopped = 0;
Stopping = 1;
Starting = 2;
Started = 3;
}

function main(ControlStatus \$p1): void {
switch (\$p1)
{
case ControlStatus::Stopped:
...
break;
case ControlStatus::Stopping:
...
break;
...
}
...
}
``````

From inside or outside a class or interface, operator `::` allows the selection of a constant. From inside or outside a class, this operator allows the selection of a static property, static method, or instance method. For example:

``````final class MathLibrary {
const PI = 3.1415926;
public static function sin(float \$val): float { ... }
...
}
\$v = MathLibrary::sin(2.34);
``````

From within a class, `::` also allows the selection of an overridden property or method.

From within a class, `self::m` refers to the member `m` in that class. For example:

``````class Point {
private static int \$pointCount = 0;
public static function getPointCount(): int {
return self::\$pointCount;
}
...
}
``````

From within a class, `parent::m` refers to the closest member `m` in the base-class hierarchy, not including the current class. For example:

``````class MyRangeException extends \Exception {
public function __construct(string \$message, ...)
{
parent::__construct(\$message);
...
}
...
}
``````

From within a method, `static::m` refers to the static member `m` in the class that corresponds to the class inheritance context in which the method is called. This allows late static binding. Consider the following scenario:

``````class Base {
public function b(): void {
static::f();  // calls the most appropriate f()
}
public static function f(): void { ... }
}
class Derived extends Base {
public static function f(): void { ... }
}
\$b1 = new Base();
\$b1->b(); // as \$b1 is an instance of Base, Base::b() calls Base::f()
\$d1 = new Derived();
\$d1->b(); // as \$d1 is an instance of Derived, Base::b() calls Derived::f()
``````

The value of the a scope-resolution expression ending in `::class` is a string containing the fully qualified name of the current class, which for a static qualifier, means the current class context. A variable name followed by `::` and a name results in a constant whose value has the `classname` type for the variable name's type. For example:

``````namespace NS_cn;
class C1 { ... }
class C2 {
public static classname<\NS_cn\C1> \$p1 = \NS_cn\C1::class;
public static function f(?classname<C1> \$p) : classname<C1> { ... }
public static array<classname<C1>> \$p2 = array(C1::class);
}
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.65090585,"math_prob":0.85420114,"size":2622,"snap":"2019-51-2020-05","text_gpt3_token_len":643,"char_repetition_ratio":0.13559969,"word_repetition_ratio":0.047505938,"special_character_ratio":0.29061785,"punctuation_ratio":0.27757353,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.978967,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-27T08:20:32Z\",\"WARC-Record-ID\":\"<urn:uuid:cf1f6295-2867-4ffe-b068-9ea01ef6178c>\",\"Content-Length\":\"42078\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:eef8f353-2e96-47a2-8cac-6831ba5a51c1>\",\"WARC-Concurrent-To\":\"<urn:uuid:dbf3d5ae-cb87-4dbb-b34a-dcc3ee2e485d>\",\"WARC-IP-Address\":\"54.69.241.74\",\"WARC-Target-URI\":\"https://docs.hhvm.com/hack/expressions-and-operators/scope-resolution\",\"WARC-Payload-Digest\":\"sha1:4ORYR5MX24NJ242MLPY3LT4W2IILEA7U\",\"WARC-Block-Digest\":\"sha1:UF3RBKCSKZRT2BS6DWLNTKGHA5JFB4DX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579251696046.73_warc_CC-MAIN-20200127081933-20200127111933-00489.warc.gz\"}"}