JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbrobject = $object; $this->parsePropRules(); } /** * @param string $propertyName * @param mixed $propertyValue * @throws \InvalidArgumentException * @return void */ public function validatePropertyValue(string $propertyName, mixed $propertyValue, ?array $filter = []): void { if (!isset($this->propRules[$propertyName])) { return; } foreach ($this->propRules[$propertyName] as $constraint) { if (!empty($filter) && in_array($constraint::class, $filter)) { continue; } $validator = $constraint->validatedBy(); $validator = new $validator($this->object::class, $propertyName); $validator->validate($propertyValue, $constraint); } } /** * @return void * @throws \InvalidArgumentException */ public function validateAllProperties(): void { foreach($this->propValues as $propName => $propValue) { $this->validatePropertyValue($propName, $propValue); } } /** * @param string $propName * @return array|null */ public function getRulesByPropName(string $propName): ?array { return $this->propRules[$propName] ?? null; } /** * @return void */ private function parsePropRules(): void { $reflector = new \ReflectionObject($this->object); foreach ($reflector->getProperties() as $property) { $property->setAccessible(true); if ($property->isInitialized($this->object)) { $this->propValues[$property->getName()] = $property->getValue($this->object); } foreach ($property->getAttributes() as $attribute) { $this->propRules[$property->getName()][] = $attribute->newInstance(); } } } }