returns all properties of an object

TODO let caller define the visibility

@param      $object
@param bool $asString
@return null|\ReflectionProperty[]|string
@throws \ReflectionException
484816
public static function getAllProperties($object, bool $asString = true) {
        $validObject = ClassUtil::isValidObject($object);
        if (!$validObject) {
            return null;
        }
        $reflectionClass = new \ReflectionClass($object);
        $properties = $reflectionClass->getProperties();

        if ($asString) {
            return ArrayUtil::arrayToString($properties);
        } else {
            return $properties;
        }
    }
961052
public static function getClassName($object): ?string {
        $validObject = ClassUtil::isValidObject($object);
        if (!$validObject) {
            return null;
        }
        return (new \ReflectionClass($object))->getName();
    }
564836
private static function &getProperty($object, string $property)
  {
    $value = &\Closure::bind(function & () use ($property) {
      return $this->$property;
    }, $object, $object)->__invoke();

    return $value;
  }
548173
public function serialize($object)
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('Argument must be an object');
        }

        $reflectedObject = new \ReflectionObject($object);
        $reflectedProperties = $reflectedObject->getProperties();

        $array = array();

        foreach ($reflectedProperties as $property) {
            $value = $this->getValue($object, $property);

            if (null !== $value) {
                if (!is_scalar($value)) {
                    $value = $this->normalize($value);
                }

                $array[$this->formatter->toMongoKey($property->getName())] = $value;
            }
        }

        return $array;
    }
303402
public function getStaticPropertyValue($object, $propertyName) {
        $className = $object;

        if(is_object($className)) {
            $className = get_class($object);
        }

        $reflector = new ReflectionClass($className);
        $properties = $reflector->getStaticProperties();

        return (isset($properties[$propertyName])) ? $properties[$propertyName] : NULL;
    }
497554
public function getGettablePropertiesOfObject($object)
    {
        $className = get_class($object);

        if (false === isset($this->gettablePropertiesOfObjects[$className])) {
            $this->gettablePropertiesOfObjects[$className] = [];
            $properties = $this->getReflectionService()->getClassPropertyNames($className);

            foreach ($properties as $propertyName) {
                if (true === $this->isPropertyGettable($object, $propertyName)) {
                    $this->gettablePropertiesOfObjects[$className][] = $propertyName;
                }
            }
        }

        return $this->gettablePropertiesOfObjects[$className];
    }
709993
public function objectToString($object, $params = array())
	{
		// A class must be provided
		$class = !empty($params['class']) ? $params['class'] : 'Registry';

		// Build the object variables string
		$vars = '';

		foreach (get_object_vars($object) as $k => $v)
		{
			if (is_scalar($v))
			{
				$vars .= "\tpublic $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n";
			}
			elseif (\is_array($v) || \is_object($v))
			{
				$vars .= "\tpublic $" . $k . ' = ' . $this->getArrayString((array) $v) . ";\n";
			}
		}

		$str = "<?php\n";

		// If supplied, add a namespace to the class object
		if (isset($params['namespace']) && $params['namespace'] !== '')
		{
			$str .= 'namespace ' . $params['namespace'] . ";\n\n";
		}

		$str .= 'class ' . $class . " {\n";
		$str .= $vars;
		$str .= '}';

		// Use the closing tag if it not set to false in parameters.
		if (!isset($params['closingtag']) || $params['closingtag'] !== false)
		{
			$str .= "\n?>";
		}

		return $str;
	}
388685
protected function _getMethods($object)
    {
        if (is_string($object)) {
            $className = $object;
        } else {
            $className = get_class($object);
        }
        $methods = get_class_methods($className);

        if (self::$_config['sort']['methods']) {
            sort($methods);
        }
        return $methods;
    }
1295218
public function getIdentifierValues($object)
    {
        $fields = $this->getReflectionFields();
        return $fields[$this->identifierPropertyName]->getValue($object);
    }
1070873
public static function getProperty($object, string $propertyName)
    {
        $reflection = new \ReflectionObject($object);
        $property = $reflection->getProperty($propertyName);
        $property->setAccessible(true);

        return $property->getValue($object);
    }
332563
public static function getTable($object)
    {
        $tableAnnotation = static::getAnnotation($object, Table::class);
        if(null !== $tableAnnotation)
        {
            return $tableAnnotation->name;
        }
        else
        {
            return null;
        }
    }
300586
private function getObjectClassname($object)
    {
        if (!is_object($object)) {
            return null;
        }

        if (!$this->isClassMappingEnabled()) {
            return '';
        }

        if(is_callable($this->getClassmappingCallback())) {
            $className = call_user_func_array($this->getClassmappingCallback(), [$object]);
        } else {
            $className = get_class($object);
        }

        return $className == 'stdClass' ? '' : $className;
    }
649821
public function getParameterBytes($asString = true)
    {
        if ($asString === true) {
            return implode($this->parameterBytes);
        } else {
            return $this->parameterBytes;
        }
    }
716694
protected function parseToArray($object): array
    {
        if (!is_array($object)) {
            $attributes = method_exists($object, 'getAttributes')
                ? $object->getAttributes()
                : get_object_vars($object);

            return $attributes;
        }

        return $object;
    }
563078
public static function objectArray($object)
    {
        if (is_object($object)) {
            $reflectionClass = new \ReflectionClass(get_class($object));
            $array = [];
            foreach ($reflectionClass->getProperties() as $property) {
                $property->setAccessible(true);
                $array[$property->getName()] = $property->getValue($object);
                $property->setAccessible(false);
            }

            //If above method failed? try, this one.
            $array = (empty($array)) ? json_decode(json_encode($object), true) : $array;

            return $array;
        }

        return false;
    }
821289
protected function getPrivate($object, string $propertyName)
    {
        $objectArray = (array) $object;
        foreach ($objectArray as $name => $value) {
            if (substr($name, - \strlen($propertyName) - 1) === "\x00" . $propertyName) {
                return $value;
            }
        }

        return null;
    }
317130
public static function ObjectAsArray($Object) {
      if (!is_object($Object))
         return $Object;

      $Return = array();
      foreach(get_object_vars($Object) as $Property => $Value) {
         $Return[$Property] = $Value;
      }
      return $Return;
   }