private function useExceptionImplementation() { $this->getClassMap()->registerClass('Exception', '\\Exception'); $implementation = new ClassTypeImplementation('Exception'); $causePropertyImplementation = new PropertyImplementation('cause'); $causePropertyImplementation->setTargetPropertyName('previous'); $implementation->addPropertyImplementation($causePropertyImplementation); $this->registerClassTypeImplementation($implementation); }
public function getImplementationForProperty($propertyName) { if (isset($this->propertiesImplementation[$propertyName])) { return $this->propertiesImplementation[$propertyName]; } $setterName = null; $getterName = null; if ($this->accessorsEnabled) { if (!$this->style) { throw new \BadMethodCallException('Cannot generate setters nad getters name without naming style'); } $setterName = $this->style->generateSetterName($propertyName); $getterName = $this->style->generateGetterName($propertyName); } $propertyImplementation = new PropertyImplementation($propertyName); $propertyImplementation->setTargetPropertyName($propertyName); if ($setterName) { $propertyImplementation->setSetter($setterName); } if ($getterName) { $propertyImplementation->setGetter($getterName); } return $propertyImplementation; }
public function testTargetPropertyNameCannotBeEmpty() { $this->cannotBeEmpty(); $this->object->setTargetPropertyName(''); }
protected function createPropertyImplementation($propertyName, $propertyOptions, ClassTypeImplementation $classImplementation) { $propertyImplementation = new PropertyImplementation($propertyName); $targetPropertyName = $propertyName; if (isset($propertyOptions['as'])) { $propertyImplementation->setTargetPropertyName($propertyOptions['as']); $targetPropertyName = $propertyOptions['as']; } // accessors enabled $accessorsEnabled = $classImplementation->isAccessorsEnabled(); if (isset($propertyOptions['accessors']['enabled'])) { $accessorsEnabled = (bool) $propertyOptions['accessors']['enabled']; } // accessors names if (array_key_exists('setter', $propertyOptions)) { $propertyImplementation->setSetter($propertyOptions['setter']); } else { if ($accessorsEnabled) { $style = $classImplementation->getAccessorsStyle(); if (!$style) { $msg = 'Cannot generate setter name for property "' . $propertyName . '". Define that name or naming style of setters and getters'; throw new \BadMethodCallException($msg); } $propertyImplementation->setSetter($style->generateSetterName($targetPropertyName)); } } if (array_key_exists('getter', $propertyOptions)) { $propertyImplementation->setGetter($propertyOptions['getter']); } elseif ($accessorsEnabled) { $style = $classImplementation->getAccessorsStyle(); if (!$style) { $msg = 'Cannot generate getter name for property "' . $propertyName . '". Define that name or naming style of setters and getters'; throw new \BadMethodCallException($msg); } $propertyImplementation->setGetter($style->generateGetterName($targetPropertyName)); } return $propertyImplementation; }