private function parseMethodColumnDescriptors(\ReflectionClass $reflClass, &$columnDescriptors, AutoTablesConfiguration $config) { foreach ($reflClass->getMethods() as $method) { $column = null; $annot = $this->reader->getMethodAnnotation($method, '\\twentysteps\\Bundle\\AutoTablesBundle\\Annotations\\Column'); if ($annot) { $column = new MethodColumnDescriptor($method); Ensure::isTrue(count($method->getParameters()) == 0, 'Failed to use [%s] as getter method, only parameterless methods supported for @Column', $method->getName()); Ensure::isTrue(StaticStringy::startsWith($method->getName(), 'get'), 'Illegal method name [%s], getter methods must start with a get prefix', $method->getName()); $column->addAutoTablesAnnotation($annot); $column->addAutoTablesConfig($config, $method->getName()); } if ($column && $column->isUsable()) { $methodName = 'set' . substr($method->getName(), 3); if ($reflClass->hasMethod($methodName)) { $setterMethod = $reflClass->getMethod($methodName); Ensure::isEqual(1, count($setterMethod->getParameters()), 'setter method [%s] needs to have exactly one parameter', $setterMethod->getName()); $column->setSetterMethod($setterMethod); } $column->validate(); $this->columnDescriptorMap[$column->getId()] = $column; $columnDescriptors[] = $column; } } }
public function testEnsureEqualsFailed() { $this->setExpectedException(self::ENSURE_EXCEPTION, 'check 1 2 3'); Ensure::isEqual(1, 2, 'check %s %s %s', 1, 2, 3); }