From e66f2928fbc870f2a0bc953249bf2805b45766d1 Mon Sep 17 00:00:00 2001 From: kokspflanze Date: Thu, 16 Apr 2015 22:09:10 +0200 Subject: [PATCH 1/5] work on "Fatal error: Class Mock_AbstractType_5023bef1 contains abstract method (getTypeName) and must therefore be declared abstract or implement the remaining methods in /home/travis/build/ThaDafinser/ZfcDatagrid/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php(301) : eval()'d code on line 1" for hhvm build --- src/ZfcDatagrid/Column/Formatter/GenerateLink.php | 2 +- src/ZfcDatagrid/Column/Type/AbstractType.php | 7 +++++++ src/ZfcDatagrid/Column/Type/DateTime.php | 7 +++++-- src/ZfcDatagrid/Column/Type/Image.php | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ZfcDatagrid/Column/Formatter/GenerateLink.php b/src/ZfcDatagrid/Column/Formatter/GenerateLink.php index 132adafd..8a395d4a 100644 --- a/src/ZfcDatagrid/Column/Formatter/GenerateLink.php +++ b/src/ZfcDatagrid/Column/Formatter/GenerateLink.php @@ -38,7 +38,7 @@ public function __construct(ServiceManager $sm, $route, $key = null, $params = [ } /** - * @param AbstractColumn $columnUniqueId + * @param AbstractColumn $column * @return string */ public function getFormattedValue(AbstractColumn $column) diff --git a/src/ZfcDatagrid/Column/Type/AbstractType.php b/src/ZfcDatagrid/Column/Type/AbstractType.php index d205b0e7..3a5a6d32 100644 --- a/src/ZfcDatagrid/Column/Type/AbstractType.php +++ b/src/ZfcDatagrid/Column/Type/AbstractType.php @@ -36,4 +36,11 @@ public function getUserValue($val) { return $val; } + + /** + * Get the type name + * + * @return string + */ + abstract function getTypeName(); } diff --git a/src/ZfcDatagrid/Column/Type/DateTime.php b/src/ZfcDatagrid/Column/Type/DateTime.php index 07baf6f6..e89497dd 100644 --- a/src/ZfcDatagrid/Column/Type/DateTime.php +++ b/src/ZfcDatagrid/Column/Type/DateTime.php @@ -44,8 +44,8 @@ class DateTime extends AbstractType * * @param string $sourceDateTimeFormat * PHP DateTime format - * @param unknown $outputDateType - * @param unknown $outputTimeType + * @param int $outputDateType + * @param int $outputTimeType * @param string $locale * @param string $sourceTimezone * @param string $outputTimezone @@ -60,6 +60,9 @@ public function __construct($sourceDateTimeFormat = 'Y-m-d H:i:s', $outputDateTy $this->setOutputTimezone($outputTimezone); } + /** + * @return string + */ public function getTypeName() { return 'dateTime'; diff --git a/src/ZfcDatagrid/Column/Type/Image.php b/src/ZfcDatagrid/Column/Type/Image.php index 3192788b..24b883a4 100644 --- a/src/ZfcDatagrid/Column/Type/Image.php +++ b/src/ZfcDatagrid/Column/Type/Image.php @@ -21,6 +21,9 @@ class Image extends AbstractType */ protected $resizeHeight = 20.5; + /** + * @return string + */ public function getTypeName() { return 'image'; From bb9527a50f77b5b6a294c9dd9801e3b37ba7e0a7 Mon Sep 17 00:00:00 2001 From: kokspflanze Date: Thu, 16 Apr 2015 22:15:30 +0200 Subject: [PATCH 2/5] contains abstract method (__construct) and must therefore be declared abstract or implement the remaining methods in AbstractClass --- src/ZfcDatagrid/DataSource/AbstractDataSource.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ZfcDatagrid/DataSource/AbstractDataSource.php b/src/ZfcDatagrid/DataSource/AbstractDataSource.php index 48c0fe9e..bee7e458 100644 --- a/src/ZfcDatagrid/DataSource/AbstractDataSource.php +++ b/src/ZfcDatagrid/DataSource/AbstractDataSource.php @@ -32,6 +32,17 @@ abstract class AbstractDataSource implements DataSourceInterface */ protected $paginatorAdapter; + /** + * Set the data source + * - array + * - ZF2: Zend\Db\Sql\Select + * - Doctrine2: Doctrine\ORM\QueryBuilder + * - ... + * + * @param mixed $data + */ + abstract function __construct($data); + /** * Set the columns * From 427888829968bb035cbc58618983c15e4895f2b7 Mon Sep 17 00:00:00 2001 From: kokspflanze Date: Thu, 16 Apr 2015 22:26:16 +0200 Subject: [PATCH 3/5] contains abstract method (__construct) and must therefore be declared abstract or implement the remaining methods in AbstractClass --- src/ZfcDatagrid/DataSource/AbstractDataSource.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ZfcDatagrid/DataSource/AbstractDataSource.php b/src/ZfcDatagrid/DataSource/AbstractDataSource.php index bee7e458..6bb04043 100644 --- a/src/ZfcDatagrid/DataSource/AbstractDataSource.php +++ b/src/ZfcDatagrid/DataSource/AbstractDataSource.php @@ -41,7 +41,11 @@ abstract class AbstractDataSource implements DataSourceInterface * * @param mixed $data */ - abstract function __construct($data); + public function __construct($data) + { + // we need this exception, because a abstract __construct, create a exception in php-unit for mocking + throw new \Exception(sprintf('Missing __construct in %s', get_class($this))); + } /** * Set the columns From 4e054e2fbc98cee8d3d3c79cc3c72a68e3f5dc94 Mon Sep 17 00:00:00 2001 From: kokspflanze Date: Thu, 16 Apr 2015 22:30:21 +0200 Subject: [PATCH 4/5] run `php-cs-fixer fix` --- src/ZfcDatagrid/Column/Type/AbstractType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZfcDatagrid/Column/Type/AbstractType.php b/src/ZfcDatagrid/Column/Type/AbstractType.php index 3a5a6d32..fb1c03c6 100644 --- a/src/ZfcDatagrid/Column/Type/AbstractType.php +++ b/src/ZfcDatagrid/Column/Type/AbstractType.php @@ -42,5 +42,5 @@ public function getUserValue($val) * * @return string */ - abstract function getTypeName(); + abstract public function getTypeName(); } From 5f35aeec8fb8bfde4b6f137c5fd4adca5a7d37fa Mon Sep 17 00:00:00 2001 From: kokspflanze Date: Thu, 16 Apr 2015 22:51:52 +0200 Subject: [PATCH 5/5] added abstract methods in abstract classes from interface for hhvm build run `php-cs-fixer fix` --- .../DataSource/AbstractDataSource.php | 13 +++++++ src/ZfcDatagrid/Renderer/AbstractRenderer.php | 34 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/ZfcDatagrid/DataSource/AbstractDataSource.php b/src/ZfcDatagrid/DataSource/AbstractDataSource.php index 6bb04043..c11bdd28 100644 --- a/src/ZfcDatagrid/DataSource/AbstractDataSource.php +++ b/src/ZfcDatagrid/DataSource/AbstractDataSource.php @@ -141,4 +141,17 @@ public function getPaginatorAdapter() { return $this->paginatorAdapter; } + + /** + * Get the data back from construct + * @return mixed + */ + abstract public function getData(); + + /** + * Execute the query and set the paginator + * - with sort statements + * - with filters statements + */ + abstract public function execute(); } diff --git a/src/ZfcDatagrid/Renderer/AbstractRenderer.php b/src/ZfcDatagrid/Renderer/AbstractRenderer.php index 19f13558..15d7e421 100644 --- a/src/ZfcDatagrid/Renderer/AbstractRenderer.php +++ b/src/ZfcDatagrid/Renderer/AbstractRenderer.php @@ -14,8 +14,16 @@ abstract class AbstractRenderer implements RendererInterface { + /** + * + * @var array + */ protected $options = []; + /** + * + * @var string + */ protected $title; /** @@ -700,4 +708,30 @@ public function prepareViewModel(Datagrid $grid) $viewModel->setVariable('exportRenderers', $grid->getExportRenderers()); } + + /** + * Return the name of the renderer + * @return string + */ + abstract public function getName(); + + /** + * Determine if the renderer is for export + * @return boolean + */ + abstract public function isExport(); + + /** + * Determin if the renderer is HTML + * It can be export + html -> f.x. + * printing for HTML + * @return boolean + */ + abstract public function isHtml(); + + /** + * Execute all... + * @return ViewModel Response\Stream + */ + abstract public function execute(); }