Skip to content

Commit

Permalink
Add table to the debug info, and remove toArray()
Browse files Browse the repository at this point in the history
The toArray() method doesn't really offer much utility given that it is
an alias for __debugInfo(). We also don't generally add toArray() to
objects unless it is easy to convert that array back into an object of
the same type again.
  • Loading branch information
markstory committed Oct 28, 2017
1 parent 66a424b commit 307b91c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 53 deletions.
13 changes: 2 additions & 11 deletions src/Database/Schema/TableSchema.php
Expand Up @@ -840,9 +840,10 @@ public function dropConstraintSql(Connection $connection)
*
* @return array
*/
public function toArray()
public function __debugInfo()
{
return [
'table' => $this->_table,
'columns' => $this->_columns,
'indexes' => $this->_indexes,
'constraints' => $this->_constraints,
Expand All @@ -851,16 +852,6 @@ public function toArray()
'temporary' => $this->_temporary,
];
}

/**
* Returns an array of the table schema.
*
* @return array
*/
public function __debugInfo()
{
return $this->toArray();
}
}

// @deprecated Add backwards compat alias.
Expand Down
42 changes: 0 additions & 42 deletions tests/TestCase/Database/Schema/TableTest.php
Expand Up @@ -662,48 +662,6 @@ public function testTemporary()
$this->assertFalse($table->temporary());
}

/**
* Tests the toArray() method.
*
* @return void
*/
public function testToArray()
{
$table = new Table('articles');
$result = $table->toArray();
$expected = [
'columns' => [],
'indexes' => [],
'constraints' => [],
'options' => [],
'typeMap' => [],
'temporary' => false,
];
$this->assertSame($expected, $result);
}

/**
* Tests the __debugInfo() method.
*
* @return void
*/
public function testDebugInfo()
{
$table = new Table('articles');
$table->setTemporary(true);

$result = $table->__debugInfo();
$expected = [
'columns' => [],
'indexes' => [],
'constraints' => [],
'options' => [],
'typeMap' => [],
'temporary' => true,
];
$this->assertSame($expected, $result);
}

/**
* Assertion for comparing a regex pattern against a query having its identifiers
* quoted. It accepts queries quoted with the characters `<` and `>`. If the third
Expand Down

0 comments on commit 307b91c

Please sign in to comment.