<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/language.attributes.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'language.attributes.classes.php',
    1 => '&Ouml;znitelik Sınıflarının Bildirimi',
    2 => '&Ouml;znitelik Sınıflarının Bildirimi',
  ),
  'up' => 
  array (
    0 => 'language.attributes.php',
    1 => '&Ouml;znitelikler',
  ),
  'prev' => 
  array (
    0 => 'language.attributes.reflection.php',
    1 => '&Ouml;zniteliklerin Yansıtma Aray&uuml;z&uuml; ile Okunması',
  ),
  'next' => 
  array (
    0 => 'language.references.php',
    1 => 'G&ouml;nderimlerle İlgili Herşey',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'tr',
    'path' => 'language/attributes.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="language.attributes.classes" class="sect1">
   <h2 class="title">Öznitelik Sınıflarının Bildirimi</h2>

   <p class="para">
    Zorunlu olmamakla birlikte, her öznitelik için gerçek bir sınıfın
    oluşturulması önerilir. En basit durumda, bir use ifadesiyle küresel isim
    alanından içe aktarılabilen #[Attribute] özniteliğinin bildirimi için
    yalnızca boş bir sınıfa ihtiyaç vardır.
   </p>

  <div class="example" id="example-1">
   <p><strong>Örnek 1 - Basit Öznitelik sınıfı</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">namespace </span><span style="color: #0000BB">Example</span><span style="color: #007700">;<br /><br />use </span><span style="color: #0000BB">Attribute</span><span style="color: #007700">;<br /><br />#[</span><span style="color: #0000BB">Attribute</span><span style="color: #007700">]<br />class </span><span style="color: #0000BB">MyAttribute<br /></span><span style="color: #007700">{<br />}</span></span></code></div>
   </div>

  </div>

  <p class="para">
   Bir özniteliğin atanabileceği bildirim türünü kısıtlamak için, #[Attribute]
   bildirimine ilk bağımsız değişken olarak bir bit maskesi aktarılabilir.
  </p>

  <div class="example" id="example-2">
   <p><strong>Örnek 2 - Özniteliklerin kullanılabileceği yerleri kısıtlamak için hedef
    belirtiminin kullanımı</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">namespace </span><span style="color: #0000BB">Example</span><span style="color: #007700">;<br /><br />use </span><span style="color: #0000BB">Attribute</span><span style="color: #007700">;<br /><br />#[</span><span style="color: #0000BB">Attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">Attribute</span><span style="color: #007700">::</span><span style="color: #0000BB">TARGET_METHOD </span><span style="color: #007700">| </span><span style="color: #0000BB">Attribute</span><span style="color: #007700">::</span><span style="color: #0000BB">TARGET_FUNCTION</span><span style="color: #007700">)]<br />class </span><span style="color: #0000BB">MyAttribute<br /></span><span style="color: #007700">{<br />}</span></span></code></div>
    </div>


    <div class="example-contents"><p>
     <span class="classname"><strong class="classname">MyAttribute</strong></span> sınıfının başka bir türde
     bildirilmesi, <span class="function"><a href="reflectionattribute.newinstance.php" class="function">ReflectionAttribute::newInstance()</a></span>
     çağrısı sırasında bir istisna oluşmasına sebep olur.
    </p></div>
   </div>

   <p class="para">Şu hedefler belirtilebilir:</p>

   <ul class="simplelist">
    <li><strong><code><a href="class.attribute.php#attribute.constants.target-class">Attribute::TARGET_CLASS</a></code></strong></li>
    <li><strong><code><a href="class.attribute.php#attribute.constants.target-function">Attribute::TARGET_FUNCTION</a></code></strong></li>
    <li><strong><code><a href="class.attribute.php#attribute.constants.target-method">Attribute::TARGET_METHOD</a></code></strong></li>
    <li><strong><code><a href="class.attribute.php#attribute.constants.target-property">Attribute::TARGET_PROPERTY</a></code></strong></li>
    <li><strong><code><a href="class.attribute.php#attribute.constants.target-class-constant">Attribute::TARGET_CLASS_CONSTANT</a></code></strong></li>
    <li><strong><code><a href="class.attribute.php#attribute.constants.target-parameter">Attribute::TARGET_PARAMETER</a></code></strong></li>
    <li><strong><code><a href="class.attribute.php#attribute.constants.target-all">Attribute::TARGET_ALL</a></code></strong></li>
   </ul>

   <p class="para">
    Öntanımlı olarak, bir öznitelik her bildirimde yalnızca bir kere
    kullanılabilir. Özniteliğin bildirimlerde yinelenebilir olması isteniyorsa,
    <code class="literal">#[Attribute]</code> bildiriminde bit maskesinin bir parçası
    olarak belirtilmelidir.
   </p>

   <div class="example" id="example-3">
    <p><strong>Örnek 3 - Özniteliğin bir bildirimle defalarca kullanılabilmesi için
    IS_REPEATABLE kullanımı</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">namespace </span><span style="color: #0000BB">Example</span><span style="color: #007700">;<br /><br />use </span><span style="color: #0000BB">Attribute</span><span style="color: #007700">;<br /><br />#[</span><span style="color: #0000BB">Attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">Attribute</span><span style="color: #007700">::</span><span style="color: #0000BB">TARGET_METHOD </span><span style="color: #007700">| </span><span style="color: #0000BB">Attribute</span><span style="color: #007700">::</span><span style="color: #0000BB">TARGET_FUNCTION </span><span style="color: #007700">| </span><span style="color: #0000BB">Attribute</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_REPEATABLE</span><span style="color: #007700">)]<br />class </span><span style="color: #0000BB">MyAttribute<br /></span><span style="color: #007700">{<br />}</span></span></code></div>
    </div>


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