<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionclass.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'reflectionclass.newlazyproxy.php',
    1 => 'ReflectionClass::newLazyProxy',
    2 => 'Creates a new lazy proxy instance',
  ),
  'up' => 
  array (
    0 => 'class.reflectionclass.php',
    1 => 'ReflectionClass',
  ),
  'prev' => 
  array (
    0 => 'reflectionclass.newlazyghost.php',
    1 => 'ReflectionClass::newLazyGhost',
  ),
  'next' => 
  array (
    0 => 'reflectionclass.resetaslazyghost.php',
    1 => 'ReflectionClass::resetAsLazyGhost',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/reflection/reflectionclass/newlazyproxy.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionclass.newlazyproxy" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::newLazyProxy</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.4.0)</p><p class="refpurpose"><span class="refname">ReflectionClass::newLazyProxy</span> &mdash; <span class="dc-title">Creates a new lazy proxy instance</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.newlazyproxy-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionClass::newLazyProxy</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$factory</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.object.php" class="type object">object</a></span></div>

  <p class="simpara">
   Creates a new lazy proxy instance of the class, attaching the
   <code class="parameter">factory</code> 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&#039;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
   <a href="language.oop5.lazy-objects.php#language.oop5.lazy-objects.initialization-triggers" class="link">Initialization
   Triggers</a> and <a href="language.oop5.lazy-objects.php#language.oop5.lazy-objects.initialization-sequence" class="link">
   Initialization Sequence</a>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.newlazyproxy-parameters">
  <h3 class="title">Bağımsız Değişkenler</h3>
  <dl>
   
    <dt><code class="parameter">factory</code></dt>
    <dd>
     <span class="simpara">
      The factory is a callback with the following signature:
     </span>
     <p class="para">
      <div class="methodsynopsis dc-description">
       <span class="methodname"><span class="replaceable">factory</span></span>(<span class="methodparam"><span class="type"><a href="language.types.object.php" class="type object">object</a></span> <code class="parameter">$object</code></span>): <span class="type"><a href="language.types.object.php" class="type object">object</a></span></div>

      <dl>
       
        <dt><code class="parameter">object</code></dt>
        <dd>
         <span class="simpara">
          The <code class="parameter">object</code> being initialized. At this point,
          the object is no longer marked as lazy, and accessing it does not
          trigger initialization again.
         </span>
        </dd>
       
      </dl>
     </p>
     <span class="simpara">
      The factory function must return an object, referred to as the
      <em>real instance</em>, 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&#039;s class must be a subclass of the real
      instance&#039;s class, without additional properties, and must not override the
      <span class="methodname"><strong>__destruct()</strong></span> or <span class="methodname"><strong>__clone()</strong></span>
      methods.
     </span>
    </dd>
   
   
    <dt><code class="parameter">options</code></dt><dd>
     <p class="para">
      <code class="parameter">options</code> can be a combination of the following
      flags:
      <dl>
       
        <dt>
         <strong><code>ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE</code></strong>
        </dt>
        <dd>
         <span class="simpara">
          By default, serializing a lazy object triggers its
          initialization. Setting this flag prevents initialization, allowing
          lazy objects to be serialized without being initialized.
         </span>
        </dd>
       
      </dl>
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionclass.newlazyproxy-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
  <p class="simpara">
   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
   <a href="language.oop5.lazy-objects.php#language.oop5.lazy-objects.lifecycle" class="link">Lifecycle of Lazy
   Objects</a>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-reflectionclass.newlazyproxy-errors">
  <h3 class="title">Hatalar/İstisnalar</h3>
  <p class="simpara">
   An <span class="classname"><a href="class.error.php" class="classname">Error</a></span> if the class is internal or extends an
   internal class except <span class="classname"><a href="class.stdclass.php" class="classname">stdClass</a></span>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionclass.newlazyproxy-examples">
  <h3 class="title">Örnekler</h3>
  <div class="example" id="example-1">
   <p><strong>Örnek 1 Basic usage</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">Example </span><span style="color: #007700">{<br />    public function </span><span style="color: #0000BB">__construct</span><span style="color: #007700">(public </span><span style="color: #0000BB">int $prop</span><span style="color: #007700">) {<br />        echo </span><span style="color: #0000BB">__METHOD__</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />    }<br />}<br /><br /></span><span style="color: #0000BB">$reflector </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #0000BB">Example</span><span style="color: #007700">::class);<br /></span><span style="color: #0000BB">$object </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflector</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">newLazyProxy</span><span style="color: #007700">(function (</span><span style="color: #0000BB">Example $object</span><span style="color: #007700">) {<br />     </span><span style="color: #0000BB">$realInstance </span><span style="color: #007700">= new </span><span style="color: #0000BB">Example</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />     return </span><span style="color: #0000BB">$realInstance</span><span style="color: #007700">;<br />});<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$object</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$object </span><span style="color: #007700">instanceof </span><span style="color: #0000BB">Example</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Triggers initialization, and forwards the property fetch to the real instance<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$object</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prop</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$object</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>
Yukarıdaki örneğin çıktısı:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">lazy proxy object(Example)#3 (0) {
  [&quot;prop&quot;]=&gt;
  uninitialized(int)
}
bool(true)
Example::__construct
int(1)
lazy proxy object(Example)#3 (1) {
  [&quot;instance&quot;]=&gt;
  object(Example)#4 (1) {
    [&quot;prop&quot;]=&gt;
    int(1)
  }
}</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.newlazyproxy-seealso">
  <h3 class="title">Ayrıca Bakınız</h3>
  <ul class="simplelist">
   <li><a href="language.oop5.lazy-objects.php" class="link">Lazy objects</a></li>
   <li><span class="methodname"><a href="reflectionclass.newlazyghost.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::newLazyGhost()</a> - Creates a new lazy ghost instance</span></li>
   <li><span class="methodname"><a href="reflectionclass.newinstancewithoutconstructor.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::newInstanceWithoutConstructor()</a> - Creates a new class instance without invoking the constructor</span></li>
   <li><span class="methodname"><a href="reflectionclass.resetaslazyproxy.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::resetAsLazyProxy()</a> - Resets an object and marks it as lazy</span></li>
   <li><span class="methodname"><a href="reflectionclass.marklazyobjectasinitialized.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::markLazyObjectAsInitialized()</a> - Marks a lazy object as initialized without calling the initializer or factory</span></li>
   <li><span class="methodname"><a href="reflectionclass.initializelazyobject.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::initializeLazyObject()</a> - Forces initialization of a lazy object</span></li>
   <li><span class="methodname"><a href="reflectionclass.isuninitializedlazyobject.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::isUninitializedLazyObject()</a> - Checks if an object is lazy and uninitialized</span></li>
   <li><span class="methodname"><a href="reflectionproperty.setrawvaluewithoutlazyinitialization.php" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::setRawValueWithoutLazyInitialization()</a> - Set raw property value without triggering lazy initialization</span></li>
   <li><span class="methodname"><a href="reflectionproperty.skiplazyinitialization.php" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::skipLazyInitialization()</a> - Marks property as non-lazy</span></li>
   <li><span class="methodname"><a href="reflectionproperty.islazy.php" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::isLazy()</a> - Checks whether a property is lazy</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>