Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Fix for PHP 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Oct 31, 2017
1 parent 748f065 commit dcf62d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/Metadata/Source/AbstractSource.php
Expand Up @@ -11,7 +11,12 @@

use Zend\Db\Adapter\Adapter;
use Zend\Db\Metadata\MetadataInterface;
use Zend\Db\Metadata\Object;
use Zend\Db\Metadata\Object\TableObject;
use Zend\Db\Metadata\Object\ViewObject;
use Zend\Db\Metadata\Object\ColumnObject;
use Zend\Db\Metadata\Object\ConstraintObject;
use Zend\Db\Metadata\Object\ConstraintKeyObject;
use Zend\Db\Metadata\Object\TriggerObject;

abstract class AbstractSource implements MetadataInterface
{
Expand Down Expand Up @@ -115,10 +120,10 @@ public function getTable($tableName, $schema = null)
$data = $this->data['table_names'][$schema][$tableName];
switch ($data['table_type']) {
case 'BASE TABLE':
$table = new Object\TableObject($tableName);
$table = new TableObject($tableName);
break;
case 'VIEW':
$table = new Object\ViewObject($tableName);
$table = new ViewObject($tableName);
$table->setViewDefinition($data['view_definition']);
$table->setCheckOption($data['check_option']);
$table->setIsUpdatable($data['is_updatable']);
Expand Down Expand Up @@ -238,7 +243,7 @@ public function getColumn($columnName, $table, $schema = null)

$info = $this->data['columns'][$schema][$table][$columnName];

$column = new Object\ColumnObject($columnName, $table, $schema);
$column = new ColumnObject($columnName, $table, $schema);
$props = [
'ordinal_position', 'column_default', 'is_nullable',
'data_type', 'character_maximum_length', 'character_octet_length',
Expand Down Expand Up @@ -300,7 +305,7 @@ public function getConstraint($constraintName, $table, $schema = null)
}

$info = $this->data['constraints'][$schema][$table][$constraintName];
$constraint = new Object\ConstraintObject($constraintName, $table, $schema);
$constraint = new ConstraintObject($constraintName, $table, $schema);

foreach ([
'constraint_type' => 'setType',
Expand Down Expand Up @@ -345,7 +350,7 @@ public function getConstraintKeys($constraint, $table, $schema = null)
$keys = [];
foreach ($this->data['constraint_keys'][$schema] as $constraintKeyInfo) {
if ($constraintKeyInfo['table_name'] == $table && $constraintKeyInfo['constraint_name'] === $constraint) {
$keys[] = $key = new Object\ConstraintKeyObject($constraintKeyInfo['column_name']);
$keys[] = $key = new ConstraintKeyObject($constraintKeyInfo['column_name']);
$key->setOrdinalPosition($constraintKeyInfo['ordinal_position']);
if (isset($references[$constraint])) {
//$key->setReferencedTableSchema($constraintKeyInfo['referenced_table_schema']);
Expand Down Expand Up @@ -408,7 +413,7 @@ public function getTrigger($triggerName, $schema = null)

$info = $this->data['triggers'][$schema][$triggerName];

$trigger = new Object\TriggerObject();
$trigger = new TriggerObject();

$trigger->setName($triggerName);
$trigger->setEventManipulation($info['event_manipulation']);
Expand Down
7 changes: 6 additions & 1 deletion src/Sql/AbstractSql.php
Expand Up @@ -241,7 +241,12 @@ protected function createSqlFromSpecificationAndParameters($specifications, $par
if (isset($paramSpecs[$position]['combinedby'])) {
$multiParamValues = [];
foreach ($paramsForPosition as $multiParamsForPosition) {
$ppCount = count($multiParamsForPosition);
if (is_array($multiParamsForPosition) || $multiParamsForPosition instanceof Countable) {
$ppCount = count($multiParamsForPosition);
} elseif (is_string($multiParamsForPosition)) {
$ppCount = 1;
}

if (!isset($paramSpecs[$position][$ppCount])) {
throw new Exception\RuntimeException(sprintf(
'A number of parameters (%d) was found that is not supported by this specification',
Expand Down

0 comments on commit dcf62d3

Please sign in to comment.