本文整理汇总了PHP中ReflectionProperty::isPublic方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionProperty::isPublic方法的具体用法?PHP ReflectionProperty::isPublic怎么用?PHP ReflectionProperty::isPublic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionProperty
的用法示例。
在下文中一共展示了ReflectionProperty::isPublic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reflectProperty
function reflectProperty($class, $property)
{
$propInfo = new ReflectionProperty($class, $property);
echo "**********************************\n";
echo "Reflecting on property {$class}::{$property}\n\n";
echo "__toString():\n";
var_dump($propInfo->__toString());
echo "export():\n";
var_dump(ReflectionProperty::export($class, $property, true));
echo "export():\n";
var_dump(ReflectionProperty::export($class, $property, false));
echo "getName():\n";
var_dump($propInfo->getName());
echo "isPublic():\n";
var_dump($propInfo->isPublic());
echo "isPrivate():\n";
var_dump($propInfo->isPrivate());
echo "isProtected():\n";
var_dump($propInfo->isProtected());
echo "isStatic():\n";
var_dump($propInfo->isStatic());
$instance = new $class();
if ($propInfo->isPublic()) {
echo "getValue():\n";
var_dump($propInfo->getValue($instance));
$propInfo->setValue($instance, "NewValue");
echo "getValue() after a setValue():\n";
var_dump($propInfo->getValue($instance));
}
echo "\n**********************************\n";
}
示例2: __construct
/**
* EntityPropertyMetadata constructor.
*
* @param string $propertyName
* @param \GraphAware\Neo4j\OGM\Metadata\PropertyAnnotationMetadata $propertyAnnotationMetadata
*/
public function __construct($propertyName, \ReflectionProperty $reflectionProperty, PropertyAnnotationMetadata $propertyAnnotationMetadata)
{
$this->propertyName = $propertyName;
$this->reflectionProperty = $reflectionProperty;
$this->propertyAnnotationMetadata = $propertyAnnotationMetadata;
$this->isAccessible = $reflectionProperty->isPublic();
}
示例3: __construct
public function __construct($class, $property)
{
$property = new ReflectionProperty($class, $property);
list($description, $tags) = Kodoc::parse($property->getDocComment());
$this->description = $description;
if ($modifiers = $property->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
}
if (isset($tags['var'])) {
if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) {
$this->type = $matches[1];
if (isset($matches[2])) {
$this->description = Markdown($matches[2]);
}
}
}
$this->property = $property;
// Show the value of static properties, but only if they are public or we are php 5.3 or higher and can force them to be accessible
if ($property->isStatic() and ($property->isPublic() or version_compare(PHP_VERSION, '5.3', '>='))) {
// Force the property to be accessible
if (version_compare(PHP_VERSION, '5.3', '>=')) {
$property->setAccessible(TRUE);
}
// Don't debug the entire object, just say what kind of object it is
if (is_object($property->getValue($class))) {
$this->value = '<pre>object ' . get_class($property->getValue($class)) . '()</pre>';
} else {
$this->value = Kohana::debug($property->getValue($class));
}
}
}
示例4: getReference
/**
* {@inheritDoc}
*/
public function getReference($name, $property = null)
{
if (isset($this->objectsCache[$name])) {
try {
$reference = $this->entityManager->merge($this->objectsCache[$name]);
} catch (\Exception $e) {
var_dump($e->getMessage());
var_dump($this->objectsCache[$name]);
exit;
}
} else {
if (isset($this->references[$name])) {
$reference = $this->references[$name];
} else {
throw new \UnexpectedValueException('Reference ' . $name . ' is not defined');
}
}
if ($property !== null) {
if (property_exists($reference, $property)) {
$prop = new \ReflectionProperty($reference, $property);
if ($prop->isPublic()) {
return $reference->{$property};
}
}
$getter = 'get' . ucfirst($property);
if (method_exists($reference, $getter) && is_callable(array($reference, $getter))) {
return $reference->{$getter}();
}
throw new \UnexpectedValueException('Property ' . $property . ' is not defined for reference ' . $name);
}
return $reference;
}
示例5: offsetUnset
/**
* @param string $sOffset
*/
public function offsetUnset($sOffset)
{
$oProperty = new \ReflectionProperty($this, $sOffset);
if ($oProperty->isPublic()) {
unset($this->{$sOffset});
}
}
示例6: call
/**
* Call to undefined method.
*
* @param string method name
* @param array arguments
* @return mixed
* @throws \MemberAccessException
*/
public static function call($_this, $name, $args)
{
$class = get_class($_this);
if ($name === '') {
throw new MemberAccessException("Call to class '{$class}' method without name.");
}
// event functionality
if (preg_match('#^on[A-Z]#', $name)) {
$rp = new ReflectionProperty($class, $name);
if ($rp->isPublic() && !$rp->isStatic()) {
$list = $_this->{$name};
if (is_array($list) || $list instanceof Traversable) {
foreach ($list as $handler) {
/**/
fixCallback($handler);
/**/
if (!is_callable($handler)) {
$able = is_callable($handler, TRUE, $textual);
throw new InvalidStateException("Event handler '{$textual}' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
}
call_user_func_array($handler, $args);
}
}
return NULL;
}
}
// extension methods
if ($cb = self::extensionMethod($class, $name)) {
array_unshift($args, $_this);
return call_user_func_array($cb, $args);
}
throw new MemberAccessException("Call to undefined method {$class}::{$name}().");
}
示例7: __call
public function __call($name, $args)
{
$class = get_class($this);
if ($name === '') {
throw new MemberAccessException("Call to class '{$class}' method without name.");
}
if (preg_match('#^on[A-Z]#', $name)) {
$rp = new ReflectionProperty($class, $name);
if ($rp->isPublic() && !$rp->isStatic()) {
$list = $this->{$name};
if (is_array($list) || $list instanceof Traversable) {
foreach ($list as $handler) {
if (is_object($handler)) {
call_user_func_array(array($handler, '__invoke'), $args);
} else {
call_user_func_array($handler, $args);
}
}
}
return NULL;
}
}
if ($cb = self::extensionMethod("{$class}::{$name}")) {
array_unshift($args, $this);
return call_user_func_array($cb, $args);
}
throw new MemberAccessException("Call to undefined method {$class}::{$name}().");
}
示例8: test_publicProperties
public function test_publicProperties()
{
$items = array('folder', 'name', 'info', 'handle', 'lock');
foreach ($items as $item) {
$prop = new ReflectionProperty($this->myClass, $item);
$this->assertTrue($prop->isPublic());
}
}
示例9: isPublic
/**
* Returns true if this property has public as access level.
*
* @return bool
*/
public function isPublic()
{
if ($this->reflectionSource instanceof ReflectionProperty) {
return $this->reflectionSource->isPublic();
} else {
return parent::isPublic();
}
}
示例10: test___publicProperties
public function test___publicProperties()
{
$items = array('vars', 'cleanVars', 'plugin_path');
foreach ($items as $item) {
$prop = new ReflectionProperty($this->myClass, $item);
$this->assertTrue($prop->isPublic());
}
}
示例11: test___publicProperties
public function test___publicProperties()
{
$items = array('handler', 'active', 'path_basic', 'path_plugin', 'configPath', 'name', 'config', 'message');
foreach ($items as $item) {
$prop = new ReflectionProperty($this->myclass, $item);
$this->assertTrue($prop->isPublic());
}
}
示例12: test___publicProperties
public function test___publicProperties()
{
$items = array('tempArr', 'themeSetData', 'imagesData', 'templatesData');
foreach ($items as $item) {
$prop = new ReflectionProperty($this->myclass, $item);
$this->assertTrue($prop->isPublic());
}
}
示例13: test___publicProperties
public function test___publicProperties()
{
$items = array('db');
foreach ($items as $item) {
$prop = new ReflectionProperty($this->myclass, $item);
$this->assertTrue($prop->isPublic());
}
}
示例14: test___publicProperties
public function test___publicProperties()
{
$items = array('ldap_provisioning', 'ldap_provisioning_upd', 'ldap_field_mapping', 'ldap_provisioning_group');
foreach ($items as $item) {
$prop = new ReflectionProperty($this->object, $item);
$this->assertTrue($prop->isPublic());
}
}
示例15: getProperty
private function getProperty($classOrObject, $property)
{
$property = new \ReflectionProperty(is_object($classOrObject) ? get_class($classOrObject) : $classOrObject, $property);
if (!$property->isPublic()) {
$property->setAccessible(true);
}
return $property->isStatic() ? $property->getValue($classOrObject) : $property->getValue();
}