Skip to content

Commit

Permalink
Fix docs CS (#980)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 11, 2022
1 parent 7e12b6c commit cf58e1d
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 40 deletions.
8 changes: 4 additions & 4 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ we cannot close amount that is bigger than invoice's total::
$i->ref('Payment')->insert([
'amount' => $paid,
'amount_closed' => min($paid, $i->get('total')),
'payment_code' => 'XYZ'
'payment_code' => 'XYZ',
]);

Having some calculated fields for the invoice is handy. I'm adding `total_payments`
Expand Down Expand Up @@ -643,7 +643,7 @@ to make things easier::
$m->insert([
'total' => 20,
'client_code' => $client_code,
'category' => $category
'category' => $category,
]);

Here is how to add them. First you need to create fields::
Expand Down Expand Up @@ -701,7 +701,7 @@ If you wish to use a different value instead, you can create an expression::
$c->addCondition($c->title_field, 'like', $m->get('category'));
$m->set('category_id', $this->expr('coalesce([], [])',[
$c->action('field',['id']),
$m->getField('category_id')->default
$m->getField('category_id')->default,
]));
}

Expand Down Expand Up @@ -729,7 +729,7 @@ information. Here is usage example::
'lines' => [
['descr' => 'Book','qty' => 3, 'price' => 5]
['descr' => 'Pencil','qty' => 1, 'price' => 10]
['descr' => 'Eraser','qty' => 2, 'price' => 2.5]
['descr' => 'Eraser','qty' => 2, 'price' => 2.5],
],
]);

Expand Down
4 changes: 2 additions & 2 deletions docs/conditions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ of objects as well as actions::
$m->expr('[age] between [min_age] and [max_age]'),
[
'min_age' => $m->action('min', ['age']),
'max_age' => $m->expr('(20 + [])', [20])
'max_age' => $m->expr('(20 + [])', [20]),
]
);

Expand Down Expand Up @@ -312,7 +312,7 @@ Creates a Scope object from an array::
// below will create 2 conditions and nest them in a compound conditions with AND junction
$scope1 = new Scope([
['name', 'like', 'ABC%'],
['country', 'US']
['country', 'US'],
]);

.. php:method:: negate();
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinxcontrib.phpdomain'
#'sphinxcontrib_phpautodoc'
#'sphinxcontrib_phpautodoc',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -233,7 +233,7 @@
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'agile-data', u'Agile Data Documentation',
[u'Agile Toolkit'], 1)
[u'Agile Toolkit'], 1),
]

# If true, show URL addresses after external links.
Expand Down
12 changes: 6 additions & 6 deletions docs/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -498,16 +498,16 @@ Finally the code above will work even if you use a simple Array as a data source
'email' => 'joe@yahoo.com',
'Orders' => [
['amount' => 10],
['amount' => 20]
]
['amount' => 20],
],
],[
'name' => 'Bill',
'email' => 'bill@yahoo.com',
'Orders' => [
['amount' => 35]
]
]
]
['amount' => 35],
],
],
],
]);

So getting back to the operation above, lets look at it in more details::
Expand Down
2 changes: 1 addition & 1 deletion docs/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ values for the other fields including other expressions.
There are other ways how you can specify expression::

$m->addExpression('total_gross', [
'expr' => $m->expr('[total_net] + [total_vat] + [fee]', ['fee' => $fee])
'expr' => $m->expr('[total_net] + [total_vat] + [fee]', ['fee' => $fee]),
]);

This format allow you to supply additional parameters inside expression.
Expand Down
4 changes: 2 additions & 2 deletions docs/joins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ like this: foreign_table.'_id'. Here is usage example::
$user->addField('username');
$j_cc = $user->join('credit_card', [
'prefix' => 'cc_',
'master_field' => 'default_credit_card_id'
'master_field' => 'default_credit_card_id',
]);
$j_cc->addField('integer'); // creates cc_number
$j_cc->addField('name'); // creates cc_name
Expand Down Expand Up @@ -281,7 +281,7 @@ When you're dealing with SQL drivers, you can specify `\Atk4\Data\Persistence\Sq

$stats = $user->join('stats', [
'on' => $user->expr('year({}) = _st.year'),
'foreign_alias' => '_st'
'foreign_alias' => '_st',
]);

You can also specify ``'on' => false`` then the ON clause will not be used at all
Expand Down
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ It can be made even simpler::

$htmltable->setModel(new Model(new Persistence\Static_([
'John',
'Peter'
'Peter',
])));

echo $htmltable->render();
Expand Down
2 changes: 1 addition & 1 deletion docs/persistence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Note that `read_only` can still have a default value::
$m->addField('created', [
'read_only' => true,
'type' => 'datetime',
'default' => new DateTime()
'default' => new DateTime(),
]);

$m->save(); // stores creation time just fine and also will loade it.
Expand Down
8 changes: 4 additions & 4 deletions docs/persistence/sql/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Finally, you can pass connection class into :php:meth:`execute` directly.

$data = new Expression([
'connection' => $pdo_dbh,
'template' => 'show databases'
'template' => 'show databases',
])->getRows();
echo json_encode($data);

Expand All @@ -218,7 +218,7 @@ Finally, you can pass connection class into :php:meth:`execute` directly.
[
{ "Database": "mydb1" },
{ "Database": "mysql" },
{ "Database": "test" }
{ "Database": "test" },
]
Expand All @@ -228,7 +228,7 @@ Finally, you can pass connection class into :php:meth:`execute` directly.

$data = new Expression([
'connection' => $pdo_dbh,
'template' => 'SELECT @@global.time_zone, @@session.time_zone'
'template' => 'SELECT @@global.time_zone, @@session.time_zone',
])->getRow()

echo json_encode($data);
Expand All @@ -246,7 +246,7 @@ Finally, you can pass connection class into :php:meth:`execute` directly.

$time = new Expression([
'connection' => $pdo_dbh,
'template' => 'now()'
'template' => 'now()',
])->getOne();

Magic an Debug Methods
Expand Down
2 changes: 1 addition & 1 deletion docs/persistence/sql/queries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ tables so you need a different syntax::
$q->join([
'a' => 'address.user_id',
'c' => 'credit_card.user_id',
'preferences.user_id'
'preferences.user_id',
]);

The second argument to join specifies which existing table/field is
Expand Down
8 changes: 4 additions & 4 deletions docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ You can reference fields by using square brackets here. Also you may pass `args`
containing your optional arguments::

->addField('len', [
'expr' => 'sum(if([date] = [exp_date], 1, 0))',
'args' => ['exp_date' => '2003-03-04]
'expr' => 'sum(if([date] = [exp_date], 1, 0))',
'args' => ['exp_date' => '2003-03-04],
]),

Alternatively you may also specify either 'aggregate'::

$book->hasMany('Pages', ['model' => [Page::class]])
->addField('page_list', [
'aggregate' => $book->refModel('Pages')->expr('group_concat([number], [])', ['-'])
'aggregate' => $book->refModel('Pages')->expr('group_concat([number], [])', ['-']),
]);


Expand Down Expand Up @@ -376,7 +376,7 @@ be renamed, just as we did above::
'address_1',
'address_2',
'address_3',
'address_notes' => ['notes', 'type' => 'text']
'address_notes' => ['notes', 'type' => 'text'],
]);

Above, all ``address_`` fields are copied with the same name, however field
Expand Down
14 changes: 7 additions & 7 deletions docs/sql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ SQL Reference
$model->hasOne('account_id', ['model' => [Account::class]])
->addFields([
'opening_balance',
'balance'
'balance',
], ['type' => 'atk4_money']);

You can also specify aliases::

$model->hasOne('account_id', ['model' => [Account::class]])
->addFields([
'opening_balance',
'account_balance' => 'balance'
'account_balance' => 'balance',
], ['type' => 'atk4_money']);

If you need to pass more details to individual field, you can also use sub-array::
Expand All @@ -95,7 +95,7 @@ SQL Reference
->addFields([
[
['opening_balance', 'caption' => 'The Opening Balance'],
'account_balance' => 'balance'
'account_balance' => 'balance',
], ['type' => 'atk4_money']);

Returns $this.
Expand Down Expand Up @@ -205,7 +205,7 @@ field expressions will be automatically substituted. Here is long / short format

$q = new \Atk4\Data\Persistence\Sql\Expression('[age] + [birth_year]', [
'age' => $m->getField('age'),
'birth_year' => $m->getField('birth_year')
'birth_year' => $m->getField('birth_year'),
]);

// identical to
Expand Down Expand Up @@ -334,13 +334,13 @@ In short this should allow you to build and execute any SQL statement::

$this->expr("call get_nominal_sheet([], [], '2014-10-01', '2015-09-30', 0)", [
$this->getApp()->system->getId(),
$this->getApp()->system['contractor_id']
$this->getApp()->system['contractor_id'],
])->execute();

Depending on the statement you can also use your statement to retrieve data::

$data = $this->expr("call get_client_report_data([client_id])", [
'client_id' => $client_id
'client_id' => $client_id,
])->getRows();

This can be handy if you wish to create a method for your Model to abstract away
Expand Down Expand Up @@ -468,7 +468,7 @@ procedure inside Model::init() then set $table property to a temporary table::

$res = $this->expr("call get_nominal_sheet([], [], '2014-10-01', '2015-09-30', 0)", [
$this->getApp()->system->getId(),
$this->getApp()->system['contractor_id']
$this->getApp()->system['contractor_id'],
])->execute();

$this->addField('date', ['type' => 'date']);
Expand Down
4 changes: 2 additions & 2 deletions docs/typecasting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ to it::
$m->addField('registered', [
'type' => 'date',
'persist_format' => 'd/m/Y',
'persist_timezone' => 'IST'
'persist_timezone' => 'IST',
]);

Here is another example with booleans::

$m->addField('is_married', [
'type' => 'boolean',
'enum' => ['No', 'Yes']
'enum' => ['No', 'Yes'],
]);

$m->set('is_married', 'Yes'); // normalizes into true
Expand Down
3 changes: 1 addition & 2 deletions tests/ModelNestedArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public function testSelectExport(): void
['name' => 'Sue', 'birthday' => new \DateTime('2005-4-3')],
], $m->export());

$this->assertSame([
], $this->hookLog);
$this->assertSame([], $this->hookLog);
}

public function testInsert(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/SmboTransferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function testBasicEntities(): void
'nominal' => 'Sales:Discounted',
'total_net' => 50.0,
'vat_rate' => 23,
// calculates total_gross at 61.5.
// calculates total_gross at 61.5
],
[
'item_id' => $john->ref('Service')->insert('Delivery'),
Expand Down

0 comments on commit cf58e1d

Please sign in to comment.