<?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.newlazyghost.php',
    1 => 'ReflectionClass::newLazyGhost',
    2 => 'Creates a new lazy ghost instance',
  ),
  'up' => 
  array (
    0 => 'class.reflectionclass.php',
    1 => 'ReflectionClass',
  ),
  'prev' => 
  array (
    0 => 'reflectionclass.newinstancewithoutconstructor.php',
    1 => 'ReflectionClass::newInstanceWithoutConstructor',
  ),
  'next' => 
  array (
    0 => 'reflectionclass.newlazyproxy.php',
    1 => 'ReflectionClass::newLazyProxy',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/reflection/reflectionclass/newlazyghost.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

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

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.newlazyghost-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionClass::newLazyGhost</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$initializer</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 ghost instance of the class, attaching the
   <code class="parameter">initializer</code> 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
   <code class="parameter">initializer</code> the first time its state is observed or
   modified. 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.newlazyghost-parameters">
  <h3 class="title">Bağımsız Değişkenler</h3>
  <dl>
   
    <dt><code class="parameter">initializer</code></dt>
    <dd>
     <span class="simpara">
      The initializer is a callback with the following signature:
     </span>
     <p class="para">
      <div class="methodsynopsis dc-description">
       <span class="methodname"><span class="replaceable">initializer</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.void.php" class="type void">void</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 <code class="parameter">initializer</code> function must return <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> or no
      value.
     </span>
    </dd>
   
   
    <dt id="reflectionclass.newlazyghost.parameters.options"><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.newlazyghost-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
  <p class="simpara">
   Returns a lazy ghost 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.newlazyghost-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.newlazyghost-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 /><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">newLazyGhost</span><span style="color: #007700">(function (</span><span style="color: #0000BB">Example $object</span><span style="color: #007700">) {<br />     </span><span style="color: #0000BB">$object</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">__construct</span><span style="color: #007700">(</span><span style="color: #0000BB">1</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 fetches the property after that<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">?&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 ghost object(Example)#3 (0) {
  [&quot;prop&quot;]=&gt;
  uninitialized(int)
}
bool(true)
Example::__construct
int(1)</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.newlazyghost-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.newlazyproxy.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::newLazyProxy()</a> - Creates a new lazy proxy 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.resetaslazyghost.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::resetAsLazyGhost()</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); ?>