Skip to content

Commit cae6758

Browse files
authored
Merge branch 'cakephp:0.x' into issue-2386
2 parents e8387c2 + 05dc104 commit cae6758

9 files changed

Lines changed: 74 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
6565

6666
- name: Cache composer dependencies
67-
uses: actions/cache@v4
67+
uses: actions/cache@v5
6868
with:
6969
path: ${{ steps.composer-cache.outputs.dir }}
7070
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
@@ -141,7 +141,7 @@ jobs:
141141
key: ${{ steps.key-date.outputs.date }}
142142

143143
- name: Cache PHP extensions
144-
uses: actions/cache@v4
144+
uses: actions/cache@v5
145145
with:
146146
path: ${{ steps.php-ext-cache.outputs.dir }}
147147
key: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
@@ -167,7 +167,7 @@ jobs:
167167
run: echo "dir=$(composer config cache-files-dir)" >> $env:GITHUB_OUTPUT
168168

169169
- name: Cache composer dependencies
170-
uses: actions/cache@v4
170+
uses: actions/cache@v5
171171
with:
172172
path: ${{ steps.composer-cache.outputs.dir }}
173173
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
@@ -209,7 +209,7 @@ jobs:
209209
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
210210

211211
- name: Cache composer dependencies
212-
uses: actions/cache@v4
212+
uses: actions/cache@v5
213213
with:
214214
path: ${{ steps.composer-cache.outputs.dir }}
215215
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}

.github/workflows/phar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
2323

2424
- name: Cache dependencies
25-
uses: actions/cache@v4
25+
uses: actions/cache@v5
2626
with:
2727
path: ${{ steps.composer-cache.outputs.dir }}
2828
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
"composer-runtime-api": "^2.0",
4141
"cakephp/database": "^5.0.2",
4242
"psr/container": "^1.1|^2.0",
43-
"symfony/config": "^4.0|^5.0|^6.0|^7.0",
44-
"symfony/console": "^6.0|^7.0"
43+
"symfony/config": "^4.0|^5.0|^6.0|^7.0|^8.0",
44+
"symfony/console": "^6.0|^7.0|^8.0"
4545
},
4646
"require-dev": {
4747
"ext-json": "*",
4848
"ext-pdo": "*",
4949
"cakephp/cakephp-codesniffer": "^5.0",
5050
"cakephp/i18n": "^5.0",
5151
"phpunit/phpunit": "^10.5",
52-
"symfony/yaml": "^4.0|^5.0|^6.0|^7.0"
52+
"symfony/yaml": "^4.0|^5.0|^6.0|^7.0|^8.0"
5353
},
5454
"autoload": {
5555
"psr-4": {

docs/en/configuration.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ For some breaking changes, Phinx offers a way to opt-out of new behavior. The fo
562562
* ``column_null_default``: Should Phinx create columns as null by default? (default: ``true``)
563563

564564
Since MySQL ``TIMESTAMP`` fields do not support dates past 2038-01-19, you have the option to use ``DATETIME`` field
565-
types for fields created by the ``addTimestamps()`` function:
565+
types for fields created by the ``addTimestamps()`` function. This setting also affects the start_time and end_time
566+
columns in the schema table:
566567

567568
* ``add_timestamps_use_datetime``: Should Phinx create created_at and updated_at fields as datetime? (default: ``false``)
568569

phpstan-baseline.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ parameters:
44
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
55
count: 1
66
path: src/Phinx/Db/Adapter/MysqlAdapter.php
7+
8+
-
9+
message: "#^Call to an undefined static method Symfony\\\\Component\\\\Console\\\\Application\\:\\:addCommand\\(\\)\\.$#"
10+
count: 1
11+
path: src/Phinx/Console/PhinxApplication.php
12+
reportUnmatched: false

src/Phinx/Config/FeatureFlags.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class FeatureFlags
2424
public static bool $columnNullDefault = true;
2525
/**
2626
* @var bool Should Phinx create datetime columns for addTimestamps instead of timestamp?
27+
* Also affects start_time and end_time column types in schema table.
2728
*/
2829
public static bool $addTimestampsUseDateTime = false;
2930

src/Phinx/Console/PhinxApplication.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Phinx\Console\Command\Status;
2121
use Phinx\Console\Command\Test;
2222
use Symfony\Component\Console\Application;
23+
use Symfony\Component\Console\Command\Command;
2324
use Symfony\Component\Console\Input\InputDefinition;
2425
use Symfony\Component\Console\Input\InputInterface;
2526
use Symfony\Component\Console\Input\InputOption;
@@ -90,6 +91,25 @@ public function doRun(InputInterface $input, OutputInterface $output): int
9091
return parent::doRun($input, $output);
9192
}
9293

94+
/**
95+
* Adds a command object.
96+
*
97+
* Provides backwards compatibility for Symfony Console 6.x/7.x where
98+
* the add() method exists, and Symfony 8.x where it was removed in
99+
* favor of addCommand().
100+
*
101+
* @param \Symfony\Component\Console\Command\Command $command A Command object
102+
* @return \Symfony\Component\Console\Command\Command|null
103+
*/
104+
public function add(Command $command): ?Command
105+
{
106+
if (method_exists(Application::class, 'addCommand')) {
107+
return parent::addCommand($command);
108+
}
109+
110+
return parent::add($command);
111+
}
112+
93113
/**
94114
* Get the current application version.
95115
*

src/Phinx/Db/Adapter/AbstractAdapter.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Exception;
1212
use InvalidArgumentException;
13+
use Phinx\Config\FeatureFlags;
1314
use Phinx\Db\Table;
1415
use Phinx\Db\Table\Column;
1516
use Phinx\Util\Literal;
@@ -307,11 +308,15 @@ public function createSchemaTable(): void
307308
'primary_key' => 'version',
308309
];
309310

311+
$columnType = FeatureFlags::$addTimestampsUseDateTime
312+
? AdapterInterface::PHINX_TYPE_DATETIME
313+
: AdapterInterface::PHINX_TYPE_TIMESTAMP;
314+
310315
$table = new Table($this->getSchemaTableName(), $options, $this);
311316
$table->addColumn('version', 'biginteger', ['null' => false])
312317
->addColumn('migration_name', 'string', ['limit' => 100, 'default' => null, 'null' => true])
313-
->addColumn('start_time', 'timestamp', ['default' => null, 'null' => true])
314-
->addColumn('end_time', 'timestamp', ['default' => null, 'null' => true])
318+
->addColumn('start_time', $columnType, ['default' => null, 'null' => true])
319+
->addColumn('end_time', $columnType, ['default' => null, 'null' => true])
315320
->addColumn('breakpoint', 'boolean', ['default' => false, 'null' => false])
316321
->save();
317322
} catch (Exception $exception) {

src/Phinx/Db/Table.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,21 @@ public function reset(): void
295295
*
296296
* @param string|\Phinx\Db\Table\Column $columnName Column Name
297297
* @param string|\Phinx\Util\Literal|null $type Column Type
298-
* @param array<string, mixed> $options Column Options
298+
* @param array{
299+
* limit?: int,
300+
* length?: int,
301+
* default?: mixed,
302+
* null?: bool,
303+
* after?: string,
304+
* comment?: string,
305+
* precision?: int,
306+
* scale?: int,
307+
* signed?: bool,
308+
* values?: mixed,
309+
* identity?: bool,
310+
* update?: string,
311+
* timezone?: bool,
312+
* } $options Column Options
299313
* @throws \InvalidArgumentException
300314
* @return $this
301315
*/
@@ -358,7 +372,21 @@ public function renameColumn(string $oldName, string $newName)
358372
*
359373
* @param string $columnName Column Name
360374
* @param string|\Phinx\Db\Table\Column|\Phinx\Util\Literal $newColumnType New Column Type
361-
* @param array<string, mixed> $options Options
375+
* @param array{
376+
* limit?: int,
377+
* length?: int,
378+
* default?: mixed,
379+
* null?: bool,
380+
* after?: string,
381+
* comment?: string,
382+
* precision?: int,
383+
* scale?: int,
384+
* signed?: bool,
385+
* values?: mixed,
386+
* identity?: bool,
387+
* update?: string,
388+
* timezone?: bool,
389+
* } $options Options
362390
* @return $this
363391
*/
364392
public function changeColumn(string $columnName, string|Column|Literal $newColumnType, array $options = [])

0 commit comments

Comments
 (0)