Skip to content

Commit

Permalink
Replaced all array() with short syntax (#1177)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinOrlowski authored and lorenzo committed Sep 9, 2017
1 parent c1d51fd commit 9514ebf
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 65 deletions.
30 changes: 15 additions & 15 deletions docs/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,23 @@ configuration file may be the computed output of a PHP file as a PHP array:
.. code-block:: php
<?php
return array(
"paths" => array(
return [
"paths" => [
"migrations" => "application/migrations"
),
"environments" => array(
],
"environments" => [
"default_migration_table" => "phinxlog",
"default_database" => "dev",
"dev" => array(
"dev" => [
"adapter" => "mysql",
"host" => $_ENV['DB_HOST'],
"name" => $_ENV['DB_NAME'],
"user" => $_ENV['DB_USER'],
"pass" => $_ENV['DB_PASS'],
"port" => $_ENV['DB_PORT']
)
)
);
]
]
];
Phinx auto-detects which language parser to use for files with ``*.yml`` and ``*.php`` extensions. The appropriate
parser may also be specified via the ``--parser`` and ``-p`` parameters. Anything other than ``"php"`` is treated as YAML.
Expand All @@ -248,19 +248,19 @@ the database name too, as Phinx requires this for certain methods such as ``hasT
.. code-block:: php
<?php
return array(
"paths" => array(
return [
"paths" => [
"migrations" => "application/migrations"
),
"environments" => array(
"environments" => [
"default_migration_table" => "phinxlog",
"default_database" => "dev",
"dev" => array(
"dev" => [
"name" => "dev_db",
"connection" => $pdo_instance
)
)
);
]
]
];
Running Phinx in a Web App
--------------------------
Expand Down
13 changes: 6 additions & 7 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ This means that:
global $app;
$pdo = $app->getDatabase()->getPdo();
return array('environments' =>
array(
return ['environments' => [
'default_database' => 'development',
'development' => array(
'development' => [
'name' => 'devdb',
'connection' => $pdo
)
)
);
]
]
];
Migration Paths
---------------
Expand Down Expand Up @@ -308,4 +307,4 @@ When rolling back or printing the status of migrations, Phinx orders the execute
``version_order`` option, which can have the following values:

* ``creation`` (the default): migrations are ordered by their creation time, which is also part of their filename.
* ``execution``: migrations are ordered by their execution time, also known as start time.
* ``execution``: migrations are ordered by their execution time, also known as start time.
76 changes: 39 additions & 37 deletions docs/migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,15 @@ store a collection of users.
public function up()
{
$users = $this->table('users');
$users->addColumn('username', 'string', array('limit' => 20))
->addColumn('password', 'string', array('limit' => 40))
->addColumn('password_salt', 'string', array('limit' => 40))
->addColumn('email', 'string', array('limit' => 100))
->addColumn('first_name', 'string', array('limit' => 30))
->addColumn('last_name', 'string', array('limit' => 30))
$users->addColumn('username', 'string', ['limit' => 20])
->addColumn('password', 'string', ['limit' => 40])
->addColumn('password_salt', 'string', ['limit' => 40])
->addColumn('email', 'string', ['limit' => 100])
->addColumn('first_name', 'string', ['limit' => 30])
->addColumn('last_name', 'string', ['limit' => 30])
->addColumn('created', 'datetime')
->addColumn('updated', 'datetime', array('null' => true))
->addIndex(array('username', 'email'), array('unique' => true))
->addColumn('updated', 'datetime', ['null' => true])
->addIndex(['username', 'email'], ['unique' => true])
->save();
}
Expand Down Expand Up @@ -444,7 +444,7 @@ create a primary key using two columns instead:
*/
public function up()
{
$table = $this->table('followers', array('id' => false, 'primary_key' => array('user_id', 'follower_id')));
$table = $this->table('followers', ['id' => false, 'primary_key' => ['user_id', 'follower_id']]);
$table->addColumn('user_id', 'integer')
->addColumn('follower_id', 'integer')
->addColumn('created', 'datetime')
Expand Down Expand Up @@ -476,9 +476,9 @@ To simply change the name of the primary key, we need to override the default ``
*/
public function up()
{
$table = $this->table('followers', array('id' => 'user_id'));
$table = $this->table('followers', ['id' => 'user_id']);
$table->addColumn('follower_id', 'integer')
->addColumn('created', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))
->addColumn('created', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
->save();
}
Expand Down Expand Up @@ -518,9 +518,9 @@ To simply set it to unsigned just pass ``signed`` option with a ``false`` value:
*/
public function up()
{
$table = $this->table('followers', array('signed' => false));
$table = $this->table('followers', ['signed' => false]);
$table->addColumn('follower_id', 'integer')
->addColumn('created', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))
->addColumn('created', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
->save();
}
Expand Down Expand Up @@ -622,15 +622,15 @@ good idea to recreate the table again in the ``down()`` method.
public function down()
{
$users = $this->table('users');
$users->addColumn('username', 'string', array('limit' => 20))
->addColumn('password', 'string', array('limit' => 40))
->addColumn('password_salt', 'string', array('limit' => 40))
->addColumn('email', 'string', array('limit' => 100))
->addColumn('first_name', 'string', array('limit' => 30))
->addColumn('last_name', 'string', array('limit' => 30))
$users->addColumn('username', 'string', ['limit' => 20])
->addColumn('password', 'string', ['limit' => 40])
->addColumn('password_salt', 'string', ['limit' => 40])
->addColumn('email', 'string', ['limit' => 100])
->addColumn('first_name', 'string', ['limit' => 30])
->addColumn('last_name', 'string', ['limit' => 30])
->addColumn('created', 'datetime')
->addColumn('updated', 'datetime', array('null' => true))
->addIndex(array('username', 'email'), array('unique' => true))
->addColumn('updated', 'datetime', ['null' => true])
->addIndex(['username', 'email'], ['unique' => true])
->save();
}
}
Expand Down Expand Up @@ -822,7 +822,7 @@ INT_SMALL SMALLINT
$table = $this->table('cart_items');
$table->addColumn('user_id', 'integer')
->addColumn('subtype_id', 'integer', array('limit' => PostgresAdapter::INT_SMALL))
->addColumn('subtype_id', 'integer', ['limit' => PostgresAdapter::INT_SMALL])
->create();
Limit Option and MySQL
Expand Down Expand Up @@ -858,9 +858,9 @@ INT_BIG BIGINT
$table = $this->table('cart_items');
$table->addColumn('user_id', 'integer')
->addColumn('product_id', 'integer', array('limit' => MysqlAdapter::INT_BIG))
->addColumn('subtype_id', 'integer', array('limit' => MysqlAdapter::INT_SMALL))
->addColumn('quantity', 'integer', array('limit' => MysqlAdapter::INT_TINY))
->addColumn('product_id', 'integer', ['limit' => MysqlAdapter::INT_BIG])
->addColumn('subtype_id', 'integer', ['limit' => MysqlAdapter::INT_SMALL])
->addColumn('quantity', 'integer', ['limit' => MysqlAdapter::INT_TINY])
->create();
Expand Down Expand Up @@ -977,7 +977,7 @@ When adding a column you can dictate its position using the ``after`` option.
public function change()
{
$table = $this->table('users');
$table->addColumn('city', 'string', array('after' => 'email'))
$table->addColumn('city', 'string', ['after' => 'email'])
->update();
}
}
Expand Down Expand Up @@ -1026,7 +1026,7 @@ You can limit the maximum length of a column by using the ``limit`` option.
public function change()
{
$table = $this->table('tags');
$table->addColumn('short_name', 'string', array('limit' => 30))
$table->addColumn('short_name', 'string', ['limit' => 30])
->update();
}
}
Expand All @@ -1051,7 +1051,7 @@ See `Valid Column Types`_ and `Valid Column Options`_ for allowed values.
public function up()
{
$users = $this->table('users');
$users->changeColumn('email', 'string', array('limit' => 255))
$users->changeColumn('email', 'string', ['limit' => 255])
->save();
}
Expand Down Expand Up @@ -1085,7 +1085,7 @@ table object.
{
$table = $this->table('users');
$table->addColumn('city', 'string')
->addIndex(array('city'))
->addIndex(['city'])
->save();
}
Expand Down Expand Up @@ -1118,7 +1118,9 @@ using the ``name`` parameter.
{
$table = $this->table('users');
$table->addColumn('email', 'string')
->addIndex(array('email'), array('unique' => true, 'name' => 'idx_users_email'))
->addIndex(['email'], [
'unique' => true,
'name' => 'idx_users_email'])
->save();
}
Expand Down Expand Up @@ -1168,7 +1170,7 @@ call this method for each index.
public function up()
{
$table = $this->table('users');
$table->removeIndex(array('email'));
$table->removeIndex(['email']);
// alternatively, you can delete an index by its name, ie:
$table->removeIndexByName('idx_users_email');
Expand Down Expand Up @@ -1213,7 +1215,7 @@ Let's add a foreign key to an example table:
$refTable = $this->table('tag_relationships');
$refTable->addColumn('tag_id', 'integer')
->addForeignKey('tag_id', 'tags', 'id', array('delete'=> 'SET_NULL', 'update'=> 'NO_ACTION'))
->addForeignKey('tag_id', 'tags', 'id', ['delete'=> 'SET_NULL', 'update'=> 'NO_ACTION'])
->save();
}
Expand Down Expand Up @@ -1250,10 +1252,10 @@ This allows us to establish a foreign key relationship to a table which uses a c
$table->addColumn('user_id', 'integer')
->addColumn('follower_id', 'integer')
->addColumn('event_id', 'integer')
->addForeignKey(array('user_id', 'follower_id'),
->addForeignKey(['user_id', 'follower_id'],
'followers',
array('user_id', 'follower_id'),
array('delete'=> 'NO_ACTION', 'update'=> 'NO_ACTION', 'constraint' => 'user_follower_id'))
['user_id', 'follower_id'],
['delete'=> 'NO_ACTION', 'update'=> 'NO_ACTION', 'constraint' => 'user_follower_id'])
->save();
}
Expand Down Expand Up @@ -1282,8 +1284,8 @@ We can add named foreign keys using the ``constraint`` parameter. This feature i
public function up()
{
$table = $this->table('your_table');
$table->addForeignKey('foreign_id', 'reference_table', array('id'),
array('constraint'=>'your_foreign_key_name'));
$table->addForeignKey('foreign_id', 'reference_table', ['id'],
['constraint' => 'your_foreign_key_name']);
->save();
}
Expand Down
11 changes: 5 additions & 6 deletions docs/seeding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,15 @@ within your seed class and then use the `insert()` method to insert data:
{
public function run()
{
$data = array(
array(
$data = [
[
'body' => 'foo',
'created' => date('Y-m-d H:i:s'),
),
array(
],[
'body' => 'bar',
'created' => date('Y-m-d H:i:s'),
)
);
]
];
$posts = $this->table('posts');
$posts->insert($data)
Expand Down

0 comments on commit 9514ebf

Please sign in to comment.