diff --git a/language/control-structures/match.xml b/language/control-structures/match.xml index a4014754a..a51f712dc 100644 --- a/language/control-structures/match.xml +++ b/language/control-structures/match.xml @@ -1,6 +1,6 @@ - + match @@ -87,7 +87,7 @@ string(8) "Teenager" - match 表达式必须使用分号 ; 结尾。 + 当 match 表达式用作独立表达式时,必须以分号 ; 终止。 diff --git a/language/enumerations.xml b/language/enumerations.xml index f8dc83af6..099f4f8f5 100644 --- a/language/enumerations.xml +++ b/language/enumerations.xml @@ -1,5 +1,5 @@ - + 枚举 @@ -194,10 +194,9 @@ enum Suit: string - 条目等同的值,必须是个字面量或它的表达式。 - 不能是常量和常量表达式。 - 换言之,允许 1 + 1, - 不允许 1 + SOME_CONST。 + 等值可以是常量标量表达式。PHP 8.2.0 + 之前,必须是文字或文字表达式。这意味着不支持常量和常量表达式。也就是说,允许 + 1 + 1,但不允许 1 + SOME_CONST diff --git a/language/oop5/lazy-objects.xml b/language/oop5/lazy-objects.xml index c3a8ee9ba..8ab5767a3 100644 --- a/language/oop5/lazy-objects.xml +++ b/language/oop5/lazy-objects.xml @@ -90,7 +90,7 @@ $lazyObject = $reflector->newLazyProxy(function (Example $object) { var_dump($lazyObject); var_dump(get_class($lazyObject)); -// Triggers initialization +// 触发器初始化 var_dump($lazyObject->prop); ?> ]]> @@ -282,25 +282,19 @@ var_dump($post->id); 对象标记为非延迟。 - Properties not initialized with - ReflectionProperty::skipLazyInitialization or + 没有使用 ReflectionProperty::skipLazyInitializationReflectionProperty::setRawValueWithoutLazyInitialization - are set to their default values, if any. At this stage, the object - resembles one created with - ReflectionClass::newInstanceWithoutConstructor, - except for already initialized properties. + 初始化的属性将设置为他们的默认值(如果有)。在此阶段,该对象类似于使用 + ReflectionClass::newInstanceWithoutConstructor + 创建的对象,但排除已初始化的属性。 - The initializer function is then called with the object as its first - parameter. The function is expected, but not required, to initialize - the object state, and must return &null; or no value. The object is no - longer lazy at this point, so the function can access its properties - directly. + 然后,将对象作为第一个参数调用其初始化函数。该函数需要(但不是必须)初始化对象状态,并且必须返回 + &null; 或没有值。此时对象不再是延迟,因此该函数可以直接访问其属性。 - After initialization, the object is indistinguishable from an object that - was never lazy. + 初始化后,该对象与从未延迟过的对象没有区别。 diff --git a/language/oop5/static.xml b/language/oop5/static.xml index 49a179190..f3c7d9193 100644 --- a/language/oop5/static.xml +++ b/language/oop5/static.xml @@ -1,6 +1,6 @@ - + 静态(static)关键字 diff --git a/language/types.xml b/language/types.xml index 5987771cf..71ff13efe 100755 --- a/language/types.xml +++ b/language/types.xml @@ -1,6 +1,6 @@ - + 类型 @@ -110,7 +110,7 @@ int(16) &language.types.void; &language.types.never; &language.types.relative-class-types; - &language.types.value; + &language.types.singleton; &language.types.iterable; &language.types.declarations; &language.types.type-juggling; diff --git a/language/types/declarations.xml b/language/types/declarations.xml index 6072c28bf..3c1577cd1 100644 --- a/language/types/declarations.xml +++ b/language/types/declarations.xml @@ -1,6 +1,6 @@ - + 类型声明 @@ -257,7 +257,7 @@ Stack trace: 联合类型 - 在一个联合类型中不能同时用两个 Value 类型 false 和 + 在一个联合类型中不能同时用两个单例类型 falsetrue。而是使用 bool 替代。 diff --git a/language/types/value.xml b/language/types/singleton.xml similarity index 70% rename from language/types/value.xml rename to language/types/singleton.xml index f1713d64b..944bae809 100644 --- a/language/types/value.xml +++ b/language/types/singleton.xml @@ -1,11 +1,11 @@ - + - - Value 类型 + + 单例类型 - Value 类型是那些不仅检查值,而且也检查值本身的类型。PHP 支持两种 Value 类型:false(自 + 单例类型(singleton type)是只允许单个值的类型。PHP 支持两种单例类型:false(自 PHP 8.0.0 起支持),true(自 PHP 8.2.0 起支持)。 @@ -18,7 +18,7 @@ - 无法定义自定义 Value 类型。建议改用枚举。 + 无法定义自定义单例类型。建议改用枚举。 diff --git a/language/types/type-system.xml b/language/types/type-system.xml index 7bcfbeaf2..730edec73 100644 --- a/language/types/type-system.xml +++ b/language/types/type-system.xml @@ -1,5 +1,5 @@ - + 类型系统 @@ -27,9 +27,6 @@ 内置类型 - - null 类型 - 标量类型: @@ -70,18 +67,28 @@ 和 static - - - - - Value 类型 - - - false + + 单例类型 + + + + false + + + true + + - true + + 单值类型 + + + + null + + diff --git a/language/variables.xml b/language/variables.xml index 6e55a3d2c..11a09234c 100644 --- a/language/variables.xml +++ b/language/variables.xml @@ -1,6 +1,6 @@ - + 变量 @@ -448,6 +448,33 @@ function foo(){ + + 匿名函数内的静态变量仅在该特定函数实例中存在。如果每次调用时都重新创建匿名函数,则静态变量将重新初始化。 + + + 匿名函数内的静态变量 + + +]]> + + + 从 PHP 8.1.0 开始,当继承(不是覆盖)使用有静态变量的方法时,继承的方法将会跟父级方法共享静态变量。这意味着方法中的静态变量现在跟静态属性有相同的行为。