The note about the signature of the ReflectionParameter constructor is actually incomplete, at least in 5.2.5: it is possible to use an integer for the second parameter, and the constructor will use it to return the n-th parameter.
This allows you to obtain proper ReflectionParameter objects even when documenting code from extensions which (strangely enough) define several parameters with the same name. The string-based constructor always returns the first parameter with the matching name, whereas the integer-based constructor correctly returns the n-th parameter.
So, in short, this works:
<?php
// supposing the extension defined something like:
// Some_Class::someMethod($a, $x, $y, $x, $y)
$p = new ReflectionParameter(array('Some_Class', 'someMethod'), 4);
// returns the last parameter, whereas
$p = new ReflectionParameter(array('Some_Class', 'someMethod'), 'y');
// always returns the first $y at position 2
?>
ReflectionParameter Sınıfı
(PHP 5)
Giriş
ReflectionParameter sınıfı bir işlev veya yöntemin değiştirgeleri hakkında bilgi edinilmesini sağlar.
Bir işlevin değiştirgelerini incelemek için önce ReflectionFunction veya ReflectionMethod sınıfının bir örneğini oluşturmalı, sonra da bu sınıfların ReflectionFunctionAbstract::getParameters() yöntemini kullanarak değiştirge dizisini almalısınız.
Sınıf Sözdizimi
Özellikler
- name
-
İsim.
İçindekiler
- ReflectionParameter::allowsNull — NULL değere izin veriliyor mu diye bakar
- ReflectionParameter::canBePassedByValue — Returns whether this parameter can be passed by value
- ReflectionParameter::__clone — Nesneyi kopyalar
- ReflectionParameter::__construct — Bir ReflectionParameter nesnesi oluşturur
- ReflectionParameter::export — Sınıfı ihraç eder
- ReflectionParameter::getClass — Sınıfı döndürür
- ReflectionParameter::getDeclaringClass — Bildiren sınıfı döndürür
- ReflectionParameter::getDeclaringFunction — Bildiren işlevi döndürür
- ReflectionParameter::getDefaultValue — Değiştirgenin öntanımlı değerini döndürür
- ReflectionParameter::getName — Değiştirgenin ismini döndürür
- ReflectionParameter::getPosition — Değiştirgenin konumunu döndürür
- ReflectionParameter::isArray — Değiştirge değeri bir dizi mi olacak diye bakar
- ReflectionParameter::isDefaultValueAvailable — Öntanımlı bir değerin kullanılabilir olup olmadığına bakar
- ReflectionParameter::isOptional — Değiştirge seçimlik mi diye bakar
- ReflectionParameter::isPassedByReference — Değiştirge gönderimli aktarılabilir mi diye bakar
- ReflectionParameter::__toString — Dizgesel tepkiyi görselleştirir
fgm at riff dot org
11-May-2008 12:44
killgecNOFSPAM at gmail dot com
25-Jul-2007 05:53
Signature of constructor of ReflectionParameter correctly is:
public function __construct(array/string $function, string $name);
where $function is either a name of a global function, or a class/method name pair.
massimo at mmware dot it
18-Jul-2007 08:58
I found these limitations using class ReflectionParameter from ReflectionFunction with INTERNAL FUNCTIONS (eg print_r, str_replace, ... ) :
1. parameter names don't match with manual: (try example 19.35 with arg "call_user_func" )
2. some functions (eg PCRE function, preg_match etc) have EMPTY parameter names
3. calling getDefaultValue on Parameters will result in Exception "Cannot determine default value for internal functions"
