Skip to content

Commit dacb98f

Browse files
Codestyle fixes
1 parent e627ad4 commit dacb98f

File tree

7 files changed

+133
-17
lines changed

7 files changed

+133
-17
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
> Questions should go to https://forum.phalcon.io
2+
> Documentation issues should go to https://github.com/phalcon/docs/issues
3+
4+
### Expected and Actual Behavior
5+
6+
> **Describe what you are trying to achieve and what goes wrong.**
7+
8+
> Provide output if related
9+
10+
```php
11+
// paste output here
12+
```
13+
> Provide minimal script to reproduce the issue
14+
15+
```php
16+
// paste code
17+
```
18+
19+
### Details
20+
21+
* System info and versions (if possible): (`phalcon info`)
22+
* Phalcon Framework version: (`php --ri phalcon`)
23+
* PHP Version: (`php -v`)
24+
* Operating System:
25+
* Server: Nginx | Apache | Other
26+
* Other related info (Database, table schema):

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Hello!
2+
3+
* Type: bug fix | new feature | code quality | documentation
4+
* Link to issue:
5+
6+
**In raising this pull request, I confirm the following (please check boxes):**
7+
8+
- [ ] I have read and understood the [Contributing Guidelines][:contrib:]
9+
- [ ] I have checked that another pull request for this purpose does not exist
10+
- [ ] I wrote some tests for this PR
11+
12+
Small description of change:
13+
14+
Thanks
15+
16+
[:contrib:]: https://github.com/phalcon/migrations/blob/master/CONTRIBUTING.md

CONTRIBUTING.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Contributing to Phalcon Migrations Utility
2+
3+
Phalcon Migrations Utility is an open source project and a volunteer effort.
4+
Phalcon Migrations Utility welcomes contribution from everyone.
5+
6+
## Contributions
7+
8+
Contributions to Phalcon Migrations Utility should be made in the form of [GitHub pull requests][pr].
9+
Each pull request will be reviewed by a core contributor (someone with permission to land patches) and either landed in
10+
the main tree or given feedback for changes that would be required before it can be merged. All contributions should
11+
follow this format, even those from core contributors.
12+
13+
## Questions & Support
14+
15+
*We only accept bug reports, new feature requests and pull requests in GitHub*.
16+
For questions regarding the usage of the Phalcon Migrations Utility or support requests please visit the
17+
[official forums][forum]. IDE stubs must not be modified manually, if you want to improve them please submit a PR
18+
to [Phalcon Framework][cphalcon].
19+
20+
## Bug Report Checklist
21+
22+
- Make sure you are using the latest released version of Phalcon Framework and Phalcon Migrations Utility
23+
before submitting a bug report. Bugs in versions older than the latest released one will not be addressed by the
24+
core team
25+
26+
- If you have found a bug it is important to add relevant reproducibility information to your issue to allow us
27+
to reproduce the bug and fix it quicker. Add a script, small program or repository providing the necessary code to
28+
make everyone reproduce the issue reported easily. If a bug cannot be reproduced by the development it would be
29+
difficult provide corrections and solutions. [Submit Reproducible Test][srt] for more information.
30+
31+
- Be sure that information such as OS, Phalcon Framework and Phalcon Migrations Utility versions and PHP version are
32+
part of the bug report
33+
34+
- If you're submitting a Segmentation Fault error, we would require a backtrace, please see [Generating a Backtrace][gb]
35+
36+
## Pull Request Checklist
37+
38+
- Don't submit your pull requests to the `master` branch. Branch from the required branch and,
39+
if needed, rebase to the proper branch before submitting your pull request.
40+
If it doesn't merge cleanly with master you may be asked to rebase your changes
41+
42+
- Don't put submodule updates, composer.lock, etc in your pull request unless they are to landed commits
43+
44+
- Make sure that the code you write fits with the general style and coding standards of the [Accepted PHP Standards][psr]
45+
46+
## Getting Support
47+
48+
If you have a question about how to use Phalcon, please see the [support page][support].
49+
50+
## Requesting Features
51+
52+
If you have a change or new feature in mind, please fill an [NFR][nfr].
53+
54+
Thanks! <br />
55+
Phalcon Team
56+
57+
58+
[pr]: https://help.github.com/articles/about-pull-requests/
59+
[forum]: https://forum.phalcon.io/
60+
[cphalcon]: https://github.com/phalcon/cphalcon
61+
[srt]: https://docs.phalcon.io/en/latest/reproducible-tests
62+
[gb]: https://docs.phalcon.io/en/latest/generating-backtrace
63+
[support]: https://phalcon.io/en/support/
64+
[nfr]: https://docs.phalcon.io/en/latest/new-feature-request
65+
[psr]: https://www.php-fig.org/psr/

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"codeception/module-cli": "^1.0",
4343
"codeception/module-phpbrowser": "^1.0.0",
4444
"codeception/module-db": "^1.0",
45+
"vimeo/psalm": "^4.6",
4546
"vlucas/phpdotenv": "^4.1"
4647
},
4748
"autoload": {

src/Console/Commands/Migration.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@ public function run(): void
8686
} else {
8787
$config = $this->getConfig($path);
8888
}
89+
$application = $config->get('application') ?? [];
8990

9091
// Multiple dir
9192
$migrationsDir = [];
9293
if ($this->parser->has('migrations')) {
9394
$migrationsDir = explode(',', $this->parser->get('migrations'));
94-
} elseif (isset($config['application']['migrationsDir'])) {
95-
$migrationsDir = explode(',', $config['application']['migrationsDir']);
95+
} elseif (isset($application['migrationsDir'])) {
96+
$migrationsDir = explode(',', $application['migrationsDir']);
9697
}
9798

9899
if (!empty($migrationsDir)) {
@@ -113,19 +114,20 @@ public function run(): void
113114
* Keep migrations log in db either "log-in-db" option or "logInDb"
114115
* config variable from "application" block
115116
*/
116-
$migrationsInDb = $config['application']['logInDb'] ?? $this->parser->has('log-in-db');
117+
$migrationsInDb = $application['logInDb'] ?? $this->parser->has('log-in-db');
117118

118119
/**
119120
* Migrations naming is timestamp-based rather than traditional, dotted versions
120121
* either "ts-based" option or "migrationsTsBased" config variable from "application" block
121122
*/
122-
$migrationsTsBased = $config['application']['migrationsTsBased'] ?? $this->parser->has('ts-based');
123+
$migrationsTsBased = $application['migrationsTsBased'] ?? $this->parser->has('ts-based');
123124

124-
$noAutoIncrement = $config['application']['no-auto-increment'] ?? $this->parser->has('no-auto-increment');
125-
$skipRefSchema = $config['application']['skip-ref-schema'] ?? $this->parser->has('skip-ref-schema');
126-
$skipForeignChecks = $config['application']['skip-foreign-checks'] ?? $this->parser->has('skip-foreign-checks');
127125

128-
$descr = $config['application']['descr'] ?? $this->parser->get('descr');
126+
$noAutoIncrement = $application['no-auto-increment'] ?? $this->parser->has('no-auto-increment');
127+
$skipRefSchema = $application['skip-ref-schema'] ?? $this->parser->has('skip-ref-schema');
128+
$skipForeignChecks = $application['skip-foreign-checks'] ?? $this->parser->has('skip-foreign-checks');
129+
130+
$descr = $application['descr'] ?? $this->parser->get('descr');
129131
$tableName = $this->parser->get('table', '@');
130132

131133
switch ($action) {
@@ -210,11 +212,12 @@ public function getHelp(): void
210212
protected function exportFromTables($config): array
211213
{
212214
$tables = [];
215+
$application = $config->get('application') ?? [];
213216

214217
if ($this->parser->has('exportDataFromTables')) {
215218
$tables = explode(',', $this->parser->get('exportDataFromTables'));
216-
} elseif (isset($config['application']['exportDataFromTables'])) {
217-
$configTables = $config['application']['exportDataFromTables'];
219+
} elseif (isset($application['exportDataFromTables'])) {
220+
$configTables = $application['exportDataFromTables'];
218221
if ($configTables instanceof Config) {
219222
$tables = $configTables->toArray();
220223
} else {

src/Migrations.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,15 @@ public static function run(array $options)
333333
) {
334334
continue;
335335
}
336-
if ((ModelMigration::DIRECTION_FORWARD === $direction)
336+
if (
337+
ModelMigration::DIRECTION_FORWARD === $direction
337338
&& isset($completedVersions[(string)$versionItem])
338339
) {
339340
print Color::info('Version ' . (string)$versionItem . ' was already applied');
340341
continue;
341342
}
342-
if ((ModelMigration::DIRECTION_BACK === $direction)
343+
if (
344+
ModelMigration::DIRECTION_BACK === $direction
343345
&& !isset($completedVersions[(string)$initialVersion])
344346
) {
345347
print Color::info('Version ' . (string)$initialVersion . ' was already rolled back');

src/Mvc/Model/Migration.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,17 @@ public function morphTable(string $tableName, array $definition): void
697697
$changed = true;
698698
}
699699

700-
if (!$changed &&
701-
count($tableReference->getColumns()) !==
700+
if (
701+
!$changed
702+
&& count($tableReference->getColumns()) !==
702703
count($localReferences[$tableReference->getName()]['columns'])
703704
) {
704705
$changed = true;
705706
}
706707

707-
if (!$changed &&
708-
count($tableReference->getReferencedColumns()) !==
708+
if (
709+
!$changed
710+
&& count($tableReference->getReferencedColumns()) !==
709711
count($localReferences[$tableReference->getName()]['referencedColumns'])
710712
) {
711713
$changed = true;
@@ -722,7 +724,8 @@ public function morphTable(string $tableName, array $definition): void
722724

723725
if (!$changed) {
724726
foreach ($tableReference->getReferencedColumns() as $columnName) {
725-
if (!in_array($columnName, $localReferences[$tableReference->getName()]['referencedColumns'], true)) {
727+
$referencedColumns = $localReferences[$tableReference->getName()]['referencedColumns'];
728+
if (!in_array($columnName, $referencedColumns, true)) {
726729
$changed = true;
727730
break;
728731
}

0 commit comments

Comments
 (0)