From 248db1f61e6811165465fec47af1dc168e6bfdab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Sat, 9 Nov 2024 18:43:42 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=83=89=E3=82=AD?= =?UTF-8?q?=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=20=E8=8B=B1=E8=AA=9E?= =?UTF-8?q?=E7=89=88=E7=8A=B6=E6=85=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- language/oop5/changelog.xml | 8 +- language/oop5/lazy-objects.xml | 484 ++++++++++++++++++ reference/reflection/reflectionclass.xml | 34 +- .../reflectionclass/getlazyinitializer.xml | 73 +++ .../reflectionclass/initializelazyobject.xml | 131 +++++ .../isuninitializedlazyobject.xml | 114 +++++ .../marklazyobjectasinitialized.xml | 198 +++++++ .../reflectionclass/newlazyghost.xml | 188 +++++++ .../reflectionclass/newlazyproxy.xml | 181 +++++++ .../reflectionclass/resetaslazyghost.xml | 170 ++++++ .../reflectionclass/resetaslazyproxy.xml | 100 ++++ .../reflection/reflectionproperty/islazy.xml | 67 +++ .../setrawvaluewithoutlazyinitialization.xml | 90 ++++ .../skiplazyinitialization.xml | 80 +++ 14 files changed, 1916 insertions(+), 2 deletions(-) create mode 100644 language/oop5/lazy-objects.xml create mode 100644 reference/reflection/reflectionclass/getlazyinitializer.xml create mode 100644 reference/reflection/reflectionclass/initializelazyobject.xml create mode 100644 reference/reflection/reflectionclass/isuninitializedlazyobject.xml create mode 100644 reference/reflection/reflectionclass/marklazyobjectasinitialized.xml create mode 100644 reference/reflection/reflectionclass/newlazyghost.xml create mode 100644 reference/reflection/reflectionclass/newlazyproxy.xml create mode 100644 reference/reflection/reflectionclass/resetaslazyghost.xml create mode 100644 reference/reflection/reflectionclass/resetaslazyproxy.xml create mode 100644 reference/reflection/reflectionproperty/islazy.xml create mode 100644 reference/reflection/reflectionproperty/setrawvaluewithoutlazyinitialization.xml create mode 100644 reference/reflection/reflectionproperty/skiplazyinitialization.xml diff --git a/language/oop5/changelog.xml b/language/oop5/changelog.xml index 7f6e10adfda..8623f27a3b1 100644 --- a/language/oop5/changelog.xml +++ b/language/oop5/changelog.xml @@ -1,6 +1,6 @@ - + @@ -19,6 +19,12 @@ + + 8.4.0 + + Added: Support for Lazy Objects. + + 8.1.0 diff --git a/language/oop5/lazy-objects.xml b/language/oop5/lazy-objects.xml new file mode 100644 index 00000000000..25b88bf942b --- /dev/null +++ b/language/oop5/lazy-objects.xml @@ -0,0 +1,484 @@ + + + + + + Lazy Objects + + + A lazy object is an object whose initialization is deferred until its + state is observed or modified. Some use-case examples include dependency + injection components that provide lazy services fully initialized only if + needed, ORMs providing lazy entities that hydrate + themselves from the database only when accessed, or a JSON parser that + delays parsing until elements are accessed. + + + + Two lazy object strategies are supported: Ghost Objects and Virtual + Proxies, hereafter referred to as "lazy ghosts" and + "lazy proxies". + In both strategies, the lazy object is attached to an initializer or factory + that is called automatically when its state is observed or modified for + the first time. From an abstraction point of view, lazy ghost objects are + indistinguishable from non-lazy ones: they can be used without knowing they + are lazy, allowing them to be passed to and used by code that is unaware of + laziness. Lazy proxies are similarly transparent, but care must be taken when + their identity is used, as the proxy and its real instance have different + identities. + + + + Creating Lazy Objects + + + It is possible to create a lazy instance of any user defined class or the + stdClass class (other internal classes are not + supported), or to reset an instance of these classes to make it lazy. + The entry points for creating a lazy object are the + ReflectionClass::newLazyGhost and + ReflectionClass::newLazyProxy methods. + + + + Both methods accept a function that is called when the object requires + initialization. The function's expected behavior varies depending on the + strategy in use, as described in the reference documentation for each method. + + + + Creating a Lazy Ghost + +newLazyGhost(function (Example $object) { + // Initialize object in-place + $object->__construct(1); +}); + +var_dump($lazyObject); +var_dump(get_class($lazyObject)); + +// Triggers initialization +var_dump($lazyObject->prop); +?> +]]> + + &example.outputs; + + +uninitialized(int) +} +string(7) "Example" +Example::__construct +int(1) +]]> + + + + + Creating a Lazy Proxy + +newLazyProxy(function (Example $object) { + // Create and return the real instance + return new Example(1); +}); + +var_dump($lazyObject); +var_dump(get_class($lazyObject)); + +// Triggers initialization +var_dump($lazyObject->prop); +?> +]]> + + &example.outputs; + + + uninitialized(int) +} +string(7) "Example" +Example::__construct +int(1) +]]> + + + + + Any access to properties of a lazy object triggers its initialization + (including via ReflectionProperty). + However, certain properties might be known in advance and should not trigger + initialization when accessed: + + + + Initializing Properties Eagerly + +newLazyGhost(function ($post) { + $data = fetch_from_store($post->id); + $post->__construct($data['id'], $data['title'], $data['content']); +}); + +// Without this line, the following call to ReflectionProperty::setValue() would +// trigger initialization. +$reflector->getProperty('id')->skipLazyInitialization($post); +$reflector->getProperty('id')->setValue($post, 123); + +// Alternatively, one can use this directly: +$reflector->getProperty('id')->setRawValueWithoutLazyInitialization($post, 123); + +// The id property can be accessed without triggering initialization +var_dump($post->id); +?> +]]> + + + + + The ReflectionProperty::skipLazyInitialization and + ReflectionProperty::setRawValueWithoutLazyInitialization + methods offer ways to bypass lazy-initialization when accessing a property. + + + + + About Lazy Object Strategies + + + Lazy ghosts are objects that initialize in-place and, + once initialized, are indistinguishable from an object that was never lazy. + This strategy is suitable when we control both the instantiation and + initialization of the object, making it unsuitable if either of these is + managed by another party. + + + + Lazy proxies, once initialized, act as proxies to + a real instance: any operation on an initialized lazy proxy is forwarded + to the real instance. The creation of the real instance can be delegated + to another party, making this strategy useful in cases where lazy ghosts + are unsuitable. Although lazy proxies are nearly as transparent as lazy + ghosts, caution is needed when their identity is used, as the proxy and + its real instance have distinct identities. + + + + + Lifecycle of Lazy Objects + + + Objects can be made lazy at instantiation time using + ReflectionClass::newLazyGhost or + ReflectionClass::newLazyProxy, or after + instantiation by using + ReflectionClass::resetAsLazyGhost or + ReflectionClass::resetAsLazyProxy. Following this, a + lazy object can become initialized through one of the following operations: + + + + + Interacting with the object in a way that triggers automatic initialization. See + Initialization + triggers. + + + Marking all its properties as non-lazy using + ReflectionProperty::skipLazyInitialization or + ReflectionProperty::setRawValueWithoutLazyInitialization. + + + Calling explicitly ReflectionClass::initializeLazyObject + or ReflectionClass::markLazyObjectAsInitialized. + + + + + As lazy objects become initialized when all their properties are marked + non-lazy, the above methods will not mark an object as lazy if no properties + could be marked as lazy. + + + + + Initialization Triggers + + + Lazy objects are designed to be fully transparent to their consumers, + so normal operations that observe or modify the object's state will + automatically trigger initialization before the operation is performed. This + includes, but is not limited to, the following operations: + + + + + Reading or writing a property. + + + Testing if a property is set or unsetting it. + + + Accessing or modifying a property via + ReflectionProperty::getValue, + ReflectionProperty::getRawValue, + ReflectionProperty::setValue, + or ReflectionProperty::setRawValue. + + + Listing properties with + ReflectionObject::getProperties, + ReflectionObject::getProperty, + get_object_vars. + + + Iterating over properties of an object that does not implement + Iterator or + IteratorAggregate using + foreach. + + + Serializing the object with serialize, + json_encode, etc. + + + Cloning the + object. + + + + + Method calls that do not access the object state will not trigger + initialization. Similarly, interactions with the object that invoke magic + methods or hook functions will not trigger initialization if these methods + or functions do not access the object's state. + + + + Non-Triggering Operations + + + The following specific methods or low-level operations allow access or + modification of lazy objects without triggering initialization: + + + + + Marking properties as non-lazy with + ReflectionProperty::skipLazyInitialization or + ReflectionProperty::setRawValueWithoutLazyInitialization. + + + Retrieving the internal representation of properties using + get_mangled_object_vars or by + casting the object to an + array. + + + Using serialize when + ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE + is set, unless + __serialize() or + __sleep() trigger initialization. + + + Calling to ReflectionObject::__toString. + + + Using var_dump or + debug_zval_dump, unless + __debugInfo() triggers + initialization. + + + + + + + Initialization Sequence + + + This section outlines the sequence of operations performed when + initialization is triggered, based on the strategy in use. + + + + Ghost Objects + + + The object is marked as non-lazy. + + + Properties not initialized with + ReflectionProperty::skipLazyInitialization or + ReflectionProperty::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. + + + 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. + + + + After initialization, the object is indistinguishable from an object that + was never lazy. + + + + + Proxy Objects + + + The object is marked as non-lazy. + + + Unlike ghost objects, the properties of the object are not modified at + this stage. + + + The factory function is called with the object as its first parameter and + must return a non-lazy instance of a compatible class (see + ReflectionClass::newLazyProxy). + + + The returned instance is referred to as the real + instance and is attached to the proxy. + + + The proxy's property values are discarded as though + unset was called. + + + + After initialization, accessing any property on the proxy will + yield the same result as accessing the corresponding property on + the real instance; all property accesses on the proxy are forwarded + to the real instance, including declared, dynamic, non-existing, or + properties marked with + ReflectionProperty::skipLazyInitialization or + ReflectionProperty::setRawValueWithoutLazyInitialization. + + + The proxy object itself is not replaced or substituted + for the real instance. + + + While the factory receives the proxy as its first parameter, it is + not expected to modify it (modifications are allowed but will be lost + during the final initialization step). However, the proxy can be used + for decisions based on the values of initialized properties, the class, + the object itself, or its identity. For instance, the initializer might + use an initialized property's value when creating the real instance. + + + + + Common Behavior + + + The scope and $this context of the initializer or factory + function remains unchanged, and usual visibility constraints apply. + + + + After successful initialization, the initializer or factory function + is no longer referenced by the object and may be released if it has no + other references. + + + + If the initializer throws an exception, the object state is reverted to its + pre-initialization state and the object is marked as lazy again. In other + words, all effects on the object itself are reverted. Other side effects, + such as effects on other objects, are not reverted. This prevents + exposing a partially initialized instance in case of failure. + + + + + + Cloning + + + Cloning + a lazy object triggers its initialization before the clone is + created, resulting in an initialized object. + + + + For proxy objects, both the proxy and its real instance are cloned, and + the clone of the proxy is returned. + The __clone method + is called on the real instance, not on the proxy. + The cloned proxy and real instance are linked as they are during + initialization, so accesses to the proxy clone are forwarded to the real + instance clone. + + + + This behavior ensures that the clone and the original object maintain + separate states. Changes to the original object or its initializer's state + after cloning do not affect the clone. Cloning both the proxy and its real + instance, rather than returning a clone of the real instance alone, ensures + that the clone operation consistently returns an object of the same class. + + + + + Destructors + + + For lazy ghosts, the destructor is only called if the object has been + initialized. For proxies, the destructor is only called on the real instance, + if one exists. + + + + The ReflectionClass::resetAsLazyGhost and + ReflectionClass::resetAsLazyProxy methods may invoke + the destructor of the object being reset. + + + diff --git a/reference/reflection/reflectionclass.xml b/reference/reflection/reflectionclass.xml index 73cae67ed4e..def865370b1 100644 --- a/reference/reflection/reflectionclass.xml +++ b/reference/reflection/reflectionclass.xml @@ -1,6 +1,6 @@ - + ReflectionClass クラス @@ -57,6 +57,18 @@ int ReflectionClass::IS_READONLY + + public + const + int + ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE + + + public + const + int + ReflectionClass::SKIP_DESTRUCTOR + &Properties; @@ -141,6 +153,26 @@ + + ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE + + + Indicates that serialize should not trigger + initialization of a lazy object. + + + + + + ReflectionClass::SKIP_DESTRUCTOR + + + Indicates an object destructor should not be called when resetting it as + lazy. + + + + diff --git a/reference/reflection/reflectionclass/getlazyinitializer.xml b/reference/reflection/reflectionclass/getlazyinitializer.xml new file mode 100644 index 00000000000..1b8195a4465 --- /dev/null +++ b/reference/reflection/reflectionclass/getlazyinitializer.xml @@ -0,0 +1,73 @@ + + + + + + + ReflectionClass::getLazyInitializer + Gets lazy initializer + + + + &reftitle.description; + + public callablenullReflectionClass::getLazyInitializer + objectobject + + + Gets the lazy initializer or factory attached to + object. + + + + + &reftitle.parameters; + + + object + + + The object from which to get the initializer. + + + + + + + + &reftitle.returnvalues; + + Returns the initializer if the object is an uninitialized lazy + object, &null; otherwise. + + + + + &reftitle.seealso; + + Lazy objects + ReflectionClass::newLazyGhost + + + + + diff --git a/reference/reflection/reflectionclass/initializelazyobject.xml b/reference/reflection/reflectionclass/initializelazyobject.xml new file mode 100644 index 00000000000..b3034bf3aa9 --- /dev/null +++ b/reference/reflection/reflectionclass/initializelazyobject.xml @@ -0,0 +1,131 @@ + + + + + + + ReflectionClass::initializeLazyObject + Forces initialization of a lazy object + + + + &reftitle.description; + + public objectReflectionClass::initializeLazyObject + objectobject + + + Forces initialization of the specified object. This + method has no effect if the object is not lazy or has already been + initialized. Otherwise, initialization proceeds as described in the + Initialization + Sequence. + + + + + In most cases, calling this method is unnecessary, as lazy objects + initialize themselves automatically when their state is observed or + modified. + + + + + + &reftitle.parameters; + + + object + + + The object to initialize. + + + + + + + + &reftitle.returnvalues; + + If object is a lazy proxy, returns its real instance. + Otherwise, returns object itself. + + + + + &reftitle.examples; + + Basic usage + +newLazyGhost(function ($object) { + echo "Initializer called\n"; + $object->__construct(1); +}); + +var_dump($object); + +$reflector->initializeLazyObject($object); + +var_dump($object); +?> +]]> + + &example.outputs; + + + uninitialized(int) +} +Initializer called +object(Example)#3 (1) { + ["prop"]=> + int(1) +} +]]> + + + + + + &reftitle.seealso; + + Lazy objects + ReflectionClass::newLazyGhost + ReflectionClass::markLazyObjectAsInitialized + ReflectionClass::isUninitializedLazyObject + + + + + diff --git a/reference/reflection/reflectionclass/isuninitializedlazyobject.xml b/reference/reflection/reflectionclass/isuninitializedlazyobject.xml new file mode 100644 index 00000000000..8755dc172ee --- /dev/null +++ b/reference/reflection/reflectionclass/isuninitializedlazyobject.xml @@ -0,0 +1,114 @@ + + + + + + + ReflectionClass::isUninitializedLazyObject + Checks if an object is lazy and uninitialized + + + + &reftitle.description; + + public boolReflectionClass::isUninitializedLazyObject + objectobject + + + Checks if an object is lazy and uninitialized. + + + + + &reftitle.parameters; + + + object + + + The object to check. + + + + + + + + &reftitle.returnvalues; + + Returns &true; if object is an uninitialized lazy + object, &false; otherwise. + + + + + &reftitle.examples; + + Basic usage + +newLazyGhost(function ($object) { + echo "Initializer called\n"; + $object->__construct(1); +}); + +var_dump($reflector->isUninitializedLazyObject($object)); + +var_dump($object->prop); + +var_dump($reflector->isUninitializedLazyObject($object)); +?> +]]> + + &example.outputs; + + + + + + + + &reftitle.seealso; + + Lazy objects + ReflectionClass::newLazyGhost + ReflectionClass::markLazyObjectAsInitialized + ReflectionClass::initializeLazyObject + + + + + diff --git a/reference/reflection/reflectionclass/marklazyobjectasinitialized.xml b/reference/reflection/reflectionclass/marklazyobjectasinitialized.xml new file mode 100644 index 00000000000..bd3baede895 --- /dev/null +++ b/reference/reflection/reflectionclass/marklazyobjectasinitialized.xml @@ -0,0 +1,198 @@ + + + + + + + ReflectionClass::markLazyObjectAsInitialized + Marks a lazy object as initialized without calling the initializer or factory + + + + &reftitle.description; + + public objectReflectionClass::markLazyObjectAsInitialized + objectobject + + + Marks a lazy object as initialized without calling the initializer or + factory. This has no effect if object is not lazy or + is already initialized. + + + The effect of calling this method is the same as described for Ghost Objects + (regardless of the laziness strategy of object) in + initialization + sequence, except that the initializer is not called. + After that, the object is indistinguishable from an object that was never + lazy and was created with + ReflectionClass::newInstanceWithoutConstructor, + except for the value of properties that were already initialized with + ReflectionProperty::setRawValueWithoutLazyInitialization + or ReflectionProperty::skipLazyInitialization. + + + + + &reftitle.parameters; + + + object + + + The object to mark as initialized. + + + + + + + + &reftitle.returnvalues; + + Returns object. + + + + + &reftitle.examples; + + Marking an uninitialized lazy object as initialized + +newLazyGhost(function ($object) { + echo "Initializer called\n"; + $object->prop1 = 'initialized'; +}); + +$reflector->getProperty('prop1') + ->setRawValueWithoutLazyInitialization($object, 'prop1 value'); + +var_dump($object); + +$reflector->markLazyObjectAsInitialized($object); + +var_dump($object); +?> +]]> + + &example.outputs; + + + string(11) "prop1 value" + ["prop2"]=> + uninitialized(string) + ["prop3"]=> + uninitialized(string) +} +object(Example)#3 (2) { + ["prop1"]=> + string(11) "prop1 value" + ["prop2"]=> + uninitialized(string) + ["prop3"]=> + string(13) "default value" +} +]]> + + + + Marking an initialized object as initialized + +newLazyGhost(function ($object) { + echo "Initializer called\n"; + $object->prop1 = 'initialized'; +}); + +$reflector->getProperty('prop1') + ->setRawValueWithoutLazyInitialization($object, 'prop1 value'); + +var_dump($object->prop3); +var_dump($object); + +$reflector->markLazyObjectAsInitialized($object); + +var_dump($object); +?> +]]> + + &example.outputs; + + + string(11) "initialized" + ["prop2"]=> + uninitialized(string) + ["prop3"]=> + string(13) "default value" +} +object(Example)#3 (2) { + ["prop1"]=> + string(11) "initialized" + ["prop2"]=> + uninitialized(string) + ["prop3"]=> + string(13) "default value" +} +]]> + + + + + + &reftitle.seealso; + + Lazy objects + ReflectionClass::newLazyGhost + ReflectionClass::initializeLazyObject + ReflectionClass::isUninitializedLazyObject + + + + + diff --git a/reference/reflection/reflectionclass/newlazyghost.xml b/reference/reflection/reflectionclass/newlazyghost.xml new file mode 100644 index 00000000000..d133e7dc1ec --- /dev/null +++ b/reference/reflection/reflectionclass/newlazyghost.xml @@ -0,0 +1,188 @@ + + + + + + + ReflectionClass::newLazyGhost + Creates a new lazy ghost instance + + + + &reftitle.description; + + public object ReflectionClass::newLazyGhost + callableinitializer + intoptions0 + + + Creates a new lazy ghost instance of the class, attaching the + initializer to it. The constructor is not called, and + properties are not set to their default value. However, the object will + be automatically initialized by invoking the + initializer the first time its state is observed or + modified. See + Initialization + Triggers and + Initialization Sequence. + + + + + &reftitle.parameters; + + + initializer + + + The initializer is a callback with the following signature: + + + + voidinitializer + objectobject + + + + object + + + The object being initialized. At this point, + the object is no longer marked as lazy, and accessing it does not + trigger initialization again. + + + + + + + The initializer function must return &null; or no + value. + + + + + options + + + options can be a combination of the following + flags: + + + + ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE + + + + By default, serializing a lazy object triggers its + initialization. Setting this flag prevents initialization, allowing + lazy objects to be serialized without being initialized. + + + + + + + + + + + + &reftitle.returnvalues; + + Returns a lazy proxy instance. If the object has no properties, or if all its + properties are static or virtual, a normal (non-lazy) instance is returned. + See also + Lifecycle of Lazy + Objects). + + + + + &reftitle.errors; + + An Error if the class is internal or extends an + internal class except stdClass. + + + + + &reftitle.examples; + + Basic usage + +newLazyGhost(function (Example $object) { + $object->__construct(1); +}); + +var_dump($object); +var_dump($object instanceof Example); + +// Triggers initialization, and fetches the property after that +var_dump($object->prop); + +?> +]]> + + &example.outputs; + + + uninitialized(int) +} +bool(true) +Example::__construct +int(1) +]]> + + + + + + &reftitle.seealso; + + Lazy objects + ReflectionClass::newLazyProxy + ReflectionClass::newInstanceWithoutConstructor + ReflectionClass::resetAsLazyGhost + ReflectionClass::markLazyObjectAsInitialized + ReflectionClass::initializeLazyObject + ReflectionClass::isUninitializedLazyObject + ReflectionProperty::setRawValueWithoutLazyInitialization + ReflectionProperty::skipLazyInitialization + ReflectionProperty::isLazy + + + + + diff --git a/reference/reflection/reflectionclass/newlazyproxy.xml b/reference/reflection/reflectionclass/newlazyproxy.xml new file mode 100644 index 00000000000..049cb55975b --- /dev/null +++ b/reference/reflection/reflectionclass/newlazyproxy.xml @@ -0,0 +1,181 @@ + + + + + + + ReflectionClass::newLazyProxy + Creates a new lazy proxy instance + + + + &reftitle.description; + + public objectReflectionClass::newLazyProxy + callablefactory + intoptions0 + + + Creates a new lazy proxy instance of the class, attaching the + factory function to it. The constructor is not + called, and properties are not set to their default values. When an + attempt is made to observe or modify the proxy's state for the first + time, the factory function is called to provide a real instance, which + is then attached to the proxy. After this, all subsequent interactions + with the proxy are forwarded to the real instance. See + Initialization + Triggers and + Initialization Sequence. + + + + + &reftitle.parameters; + + + factory + + + The factory is a callback with the following signature: + + + + objectfactory + objectobject + + + + object + + + The object being initialized. At this point, + the object is no longer marked as lazy, and accessing it does not + trigger initialization again. + + + + + + + The factory function must return an object, referred to as the + real instance, which is then attached to the + proxy. This real instance must not be lazy and must not be the + proxy itself. If the real instance does not have the same class + as the proxy, the proxy's class must be a subclass of the real + instance's class, without additional properties, and must not override the + __destruct or __clone + methods. + + + + + + + + + + + + + &reftitle.returnvalues; + + Returns a lazy proxy instance. If the object has no properties, or if all its + properties are static or virtual, a normal (non-lazy) instance is returned. + See also + Lifecycle of Lazy + Objects). + + + + + + + + + &reftitle.examples; + + Basic usage + +newLazyProxy(function (Example $object) { + $realInstance = new Example(1); + return $realInstance; +}); + +var_dump($object); +var_dump($object instanceof Example); + +// Triggers initialization, and forwards the property fetch to the real instance +var_dump($object->prop); + +var_dump($object); +?> +]]> + + &example.outputs; + + + uninitialized(int) +} +bool(true) +Example::__construct +int(1) +lazy proxy object(Example)#3 (1) { + ["instance"]=> + object(Example)#4 (1) { + ["prop"]=> + int(1) + } +} +]]> + + + + + + &reftitle.seealso; + + Lazy objects + ReflectionClass::newLazyGhost + ReflectionClass::newInstanceWithoutConstructor + ReflectionClass::resetAsLazyProxy + ReflectionClass::markLazyObjectAsInitialized + ReflectionClass::initializeLazyObject + ReflectionClass::isUninitializedLazyObject + ReflectionProperty::setRawValueWithoutLazyInitialization + ReflectionProperty::skipLazyInitialization + ReflectionProperty::isLazy + + + + + diff --git a/reference/reflection/reflectionclass/resetaslazyghost.xml b/reference/reflection/reflectionclass/resetaslazyghost.xml new file mode 100644 index 00000000000..1cf2fddee63 --- /dev/null +++ b/reference/reflection/reflectionclass/resetaslazyghost.xml @@ -0,0 +1,170 @@ + + + + + + + ReflectionClass::resetAsLazyGhost + Resets an object and marks it as lazy + + + + &reftitle.description; + + public voidReflectionClass::resetAsLazyGhost + objectobject + callableinitializer + intoptions0 + + + Resets an existing object and marks it as lazy. + + + The object's destructor is called (if one exists) unless the + ReflectionClass::SKIP_DESTRUCTOR flag is specified. In + the special case where the object is an initialized proxy, the real instance + is detached from the proxy. If the real instance is no longer referenced + elsewhere, its destructor is called regardless of the + SKIP_DESTRUCTOR flag. + + + Dynamic properties are removed, and the value of properties declared on the + class is discarded as though unset was called, and + marked as lazy. This implies that if the object is an instance of a subclass + with additional properties, these properties are not modified and not made + lazy. + Readonly + properties are also not modified and not made lazy if they are + final or the class itself is final. + + + If no properties was marked lazy, the object is is not marked as lazy. See + also + Lazy Objects + Lifecycle. + + + Otherwise, after calling this method, the behavior of the object is the same + as an object created by + ReflectionClass::newLazyGhost (except for + subclass and readonly properties, as described above). + + + The object is not replaced by an other one, and its identity remains + unchanged. Functionality such as spl_object_id, + spl_object_hash, + SplObjectStorage, WeakMap, + WeakReference, or + the identity operator + (===) are unaffected. + + + + + &reftitle.parameters; + + + object + + + A non-lazy object, or an initialized lazy object. + + + + + initializer + + + An initializer callback with the same signature and purpose as in + ReflectionClass::newLazyGhost. + + + + + options + + + options can be a combination of the following + flags: + + + + ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE + + + + By default, serializing a lazy object triggers its + initialization. Setting this flag prevents initialization, allowing + lazy objects to be serialized without being initialized. + + + + + + ReflectionClass::SKIP_DESTRUCTOR + + + + By default, the object destructor is called (if any) before making it + lazy. This provides safety regarding any preexisting state in the + object. This flag disables that behavior, allowing objects to be reset + as lazy without calling the destructor. + + + + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.errors; + + A ReflectionException if the object is lazy and + non-initialized. + + + An Error if the object is being initialized, or if the + object properties are being iterated with + foreach. + + + + + &reftitle.seealso; + + ReflectionClass::newLazyGhost + ReflectionClass::resetAsLazyProxy + + + + + diff --git a/reference/reflection/reflectionclass/resetaslazyproxy.xml b/reference/reflection/reflectionclass/resetaslazyproxy.xml new file mode 100644 index 00000000000..4f9a331c854 --- /dev/null +++ b/reference/reflection/reflectionclass/resetaslazyproxy.xml @@ -0,0 +1,100 @@ + + + + + + + ReflectionClass::resetAsLazyProxy + Resets an object and marks it as lazy + + + + &reftitle.description; + + public voidReflectionClass::resetAsLazyProxy + objectobject + callablefactory + intoptions0 + + + The behavior of this method is the same as + ReflectionClass::resetAsLazyGhost except that it + uses the proxy strategy. + + + The object itself becomes the proxy. Similarly to + ReflectionClass::resetAsLazyGhost, the object is not + replaced by an other one, and its identity does not change, even after + initialization. The proxy and the real instance are distinct objects, with + distinct identities. + + + + + &reftitle.parameters; + + + object + + + A non-lazy object, or an initialized lazy object. + + + + + factory + + + An factory callback with the same signature and purpose as in + ReflectionClass::newLazyProxy. + + + + + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + + + + + &reftitle.seealso; + + ReflectionClass::newLazyProxy + ReflectionClass::resetAsLazyGhost + + + + + diff --git a/reference/reflection/reflectionproperty/islazy.xml b/reference/reflection/reflectionproperty/islazy.xml new file mode 100644 index 00000000000..9bd233e056d --- /dev/null +++ b/reference/reflection/reflectionproperty/islazy.xml @@ -0,0 +1,67 @@ + + + + ReflectionProperty::isLazy + Checks whether a property is lazy + + + + &reftitle.description; + + public boolReflectionProperty::isLazy + objectobject + + + Checks whether a property is lazy. + + + + + &reftitle.parameters; + + + object + + + The object to check the property on. + + + + + + + + &reftitle.returnvalues; + + Returns &true; if the property is lazy, &false; otherwise. + + + + + &reftitle.seealso; + + Lazy objects + + + + + diff --git a/reference/reflection/reflectionproperty/setrawvaluewithoutlazyinitialization.xml b/reference/reflection/reflectionproperty/setrawvaluewithoutlazyinitialization.xml new file mode 100644 index 00000000000..44751bf9d33 --- /dev/null +++ b/reference/reflection/reflectionproperty/setrawvaluewithoutlazyinitialization.xml @@ -0,0 +1,90 @@ + + + + + + + ReflectionProperty::setRawValueWithoutLazyInitialization + Set raw property value without triggering lazy initialization + + + + &reftitle.description; + + public voidReflectionProperty::setRawValueWithoutLazyInitialization + objectobject + mixednullvalue + + + Sets (changes) the property's value without triggering lazy initialization + and without calling hook functions. + The property is marked as non-lazy and can be accessed afterwards without + triggering lazy initialization. + The property must not be dynamic, static, or virtual, and the object must be + an instance of a user defined class or stdClass. + + + If this was the last lazy property, the object is marked as non-lazy and the + initializer or factory function is detached. + + + + + &reftitle.parameters; + + + object + + + The object to change the property on. + + + + + value + + + The new value. + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.seealso; + + Lazy objects + ReflectionProperty::skipLazyInitialization + ReflectionClass::newLazyGhost + + + + + diff --git a/reference/reflection/reflectionproperty/skiplazyinitialization.xml b/reference/reflection/reflectionproperty/skiplazyinitialization.xml new file mode 100644 index 00000000000..8bff2e12839 --- /dev/null +++ b/reference/reflection/reflectionproperty/skiplazyinitialization.xml @@ -0,0 +1,80 @@ + + + + + + + ReflectionProperty::skipLazyInitialization + Marks property as non-lazy + + + + &reftitle.description; + + public voidReflectionProperty::skipLazyInitialization + objectobject + + + Marks a property as non-lazy such that it can be accessed directly without + triggering lazy initialization. The property is initialized to its default + value, if any. + The property must not be dynamic, static, or virtual, and the object must be + an instance of a user defined class or stdClass. + + + If this was the last lazy property, the object is marked as non-lazy and the + initializer or factory function is detached. + + + + + &reftitle.parameters; + + + object + + + The object to mark the property on. + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.seealso; + + Lazy objects + ReflectionProperty::setRawValueWithoutLazyInitialization + ReflectionClass::newLazyGhost + + + + + From 30afbcd899535ba6e931fa831ed7ab04c03eed04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Sat, 9 Nov 2024 23:13:50 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[PHP=208.4]=20=E3=80=8C=E3=83=AC=E3=82=A4?= =?UTF-8?q?=E3=82=B8=E3=83=BC=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=80=8D=E3=81=AE=E7=BF=BB=E8=A8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- language/oop5/changelog.xml | 2 +- language/oop5/lazy-objects.xml | 399 +++++++++--------- reference/reflection/reflectionclass.xml | 8 +- .../reflectionclass/getlazyinitializer.xml | 14 +- .../reflectionclass/initializelazyobject.xml | 28 +- .../isuninitializedlazyobject.xml | 14 +- .../marklazyobjectasinitialized.xml | 45 +- .../reflectionclass/newlazyghost.xml | 62 +-- .../reflectionclass/newlazyproxy.xml | 62 +-- .../reflectionclass/resetaslazyghost.xml | 96 ++--- .../reflectionclass/resetaslazyproxy.xml | 36 +- .../reflection/reflectionproperty/islazy.xml | 10 +- .../setrawvaluewithoutlazyinitialization.xml | 24 +- .../skiplazyinitialization.xml | 20 +- 14 files changed, 407 insertions(+), 413 deletions(-) diff --git a/language/oop5/changelog.xml b/language/oop5/changelog.xml index 8623f27a3b1..aedfec37898 100644 --- a/language/oop5/changelog.xml +++ b/language/oop5/changelog.xml @@ -22,7 +22,7 @@ 8.4.0 - Added: Support for Lazy Objects. + レイジーオブジェクトがサポートされました。 diff --git a/language/oop5/lazy-objects.xml b/language/oop5/lazy-objects.xml index 25b88bf942b..d14fe076152 100644 --- a/language/oop5/lazy-objects.xml +++ b/language/oop5/lazy-objects.xml @@ -3,51 +3,49 @@ - Lazy Objects + レイジーオブジェクト - A lazy object is an object whose initialization is deferred until its - state is observed or modified. Some use-case examples include dependency - injection components that provide lazy services fully initialized only if - needed, ORMs providing lazy entities that hydrate - themselves from the database only when accessed, or a JSON parser that - delays parsing until elements are accessed. + レイジーオブジェクトは、状態が参照または変更されるまで + 初期化が遅延されるオブジェクトです。ユースケースの例として、 + 必要な時だけ初期化される遅延DIコンポーネント、 + 必要な時だけデータを読み込む遅延ORM、 + 必要な時だけ解析を行う遅延JSONパーサーなどがあります。 - Two lazy object strategies are supported: Ghost Objects and Virtual - Proxies, hereafter referred to as "lazy ghosts" and - "lazy proxies". - In both strategies, the lazy object is attached to an initializer or factory - that is called automatically when its state is observed or modified for - the first time. From an abstraction point of view, lazy ghost objects are - indistinguishable from non-lazy ones: they can be used without knowing they - are lazy, allowing them to be passed to and used by code that is unaware of - laziness. Lazy proxies are similarly transparent, but care must be taken when - their identity is used, as the proxy and its real instance have different - identities. + レイジーオブジェクトには、ゴーストオブジェクトとバーチャルプロキシの + 2つの戦略があります。以降 "レイジーゴースト"、 + "レイジープロキシ" と呼びます。 + どちらの戦略の場合も、レイジーオブジェクトには + 最初に状態が参照または変更されたときに自動的に呼び出されるイニシャライザまたはファクトリが + 接続されています。抽象的な観点では、レイジーゴーストオブジェクトは + 非レイジーなものと区別がつかず、レイジーであること意識せず使用できます。 + レイジープロキシも同様に透過的ですが、実体を + 参照する際は注意が必要です。プロキシと実インスタンスは異なる実体を + 持つからです。 - Creating Lazy Objects + レイジーオブジェクトの作成 - It is possible to create a lazy instance of any user defined class or the - stdClass class (other internal classes are not - supported), or to reset an instance of these classes to make it lazy. - The entry points for creating a lazy object are the - ReflectionClass::newLazyGhost and - ReflectionClass::newLazyProxy methods. + 任意のユーザー定義クラスやstdClassクラス + (他の内部クラスはサポートされていません)のレイジーインスタンスを作成したり、 + これらのクラスのインスタンスをレイジーにリセットすることが可能です。 + レイジーオブジェクトを作成するエントリーポイントは、 + ReflectionClass::newLazyGhostおよび + ReflectionClass::newLazyProxyメソッドです。 - Both methods accept a function that is called when the object requires - initialization. The function's expected behavior varies depending on the - strategy in use, as described in the reference documentation for each method. + どちらのメソッドも、オブジェクトの初期化が必要な際に呼び出される関数を + 受け取ります。その関数が要求する動作は、使用する戦略に応じて + 異なります。各メソッドのリファレンスを参照してください。 - Creating a Lazy Ghost + レイジーゴーストの作成 newLazyGhost(function (Example $object) { - // Initialize object in-place + // ここでオブジェクトを初期化 $object->__construct(1); }); var_dump($lazyObject); var_dump(get_class($lazyObject)); -// Triggers initialization +// ここで初期化がトリガーされる var_dump($lazyObject->prop); ?> ]]> @@ -88,7 +86,7 @@ int(1) - Creating a Lazy Proxy + レイジープロキシの作成 newLazyProxy(function (Example $object) { - // Create and return the real instance + // 実インスタンスを初期化して返す return new Example(1); }); var_dump($lazyObject); var_dump(get_class($lazyObject)); -// Triggers initialization +// ここで初期化がトリガーされる var_dump($lazyObject->prop); ?> ]]> @@ -129,14 +127,14 @@ int(1) - Any access to properties of a lazy object triggers its initialization - (including via ReflectionProperty). - However, certain properties might be known in advance and should not trigger - initialization when accessed: + レイジーオブジェクトのプロパティへのアクセスは、初期化をトリガーします + (ReflectionProperty 経由も含む)。 + しかし、特定のプロパティに対してはトリガーしないよう、 + 事前に初期化しておく必要があるかもしれません。 - Initializing Properties Eagerly + プロパティを事前に初期化する newLazyGhost(function ($post) { $post->__construct($data['id'], $data['title'], $data['content']); }); -// Without this line, the following call to ReflectionProperty::setValue() would -// trigger initialization. +// この行がないと、次のReflectionProperty::setValue()の呼び出しは +// 初期化をトリガーします。 $reflector->getProperty('id')->skipLazyInitialization($post); $reflector->getProperty('id')->setValue($post, 123); -// Alternatively, one can use this directly: +// または、直接以下を使用できます: $reflector->getProperty('id')->setRawValueWithoutLazyInitialization($post, 123); -// The id property can be accessed without triggering initialization +// 事前に設定したidプロパティは初期化をトリガーせずにアクセスできます var_dump($post->id); ?> ]]> @@ -172,313 +170,310 @@ var_dump($post->id); - The ReflectionProperty::skipLazyInitialization and + ReflectionProperty::skipLazyInitialization および ReflectionProperty::setRawValueWithoutLazyInitialization - methods offer ways to bypass lazy-initialization when accessing a property. + メソッドで、プロパティにアクセスする際の遅延初期化をバイパスできます。 - About Lazy Object Strategies + レイジーオブジェクトの戦略について - Lazy ghosts are objects that initialize in-place and, - once initialized, are indistinguishable from an object that was never lazy. - This strategy is suitable when we control both the instantiation and - initialization of the object, making it unsuitable if either of these is - managed by another party. + レイジーゴーストは、その場で初期化され、 + 初期化後はレイジーでないオブジェクトと区別がつきません。 + この戦略は、オブジェクトのインスタンス化と初期化の両方を + 制御できる場合に適しています。どちらかを制御出来ない場合は + 適していません。 - Lazy proxies, once initialized, act as proxies to - a real instance: any operation on an initialized lazy proxy is forwarded - to the real instance. The creation of the real instance can be delegated - to another party, making this strategy useful in cases where lazy ghosts - are unsuitable. Although lazy proxies are nearly as transparent as lazy - ghosts, caution is needed when their identity is used, as the proxy and - its real instance have distinct identities. + レイジープロキシは、初期化後、実インスタンスへの + プロキシとして機能します。初期化されたレイジープロキシ上のあらゆる操作は、 + 実インスタンスに転送されます。この戦略は、インスタンスの作成を + 外部に委ねているなど、レイジーゴーストが適さない場合に + 適しています。レイジープロキシはほぼ透過的ですが、インスタンスの実体を + 使用する場合は注意が必要です。プロキシと実インスタンスは異なる + 実体を持つからです。 - Lifecycle of Lazy Objects + レイジーオブジェクトのライフサイクル - Objects can be made lazy at instantiation time using - ReflectionClass::newLazyGhost or - ReflectionClass::newLazyProxy, or after - instantiation by using - ReflectionClass::resetAsLazyGhost or - ReflectionClass::resetAsLazyProxy. Following this, a - lazy object can become initialized through one of the following operations: + オブジェクトは、インスタンス化時に + ReflectionClass::newLazyGhostまたは + ReflectionClass::newLazyProxyを使用して、 + あるいはインスタンス化後に + ReflectionClass::resetAsLazyGhostまたは + ReflectionClass::resetAsLazyProxyを使用して、 + レイジーにできます。その後、以下のいずれかの操作により初期化されます: - Interacting with the object in a way that triggers automatic initialization. See - Initialization - triggers. + 自動初期化をトリガーする方法でオブジェクトと対話する。 + 初期化トリガーを + 参照してください。 - Marking all its properties as non-lazy using - ReflectionProperty::skipLazyInitialization or - ReflectionProperty::setRawValueWithoutLazyInitialization. + ReflectionProperty::skipLazyInitializationまたは + ReflectionProperty::setRawValueWithoutLazyInitializationを使用して、 + すべてのプロパティを非レイジーとしてマークする。 - Calling explicitly ReflectionClass::initializeLazyObject - or ReflectionClass::markLazyObjectAsInitialized. + ReflectionClass::initializeLazyObjectまたは + ReflectionClass::markLazyObjectAsInitializedを + 明示的に呼び出す。 - As lazy objects become initialized when all their properties are marked - non-lazy, the above methods will not mark an object as lazy if no properties - could be marked as lazy. + すべてのプロパティが非レイジーとしてマークされると、レイジーオブジェクトは + 初期化済とみなされます。従って上記のメソッドは、非レイジーなプロパティがない場合、 + オブジェクトをレイジーとみなしません。 - Initialization Triggers + 初期化トリガー - Lazy objects are designed to be fully transparent to their consumers, - so normal operations that observe or modify the object's state will - automatically trigger initialization before the operation is performed. This - includes, but is not limited to, the following operations: + レイジーオブジェクトは、利用者に対して透過的に設計されているため、 + オブジェクトの状態を参照または変更する通常の操作は、 + その実行の前に自動的に初期化をトリガーします。これには以下の操作が含まれますが、 + これらに限定されません: - Reading or writing a property. + プロパティの読み取りまたは書き込み。 - Testing if a property is set or unsetting it. + プロパティが設定されているかテスト、またはプロパティの削除。 - Accessing or modifying a property via - ReflectionProperty::getValue, - ReflectionProperty::getRawValue, - ReflectionProperty::setValue, - or ReflectionProperty::setRawValue. + ReflectionProperty::getValue、 + ReflectionProperty::getRawValue、 + ReflectionProperty::setValue、 + ReflectionProperty::setRawValue + によるプロパティの参照または変更。 - Listing properties with - ReflectionObject::getProperties, - ReflectionObject::getProperty, - get_object_vars. + ReflectionObject::getProperties、 + ReflectionObject::getProperty、 + get_object_vars + によるプロパティの取得。 - Iterating over properties of an object that does not implement - Iterator or - IteratorAggregate using - foreach. + Iteratorや + IteratorAggregateを + 実装していないオブジェクトを + foreachでイテレーション。 - Serializing the object with serialize, - json_encode, etc. + serialize、 + json_encodeなどでシリアライズ。 - Cloning the - object. + クローンの作成。 - Method calls that do not access the object state will not trigger - initialization. Similarly, interactions with the object that invoke magic - methods or hook functions will not trigger initialization if these methods - or functions do not access the object's state. + オブジェクトの状態にアクセスしないメソッド呼び出しは初期化を + トリガーしません。同様に、マジックメソッドやフック関数を呼び出す + オブジェクトとの対話も、これらのメソッドや関数がオブジェクトの状態に + アクセスしない限りトリガーしません。 - Non-Triggering Operations + 初期化をトリガーしない操作 - The following specific methods or low-level operations allow access or - modification of lazy objects without triggering initialization: + 以下の特定のメソッドや低レベルの操作は、初期化をトリガーせずにレイジー + オブジェクトへのアクセスや変更を可能にします: - Marking properties as non-lazy with - ReflectionProperty::skipLazyInitialization or - ReflectionProperty::setRawValueWithoutLazyInitialization. + ReflectionProperty::skipLazyInitialization や + ReflectionProperty::setRawValueWithoutLazyInitialization + でプロパティを非レイジーとしてマーク。 - Retrieving the internal representation of properties using - get_mangled_object_vars or by - casting the object to an - array. + get_mangled_object_vars や、 + 配列への変換による + プロパティ内部表現の取得。 - Using serialize when ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE - is set, unless - __serialize() or - __sleep() trigger initialization. + が設定された状態での serialize 。 + ただし __serialize() または + __sleep() が初期化をトリガーしない場合。 - Calling to ReflectionObject::__toString. + ReflectionObject::__toString の呼び出し。 - Using var_dump or - debug_zval_dump, unless - __debugInfo() triggers - initialization. + var_dump または + debug_zval_dump 。ただし、 + __debugInfo() が初期化をトリガー + しない場合に限る。 - Initialization Sequence + 初期化シーケンス - This section outlines the sequence of operations performed when - initialization is triggered, based on the strategy in use. + このセクションでは、初期化がトリガーされたときに実行される操作の順序を + 使用する戦略に応じて説明します。 - Ghost Objects + ゴーストオブジェクト - The object is marked as non-lazy. + オブジェクトは非レイジーとしてマークされます。 - Properties not initialized with - ReflectionProperty::skipLazyInitialization or + ReflectionProperty::skipLazyInitializationまたは ReflectionProperty::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. + 初期化後、オブジェクトはレイジーでない場合と + 区別がつきません。 - Proxy Objects + プロキシオブジェクト - The object is marked as non-lazy. + オブジェクトは非レイジーとしてマークされます。 - Unlike ghost objects, the properties of the object are not modified at - this stage. + ゴーストオブジェクトとは異なり、この段階でオブジェクトのプロパティは + 変更されません。 - The factory function is called with the object as its first parameter and - must return a non-lazy instance of a compatible class (see - ReflectionClass::newLazyProxy). + オブジェクトがファクトリ関数に入力されます。 + この関数は、互換性のあるクラスの非レイジーなインスタンスを返す必要があります + (ReflectionClass::newLazyProxyを参照)。 - The returned instance is referred to as the real - instance and is attached to the proxy. + 返されたインスタンスは 実インスタンス として参照され、 + プロキシに接続されます。 - The proxy's property values are discarded as though - unset was called. + プロキシのプロパティ値は、 + unset と同等の方法で破棄されます。 - After initialization, accessing any property on the proxy will - yield the same result as accessing the corresponding property on - the real instance; all property accesses on the proxy are forwarded - to the real instance, including declared, dynamic, non-existing, or - properties marked with - ReflectionProperty::skipLazyInitialization or - ReflectionProperty::setRawValueWithoutLazyInitialization. + 初期化後、プロキシの任意のプロパティへのアクセスは、 + 実インスタンスへのアクセスと同じ結果をもたらします。 + 宣言済プロパティ、動的プロパティ、存在しないプロパティ、 + ReflectionProperty::skipLazyInitialization や + ReflectionProperty::setRawValueWithoutLazyInitialization で + マークされたプロパティを含む、すべてのプロパティへのアクセスは + 実インスタンスに転送されます。 - The proxy object itself is not replaced or substituted - for the real instance. + プロキシオブジェクトが、 + 実インスタンスに置き換えられることはありません - While the factory receives the proxy as its first parameter, it is - not expected to modify it (modifications are allowed but will be lost - during the final initialization step). However, the proxy can be used - for decisions based on the values of initialized properties, the class, - the object itself, or its identity. For instance, the initializer might - use an initialized property's value when creating the real instance. + ファクトリは最初のパラメータとしてプロキシを受け取りますが、 + それを変更することは期待されていません(変更は許可されますが、 + 最終的な初期化ステップ中に失われます)。しかし、プロキシは + 事前に初期化されたプロパティの値、クラス、オブジェクト自体、 + その同一性に基づく決定に使用できます。例えば、イニシャライザは + 実インスタンスを作成する際に初期化されたプロパティの値を利用するかもしれません。 - Common Behavior + 共通の動作 - The scope and $this context of the initializer or factory - function remains unchanged, and usual visibility constraints apply. + イニシャライザまたはファクトリ関数のスコープと$thisの + コンテキストは変更されず、通常の可視性制約が適用されます。 - After successful initialization, the initializer or factory function - is no longer referenced by the object and may be released if it has no - other references. + 初期化が成功した後、イニシャライザまたはファクトリ関数は + オブジェクトから参照されなくなり、他に参照がなければ + 解放される場合があります。 - If the initializer throws an exception, the object state is reverted to its - pre-initialization state and the object is marked as lazy again. In other - words, all effects on the object itself are reverted. Other side effects, - such as effects on other objects, are not reverted. This prevents - exposing a partially initialized instance in case of failure. + イニシャライザが例外をスローした場合、オブジェクトの状態は + 初期化前の状態に戻され、オブジェクトは再びレイジーとマークされます。つまり、 + オブジェクトへの副作用はすべて破棄されます。これは、失敗した場合に + 壊れたインスタンスが生成されてしまうのを防ぎます。ただし、他のオブジェクトへの + 影響など、外部への副作用は元に戻されません。 - Cloning + クローン - Cloning - a lazy object triggers its initialization before the clone is - created, resulting in an initialized object. + レイジーオブジェクトをクローンすると、 + クローンが作成される前に初期化がトリガーされ、 + 結果として初期化されたオブジェクトが得られます。 - For proxy objects, both the proxy and its real instance are cloned, and - the clone of the proxy is returned. - The __clone method - is called on the real instance, not on the proxy. - The cloned proxy and real instance are linked as they are during - initialization, so accesses to the proxy clone are forwarded to the real - instance clone. + プロキシオブジェクトの場合、プロキシとその実インスタンスの両方がクローンされ、 + プロキシのクローンが返されます。 + __cloneメソッドは + プロキシではなく実インスタンス上で呼び出されます。 + クローンされたプロキシと実インスタンスは + 初期化時にリンクされるため、クローン後のプロキシへのアクセスは + クローン後の実インスタンスに転送されます。 - This behavior ensures that the clone and the original object maintain - separate states. Changes to the original object or its initializer's state - after cloning do not affect the clone. Cloning both the proxy and its real - instance, rather than returning a clone of the real instance alone, ensures - that the clone operation consistently returns an object of the same class. + この動作により、クローンと元のオブジェクトは独立した状態を持つことが + 保証されます。クローン後に元のオブジェクトまたはそのイニシャライザの状態に + 変更を加えても、クローンには影響しません。実インスタンスのみではなく + 両方をクローンすることで、クローン操作は常に同じクラスのオブジェクトを + 返すことを保証します。 - Destructors + デストラクタ - For lazy ghosts, the destructor is only called if the object has been - initialized. For proxies, the destructor is only called on the real instance, - if one exists. + レイジーゴーストの場合、オブジェクトが初期化されている場合のみ、 + プロキシの場合、実インスタンスが存在する場合のみ、 + デストラクタが呼び出されます。 - The ReflectionClass::resetAsLazyGhost and - ReflectionClass::resetAsLazyProxy methods may invoke - the destructor of the object being reset. + ReflectionClass::resetAsLazyGhostおよび + ReflectionClass::resetAsLazyProxyメソッドは、 + リセットされるオブジェクトのデストラクタを呼び出す場合があります。 diff --git a/reference/reflection/reflectionclass.xml b/reference/reflection/reflectionclass.xml index def865370b1..8194f5a9505 100644 --- a/reference/reflection/reflectionclass.xml +++ b/reference/reflection/reflectionclass.xml @@ -157,8 +157,8 @@ ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE - Indicates that serialize should not trigger - initialization of a lazy object. + serializeがレイジーオブジェクトの初期化を + トリガーしないことを示します。 @@ -167,8 +167,8 @@ ReflectionClass::SKIP_DESTRUCTOR - Indicates an object destructor should not be called when resetting it as - lazy. + オブジェクトをレイジーにリセットする時に、 + デストラクタが呼び出されないことを示します。 diff --git a/reference/reflection/reflectionclass/getlazyinitializer.xml b/reference/reflection/reflectionclass/getlazyinitializer.xml index 1b8195a4465..b6c38e6d3db 100644 --- a/reference/reflection/reflectionclass/getlazyinitializer.xml +++ b/reference/reflection/reflectionclass/getlazyinitializer.xml @@ -5,7 +5,7 @@ ReflectionClass::getLazyInitializer - Gets lazy initializer + レイジーイニシャライザを取得する @@ -15,8 +15,8 @@ objectobject - Gets the lazy initializer or factory attached to - object. + objectに + アタッチされているレイジーイニシャライザまたはファクトリを取得します。 @@ -27,7 +27,7 @@ object - The object from which to get the initializer. + イニシャライザを取得する対象のオブジェクト。 @@ -37,15 +37,15 @@ &reftitle.returnvalues; - Returns the initializer if the object is an uninitialized lazy - object, &null; otherwise. + オブジェクトが未初期化のレイジーオブジェクトであればイニシャライザを、 + そうでなければ &null; を返します。 &reftitle.seealso; - Lazy objects + レイジーオブジェクト ReflectionClass::newLazyGhost diff --git a/reference/reflection/reflectionclass/initializelazyobject.xml b/reference/reflection/reflectionclass/initializelazyobject.xml index b3034bf3aa9..c585fae1f59 100644 --- a/reference/reflection/reflectionclass/initializelazyobject.xml +++ b/reference/reflection/reflectionclass/initializelazyobject.xml @@ -5,7 +5,7 @@ ReflectionClass::initializeLazyObject - Forces initialization of a lazy object + レイジーオブジェクトを強制的に初期化する @@ -15,18 +15,18 @@ objectobject - Forces initialization of the specified object. This - method has no effect if the object is not lazy or has already been - initialized. Otherwise, initialization proceeds as described in the - Initialization - Sequence. + 指定されたobjectを強制的に初期化します。この + メソッドは、オブジェクトがレイジーでないか、既に初期化されている場合は + 効果がありません。それ以外の場合、初期化は + 初期化シーケンス + の通り進行します。 - In most cases, calling this method is unnecessary, as lazy objects - initialize themselves automatically when their state is observed or - modified. + ほとんどの場合、このメソッドを呼び出す必要はありません。なぜなら、 + レイジーオブジェクトはその状態が参照または変更されたときに + 自動的に初期化されるからです。 @@ -38,7 +38,7 @@ object - The object to initialize. + 初期化するオブジェクト。 @@ -48,15 +48,15 @@ &reftitle.returnvalues; - If object is a lazy proxy, returns its real instance. - Otherwise, returns object itself. + objectがレイジープロキシであれば、 + その実インスタンスを、そうでなければ object自身を返します。 &reftitle.examples; - Basic usage + 基本的な使用法 &reftitle.seealso; - Lazy objects + レイジーオブジェクト ReflectionClass::newLazyGhost ReflectionClass::markLazyObjectAsInitialized ReflectionClass::isUninitializedLazyObject diff --git a/reference/reflection/reflectionclass/isuninitializedlazyobject.xml b/reference/reflection/reflectionclass/isuninitializedlazyobject.xml index 8755dc172ee..f33a72b13b7 100644 --- a/reference/reflection/reflectionclass/isuninitializedlazyobject.xml +++ b/reference/reflection/reflectionclass/isuninitializedlazyobject.xml @@ -5,7 +5,7 @@ ReflectionClass::isUninitializedLazyObject - Checks if an object is lazy and uninitialized + オブジェクトがレイジーで未初期化かどうかを調べる @@ -15,7 +15,7 @@ objectobject - Checks if an object is lazy and uninitialized. + オブジェクトがレイジーで未初期化かどうかを調べます。 @@ -26,7 +26,7 @@ object - The object to check. + 調べるオブジェクト。 @@ -36,15 +36,15 @@ &reftitle.returnvalues; - Returns &true; if object is an uninitialized lazy - object, &false; otherwise. + object が未初期化のレイジーオブジェクトであれば &true; を、 + そうでなければ &false; を返します。 &reftitle.examples; - Basic usage + 基本的な使用法 &reftitle.seealso; - Lazy objects + レイジーオブジェクト ReflectionClass::newLazyGhost ReflectionClass::markLazyObjectAsInitialized ReflectionClass::initializeLazyObject diff --git a/reference/reflection/reflectionclass/marklazyobjectasinitialized.xml b/reference/reflection/reflectionclass/marklazyobjectasinitialized.xml index bd3baede895..389965842b8 100644 --- a/reference/reflection/reflectionclass/marklazyobjectasinitialized.xml +++ b/reference/reflection/reflectionclass/marklazyobjectasinitialized.xml @@ -5,7 +5,7 @@ ReflectionClass::markLazyObjectAsInitialized - Marks a lazy object as initialized without calling the initializer or factory + イニシャライザまたはファクトリを呼び出さずレイジーオブジェクトを初期化済みとしてマークする @@ -15,21 +15,20 @@ objectobject - Marks a lazy object as initialized without calling the initializer or - factory. This has no effect if object is not lazy or - is already initialized. + イニシャライザまたはファクトリを呼び出さずレイジーオブジェクトを + 初期化済みとしてマークします。object がレイジーでないか、 + すでに初期化されている場合、このメソッドは効果がありません。 - The effect of calling this method is the same as described for Ghost Objects - (regardless of the laziness strategy of object) in - initialization - sequence, except that the initializer is not called. - After that, the object is indistinguishable from an object that was never - lazy and was created with - ReflectionClass::newInstanceWithoutConstructor, - except for the value of properties that were already initialized with - ReflectionProperty::setRawValueWithoutLazyInitialization - or ReflectionProperty::skipLazyInitialization. + このメソッド動作は、object のレイジー戦略に関わらず、 + 初期化シーケンス + においてゴーストオブジェクトに対して説明されたものとほぼ同じですが、 + イニシャライザが呼び出されない点を除きます。 + その後、オブジェクトは、ReflectionProperty::setRawValueWithoutLazyInitialization または + ReflectionProperty::skipLazyInitialization で + 既に初期化されたプロパティの値を除いて、 + ReflectionClass::newInstanceWithoutConstructor で作成された、 + 元々レイジーでなかったオブジェクトと区別がつかなくなります。 @@ -40,7 +39,7 @@ object - The object to mark as initialized. + 初期化済みとしてマークするオブジェクト。 @@ -50,14 +49,14 @@ &reftitle.returnvalues; - Returns object. + object を返します。 &reftitle.examples; - Marking an uninitialized lazy object as initialized + 未初期化のレイジーオブジェクトを初期化済みとしてマークする - Marking an initialized object as initialized + 既に初期化されたオブジェクトを初期化済みとしてマークする markLazyObjectAsInitialized($object); var_dump($object); ?> -]]> - - &example.outputs; - + ]]> + + &example.outputs; + &reftitle.seealso; - Lazy objects + レイジーオブジェクト ReflectionClass::newLazyGhost ReflectionClass::initializeLazyObject ReflectionClass::isUninitializedLazyObject diff --git a/reference/reflection/reflectionclass/newlazyghost.xml b/reference/reflection/reflectionclass/newlazyghost.xml index d133e7dc1ec..54cbbeff7d7 100644 --- a/reference/reflection/reflectionclass/newlazyghost.xml +++ b/reference/reflection/reflectionclass/newlazyghost.xml @@ -5,7 +5,7 @@ ReflectionClass::newLazyGhost - Creates a new lazy ghost instance + 新しいレイジーゴーストインスタンスを作成する @@ -16,15 +16,14 @@ intoptions0 - Creates a new lazy ghost instance of the class, attaching the - initializer to it. The constructor is not called, and - properties are not set to their default value. However, the object will - be automatically initialized by invoking the - initializer the first time its state is observed or - modified. See - Initialization - Triggers and - Initialization Sequence. + クラスの新しいレイジーゴーストインスタンスを作成し、 + initializer をアタッチします。コンストラクタは呼び出されず、 + プロパティはデフォルト値に設定されません。オブジェクトの状態を + 初めて参照または変更する時に、 + initializerをにより自動的に初期化されます。 + 初期化トリガーおよび + 初期化シーケンス + を参照してください。 @@ -35,7 +34,7 @@ initializer - The initializer is a callback with the following signature: + イニシャライザは以下のシグネチャを持つコールバックです: @@ -47,17 +46,17 @@ object - The object being initialized. At this point, - the object is no longer marked as lazy, and accessing it does not - trigger initialization again. + 初期化されるobject。この時点では、 + オブジェクトはもはやレイジーとしてマークされておらず、 + アクセスしても再び初期化がトリガーされることはありません。 - The initializer function must return &null; or no - value. + initializer関数は &null; を返すか、 + 値を返さない必要があります。 @@ -65,8 +64,8 @@ options - options can be a combination of the following - flags: + optionsには以下のフラグを組み合わせて + 指定できます: @@ -74,9 +73,9 @@ - By default, serializing a lazy object triggers its - initialization. Setting this flag prevents initialization, allowing - lazy objects to be serialized without being initialized. + デフォルトでは、レイジーオブジェクトのシリアライズは + 初期化がトリガーされます。このフラグを設定すると、 + 初期化せずにシリアライズできるようになります。 @@ -90,26 +89,26 @@ &reftitle.returnvalues; - Returns a lazy proxy instance. If the object has no properties, or if all its - properties are static or virtual, a normal (non-lazy) instance is returned. - See also - Lifecycle of Lazy - Objects). + レイジーゴーストインスタンスを返します。オブジェクトにプロパティがない場合、または + そのプロパティがすべてstaticまたはvirtualの場合、通常の(レイジーではない)インスタンスが + 返されます。 + レイジーオブジェクトの + ライフサイクルも参照してください。 &reftitle.errors; - An Error if the class is internal or extends an - internal class except stdClass. + クラスが内部クラスであるか、stdClassを除く内部クラスを + 拡張している場合、Errorをスローします。 &reftitle.examples; - Basic usage + 基本的な使用法 newLazyGhost(function (Example $object) { var_dump($object); var_dump($object instanceof Example); -// Triggers initialization, and fetches the property after that +// 初期化をトリガーし、その後プロパティを取得します var_dump($object->prop); ?> @@ -152,7 +151,7 @@ int(1) &reftitle.seealso; - Lazy objects + レイジーオブジェクト ReflectionClass::newLazyProxy ReflectionClass::newInstanceWithoutConstructor ReflectionClass::resetAsLazyGhost @@ -186,3 +185,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> + diff --git a/reference/reflection/reflectionclass/newlazyproxy.xml b/reference/reflection/reflectionclass/newlazyproxy.xml index 049cb55975b..a64bc5827a3 100644 --- a/reference/reflection/reflectionclass/newlazyproxy.xml +++ b/reference/reflection/reflectionclass/newlazyproxy.xml @@ -5,7 +5,7 @@ ReflectionClass::newLazyProxy - Creates a new lazy proxy instance + 新しいレイジープロキシインスタンスを作成する @@ -16,16 +16,16 @@ intoptions0 - Creates a new lazy proxy instance of the class, attaching the - factory function to it. The constructor is not - called, and properties are not set to their default values. When an - attempt is made to observe or modify the proxy's state for the first - time, the factory function is called to provide a real instance, which - is then attached to the proxy. After this, all subsequent interactions - with the proxy are forwarded to the real instance. See - Initialization - Triggers and - Initialization Sequence. + クラスの新しいレイジープロキシインスタンスを作成し、 + factory をアタッチします。コンストラクタは呼び出されず、 + プロパティはデフォルト値に設定されません。プロキシの状態を + 初めて参照または変更する時に、 + ファクトリ関数により実インスタンスが初期化され、 + プロキシにアタッチされます。その後、プロキシとのすべての対話は + 実インスタンスに転送されます。 + 初期化トリガーおよび + 初期化シーケンス + を参照してください。 @@ -36,7 +36,7 @@ factory - The factory is a callback with the following signature: + ファクトリは以下のシグネチャを持つコールバックです: @@ -48,23 +48,23 @@ object - The object being initialized. At this point, - the object is no longer marked as lazy, and accessing it does not - trigger initialization again. + 初期化されるobject。この時点では、 + オブジェクトはもはやレイジーとしてマークされておらず、 + アクセスしても再び初期化がトリガーされることはありません。 - The factory function must return an object, referred to as the - real instance, which is then attached to the - proxy. This real instance must not be lazy and must not be the - proxy itself. If the real instance does not have the same class - as the proxy, the proxy's class must be a subclass of the real - instance's class, without additional properties, and must not override the - __destruct or __clone - methods. + ファクトリ関数は、実インスタンスとして参照される + オブジェクトを返す必要があり、それがプロキシにアタッチされます。 + この実インスタンスはレイジーであってはならず、 + プロキシ自体でもあってはなりません。もし実インスタンスが + プロキシと同じクラスでない場合、プロキシのクラスは実インスタンスのクラスの + サブクラスでなければならず、追加のプロパティを持ってはならず、 + __destruct__cloneメソッドを + オーバーライドしてはいけまさん。 @@ -79,11 +79,11 @@ &reftitle.returnvalues; - Returns a lazy proxy instance. If the object has no properties, or if all its - properties are static or virtual, a normal (non-lazy) instance is returned. - See also - Lifecycle of Lazy - Objects). + レイジープロキシインスタンスを返します。オブジェクトにプロパティがない場合、または + そのプロパティがすべてstaticまたはvirtualの場合、通常の(レイジーではない)インスタンスが + 返されます。 + レイジーオブジェクトの + ライフサイクルも参照してください。 @@ -94,7 +94,7 @@ &reftitle.examples; - Basic usage + 基本的な使用法 newLazyProxy(function (Example $object) { var_dump($object); var_dump($object instanceof Example); -// Triggers initialization, and forwards the property fetch to the real instance +// 初期化をトリガーし、プロパティの取得を実インスタンスに転送します var_dump($object->prop); var_dump($object); @@ -145,7 +145,7 @@ lazy proxy object(Example)#3 (1) { &reftitle.seealso; - Lazy objects + レイジーオブジェクト ReflectionClass::newLazyGhost ReflectionClass::newInstanceWithoutConstructor ReflectionClass::resetAsLazyProxy diff --git a/reference/reflection/reflectionclass/resetaslazyghost.xml b/reference/reflection/reflectionclass/resetaslazyghost.xml index 1cf2fddee63..9ef8163c354 100644 --- a/reference/reflection/reflectionclass/resetaslazyghost.xml +++ b/reference/reflection/reflectionclass/resetaslazyghost.xml @@ -5,7 +5,7 @@ ReflectionClass::resetAsLazyGhost - Resets an object and marks it as lazy + オブジェクトをリセットしてレイジーとしてマークする @@ -17,46 +17,46 @@ intoptions0 - Resets an existing object and marks it as lazy. + 既存のobjectをリセットし、レイジーとしてマークします。 - The object's destructor is called (if one exists) unless the - ReflectionClass::SKIP_DESTRUCTOR flag is specified. In - the special case where the object is an initialized proxy, the real instance - is detached from the proxy. If the real instance is no longer referenced - elsewhere, its destructor is called regardless of the - SKIP_DESTRUCTOR flag. + オブジェクトのデストラクタが存在する場合、 + ReflectionClass::SKIP_DESTRUCTORフラグが指定されていない限り、 + デストラクタが呼び出されます。特殊なケースとして、オブジェクトが初期済のプロキシの場合、 + 実インスタンスはプロキシから切り離されます。実インスタンスが他で参照されていない場合、 + SKIP_DESTRUCTORフラグに関係なく、 + そのデストラクタが呼び出されます。 - Dynamic properties are removed, and the value of properties declared on the - class is discarded as though unset was called, and - marked as lazy. This implies that if the object is an instance of a subclass - with additional properties, these properties are not modified and not made - lazy. - Readonly - properties are also not modified and not made lazy if they are - final or the class itself is final. + 動的プロパティは削除され、クラスで宣言されたプロパティの値は + unset と同等の方法で破棄され、 + レイジーとしてマークされます。これは、オブジェクトが追加のプロパティを持つ + サブクラスのインスタンスである場合、これらのプロパティは変更されず、 + レイジーにもならないことを意味します。 + 読み取り専用プロパティも、 + finalであるかクラス自体がfinalである場合、 + 変更されず、レイジーにもなりません。 - If no properties was marked lazy, the object is is not marked as lazy. See - also - Lazy Objects - Lifecycle. + レイジーとしてマークされたプロパティがない場合、オブジェクトはレイジーとしてマークされません。 + レイジーオブジェクトのライフサイクル + も参照してください。 - Otherwise, after calling this method, the behavior of the object is the same - as an object created by - ReflectionClass::newLazyGhost (except for - subclass and readonly properties, as described above). + それ以外の場合、このメソッドを呼び出した後、 + オブジェクトの動作は + ReflectionClass::newLazyGhostによって作成されたオブジェクトと同じになります + (上記で説明したサブクラスと読み取り専用プロパティを除く)。 - The object is not replaced by an other one, and its identity remains - unchanged. Functionality such as spl_object_id, - spl_object_hash, - SplObjectStorage, WeakMap, - WeakReference, or - the identity operator - (===) are unaffected. + オブジェクトは他のものに置き換えられず、その同一性は変わりません。 + spl_object_id、 + spl_object_hash、 + SplObjectStorage、 + WeakMap、 + WeakReference、または + 一致演算子 + (===)などの機能は影響を受けません。 @@ -67,7 +67,7 @@ object - A non-lazy object, or an initialized lazy object. + 非レイジーなオブジェクト、または初期化されたレイジーオブジェクト。 @@ -75,8 +75,8 @@ initializer - An initializer callback with the same signature and purpose as in - ReflectionClass::newLazyGhost. + ReflectionClass::newLazyGhost + と同じシグネチャと目的を持つイニシャライザコールバック。 @@ -84,8 +84,8 @@ options - options can be a combination of the following - flags: + optionsには + 以下のフラグを組み合わせて指定できます: @@ -93,9 +93,9 @@ - By default, serializing a lazy object triggers its - initialization. Setting this flag prevents initialization, allowing - lazy objects to be serialized without being initialized. + デフォルトでは、レイジーオブジェクトのシリアライズは + 初期化がトリガーされます。このフラグを設定すると、 + 初期化せずにシリアライズできるようになります。 @@ -105,10 +105,10 @@ - By default, the object destructor is called (if any) before making it - lazy. This provides safety regarding any preexisting state in the - object. This flag disables that behavior, allowing objects to be reset - as lazy without calling the destructor. + デフォルトでは、オブジェクトをレイジーにする前に、そのデストラクタが(存在すれば) + 呼び出されます。これは、オブジェクト内の既存の状態に関する安全性を提供します。 + このフラグはその動作を無効にし、デストラクタを呼び出さずにオブジェクトを + レイジーとしてリセットできるようにします。 @@ -129,13 +129,13 @@ &reftitle.errors; - A ReflectionException if the object is lazy and - non-initialized. + オブジェクトがレイジーで未初期化の場合、ReflectionExceptionを + スローします。 - An Error if the object is being initialized, or if the - object properties are being iterated with - foreach. + オブジェクトが初期化中である場合、またはforeachで + プロパティが反復処理されている場合、Errorを + スローします。 diff --git a/reference/reflection/reflectionclass/resetaslazyproxy.xml b/reference/reflection/reflectionclass/resetaslazyproxy.xml index 4f9a331c854..197cc3f14a0 100644 --- a/reference/reflection/reflectionclass/resetaslazyproxy.xml +++ b/reference/reflection/reflectionclass/resetaslazyproxy.xml @@ -5,9 +5,9 @@ ReflectionClass::resetAsLazyProxy - Resets an object and marks it as lazy + オブジェクトをリセットしてレイジーとしてマークする - + &reftitle.description; @@ -17,19 +17,19 @@ intoptions0 - The behavior of this method is the same as - ReflectionClass::resetAsLazyGhost except that it - uses the proxy strategy. + このメソッドの動作は、 + ReflectionClass::resetAsLazyGhostと同じですが、 + プロキシ戦略を使用します。 - The object itself becomes the proxy. Similarly to - ReflectionClass::resetAsLazyGhost, the object is not - replaced by an other one, and its identity does not change, even after - initialization. The proxy and the real instance are distinct objects, with - distinct identities. + object自体がプロキシになります。 + ReflectionClass::resetAsLazyGhostと同様に、 + オブジェクトは他のものに置き換えられず、初期化後もその同一性は + 変わりません。プロキシと実インスタンスは別々のオブジェクトであり、 + 別々の実体を持ちます。 - + &reftitle.parameters; @@ -37,7 +37,7 @@ object - A non-lazy object, or an initialized lazy object. + 非レイジーなオブジェクト、または初期化されたレイジーオブジェクト。 @@ -45,8 +45,8 @@ factory - An factory callback with the same signature and purpose as in - ReflectionClass::newLazyProxy. + ReflectionClass::newLazyProxyと + 同じシグネチャと目的を持つファクトリコールバック。 @@ -57,18 +57,18 @@ - + &reftitle.returnvalues; &return.void; - + - + &reftitle.seealso; @@ -76,7 +76,7 @@ ReflectionClass::resetAsLazyGhost - +