Get a reflection class that has this property.

@param string $class
@param string $propertyName

@return \ReflectionClass|null

@throws \InvalidArgumentException
188236
protected static function getReflectionClassWithProperty($class, $propertyName)
    {
        Assert::string($class, 'First argument to Reflection::getReflectionClassWithProperty must be string. Variable of type "%s" was given.');
        Assert::classExists($class, 'Could not find class "%s"');

        $refl = new \ReflectionClass($class);
        if ($refl->hasProperty($propertyName)) {
            return $refl;
        }

        if (false === $parent = get_parent_class($class)) {
            // No more parents
            return;
        }

        return self::getReflectionClassWithProperty($parent, $propertyName);
    }
443741
public static function getPropertyValue($object,$propertyName)
    {
        $getter = "get" . ucfirst($propertyName);
        if (method_exists($object, $getter)) {
            return $object->$getter();
        }
        return null;
    }
845514
protected function getProperty(string $propertyName, $defaultValue)
    {
        if (count($this->values) === 1 && isset($this->values['__value'])) {
            return $this->parseType($this->values['__value']);
        }

        if (isset($this->values[$propertyName])) {
            return $this->parseType($this->values[$propertyName]);
        }

        return $defaultValue;
    }
23473
public static function getValue($objectOrClass, string $propertyName)
    {
        $objectOrClass = self::getObject($objectOrClass);
        $closure =
            /**
             * @return mixed
             */
            function () use ($propertyName) {
                if (\property_exists($this, $propertyName)) {
                    $class = new \ReflectionClass(typeOf($this));
                    $property = $class->getProperty($propertyName);
                    $property->setAccessible(true);
                    return $property->getValue($this);
                }
                throw new \RuntimeException(
                    Picklock::errorMessage($this, $propertyName, false)
                );
            };
        return
            $closure->bindTo($objectOrClass, $objectOrClass)();
    }
716329
public function getProperty($classname, $property)
    {
        return $this->hasProperty($classname, $property)
            ? $this->properties[$classname . '$' . $property]
            : [];
    }
1145651
public function getTraitProvidingProperty(ReflectionClass $class, string $propertyName): ReflectionClass
    {
        $traitsWithProperty = [];
        foreach ($class->getTraits() as $trait) {
            try {
                $trait->getProperty($propertyName);
                $traitsWithProperty[] = $trait;
            } catch (\ReflectionException $e) {
            }
        }
        if ([] === $traitsWithProperty) {
            if ($class->isTrait() && $class->hasProperty($propertyName)) {
                return $class;
            }
            throw new \RuntimeException(
                'Failed finding trait providing the property ' . $propertyName . ' in ' .
                $class->getShortName()
            );
        }
        if (count($traitsWithProperty) > 1) {
            throw new \RuntimeException(
                'Found more than one trait providing the property ' . $propertyName . ' in ' .
                $class->getShortName()
            );
        }

        return current($traitsWithProperty);
    }
613810
public static function getPropertyClass($class, $propertyName)
    {
        if ($class == get_class(new BlockCypherModel())) {
            // Make it generic if BlockCypherModel is used for generating this
            return get_class(new BlockCypherModel());
        }

        // If the class doesn't exist, or the method doesn't exist, return null.
        if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) {
            return null;
        }

        if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) {
            $param = $annotations['return'];
        }

        if (isset($param)) {
            $anno = preg_split("/[\s\[\]]+/", $param);

            $clazz = $anno[0];

            $primitiveTypes = array(
                'int', 'integer', 'float', 'string', 'bool', 'boolean', 'array', 'mixed',
            );

            if (!in_array($clazz, $primitiveTypes)
                && !in_array(ltrim($clazz, '\\'), $primitiveTypes)  // primitive types can also be \string, \int, ...
                && !class_exists($clazz)
            ) {
                throw new \Exception("Class not found: $clazz. Check all class names are fully qualified in PHPDoc");
            }

            return $clazz;
        } else {
            throw new BlockCypherConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type.");
        }
    }
976570
private function getMutatorMethod(string $class, string $property): ?array
    {
        $ucProperty = ucfirst($property);
        $ucSingulars = (array) Inflector::singularize($ucProperty);

        foreach ($this->mutatorPrefixes as $prefix) {
            $names = [$ucProperty];
            if (\in_array($prefix, $this->arrayMutatorPrefixes)) {
                $names = array_merge($names, $ucSingulars);
            }

            foreach ($names as $name) {
                try {
                    $reflectionMethod = new \ReflectionMethod($class, $prefix.$name);
                    if ($reflectionMethod->isStatic()) {
                        continue;
                    }

                    // Parameter can be optional to allow things like: method(array $foo = null)
                    if ($reflectionMethod->getNumberOfParameters() >= 1) {
                        return [$reflectionMethod, $prefix];
                    }
                } catch (\ReflectionException $e) {
                    // Try the next prefix if the method doesn't exist
                }
            }
        }

        return null;
    }
178817
public static function getValue($object, $propertyName)
    {
        /**
         * The error container
         *
         * @var \InvalidArgumentException|null $error
         */
        $error = null;

        foreach (self::$providers as $provider) {
            $error = null;
            $value = self::tryGetValue($provider, $object, $propertyName, $error);
            if (is_null($error)) {
                return $value;
            }
        }

        throw $error;
    }
80809
public static function getClassProperties($class)
    {
        if (is_string($class)) {
            if (isset(self::$classPropertyes[$class])) {
                return self::$classPropertyes[$class];
            }

            $class = new \ReflectionClass($class);
        }

        if (!$class instanceof \ReflectionClass) {
            throw new \InvalidArgumentException('The arguments must be a valid class name or reflection');
        }

        if (isset(self::$classPropertyes[$class->getName()])) {
            return self::$classPropertyes[$class->getName()];
        }

        $props = $class->getProperties();
        $props_arr = [];
        foreach ($props as $prop) {
            $f = $prop->getName();

            $props_arr[$f] = $prop;
        }
        if ($parentClass = $class->getParentClass()) {
            $parent_props_arr = static::getClassProperties($parentClass);//RECURSION
            if (count($parent_props_arr) > 0) {
                $props_arr = array_merge($parent_props_arr, $props_arr);
            }
        }

        self::$classPropertyes[$class->getName()] = $props_arr;

        return $props_arr;
    }
1152267
public function getProperty(&$object, string $propertyName)
    {
        $reflection = new ReflectionClass(get_class($object));

        /** @var ReflectionProperty $property */
        $property = $reflection->getProperty($propertyName);
        $property->setAccessible(true);

        return $property->getValue($object);
    }
57068
private function getReflectionClass($className) : ReflectionClass
    {
        if (! class_exists($className)) {
            throw InvalidArgumentException::fromNonExistingClass($className);
        }

        $reflection = new ReflectionClass($className);

        if ($reflection->isAbstract()) {
            throw InvalidArgumentException::fromAbstractClass($reflection);
        }

        return $reflection;
    }
312015
private function getPropertyInfo(string $propertyName, string $className, int $specVersion = 2): stdClass
    {
        foreach ($this->getProperties($className, $specVersion) as $classPropertyName => $property) {
            if ($classPropertyName === $propertyName) {
                return $property;
            }
        }

        throw new \InvalidArgumentException(sprintf('The property "%s" for the class "%s" doesn\'t exist.', $propertyName, $className));
    }
284684
public function getMultipleProperties(array $propertyNames)
    {
        $this->parseStyleAttribute();

        $result = [];

        foreach ($propertyNames as $propertyName) {
            if (!is_string($propertyName)) {
                throw new InvalidArgumentException(sprintf('Property name must be a string, %s given', (is_object($propertyName) ? get_class($propertyName) : gettype($propertyName))));
            }

            if (array_key_exists($propertyName, $this->properties)) {
                $result[$propertyName] = $this->properties[$propertyName];
            }
        }

        return $result;
    }
1368076
public function getProperty($propertyName)
    {
        if (isset($this->properties[$propertyName])) {
            return $this->properties[$propertyName];
        }

        $extendsClassDefinition = $this->getExtendsClassDefinition();
        if ($extendsClassDefinition) {
            if ($extendsClassDefinition->hasProperty($propertyName)) {
                return $extendsClassDefinition->getProperty($propertyName);
            }
        }

        return false;
    }
707091
public function getProperties($value, ReflectionClass $class, $propertyFilter)
	{
		$attributes = array_merge($value->getAttributes(), $value->getRelations());

		$visible = $value->getVisible();

		if (count($visible) === 0)
		{
			$visible = array_diff(array_keys($attributes), $value->getHidden());
		}

		if ( ! $this->showHidden($propertyFilter))
		{
			return array_intersect_key($attributes, array_flip($visible));
		}

		$properties = [];

		foreach ($attributes as $key => $value)
		{
			if ( ! in_array($key, $visible))
			{
				$key = sprintf('<protected>%s</protected>', $key);
			}

			$properties[$key] = $value;
		}

		return $properties;
	}
601201
public static function isPropertyClassArray($class, $propertyName)
    {
        // If the class doesn't exist, or the method doesn't exist, return null.
        if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) {
            return null;
        }

        if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) {
            $param = $annotations['return'];
        }

        if (isset($param)) {
            return substr($param, -strlen('[]')) === '[]';
        } else {
            throw new BlockCypherConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type.");
        }
    }