Skip to content

Conversation

@garak
Copy link
Contributor

@garak garak commented Mar 3, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #59889
License MIT

Add a new DoctrineType for the DatePoint class.
Please take a look at the issue mentioned above for more details.

@carsonbot carsonbot added this to the 7.3 milestone Mar 3, 2025
@OskarStark OskarStark changed the title add new DatePointType Doctrine type add new DatePointType Doctrine type Mar 3, 2025
@carsonbot carsonbot changed the title add new DatePointType Doctrine type [DoctrineBridge] add new DatePointType Doctrine type Mar 3, 2025
@garak
Copy link
Contributor Author

garak commented Mar 3, 2025

I can't understand the psalm failures, any help will be appreciated.
Moreover, I see that fabbot complains because I added some tests with return type, does it make sense?

@OskarStark
Copy link
Contributor

Moreover, I see that fabbot complains because I added some tests with return type, does it make sense?

Yes, we avoid the void return type in the Symfony codebase

@garak
Copy link
Contributor Author

garak commented Mar 3, 2025

I fixed the return types. The unit test failures seem unrelated.
I still need a hint about fixing the psalm inspection, thanks.

@garak garak force-pushed the datepoint-type branch 2 times, most recently from 6bc479d to 4608390 Compare March 8, 2025 17:30
@GromNaN
Copy link
Member

GromNaN commented Mar 15, 2025

Note for the DoctrineBundle integration: in addition to adding the type to the DBAL Types registry, this new type should be associated to the DatePoint property type in the typed field mapper.

@fabpot
Copy link
Member

fabpot commented Mar 24, 2025

Thank you @garak.

@fabpot fabpot merged commit 6872336 into symfony:7.3 Mar 24, 2025
3 of 7 checks passed
@garak garak deleted the datepoint-type branch March 24, 2025 08:25
@fabpot fabpot mentioned this pull request May 2, 2025
nicolas-grekas added a commit that referenced this pull request May 30, 2025
…Type` and `TimeType` (wkania)

This PR was merged into the 7.4 branch.

Discussion
----------

[Form] Add `input=date_point` to `DateTimeType`, `DateType` and `TimeType`

| Q             | A
| ------------- | ---
| Branch?       | 7.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        |
| License       | MIT

Based on [datetime_immutable](https://symfony.com/blog/new-in-symfony-4-1-added-support-for-immutable-dates-in-forms).

After [DatePointType](#59900) and [DatePointDateType](#60237), it would be great to use Forms without needing to transform values into the DatePoint type manually.

```
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\Extension\Core\Type\BirthdayType;

$builder->add('from', DateType::class, [
    'input' => 'date_point',
]);
$builder->add('from', DateTimeType::class, [
    'input' => 'date_point',
]);
$builder->add('from', TimeType::class, [
    'input' => 'date_point',
]);
$builder->add('from', BirthdayType::class, [
    'input' => 'date_point',
]);
```

Alternative: Make symfony/clock a hard requirement and refactor the existing DateTimeImmutableToDateTimeTransformer to return a DatePoint instead. This should not introduce any breaking changes.

Commits
-------

f1160d6 [Form] Add input=date_point to DateTimeType, DateType and TimeType
symfony-splitter pushed a commit to symfony/form that referenced this pull request May 30, 2025
…Type` and `TimeType` (wkania)

This PR was merged into the 7.4 branch.

Discussion
----------

[Form] Add `input=date_point` to `DateTimeType`, `DateType` and `TimeType`

| Q             | A
| ------------- | ---
| Branch?       | 7.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        |
| License       | MIT

Based on [datetime_immutable](https://symfony.com/blog/new-in-symfony-4-1-added-support-for-immutable-dates-in-forms).

After [DatePointType](symfony/symfony#59900) and [DatePointDateType](symfony/symfony#60237), it would be great to use Forms without needing to transform values into the DatePoint type manually.

```
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\Extension\Core\Type\BirthdayType;

$builder->add('from', DateType::class, [
    'input' => 'date_point',
]);
$builder->add('from', DateTimeType::class, [
    'input' => 'date_point',
]);
$builder->add('from', TimeType::class, [
    'input' => 'date_point',
]);
$builder->add('from', BirthdayType::class, [
    'input' => 'date_point',
]);
```

Alternative: Make symfony/clock a hard requirement and refactor the existing DateTimeImmutableToDateTimeTransformer to return a DatePoint instead. This should not introduce any breaking changes.

Commits
-------

f1160d6617f [Form] Add input=date_point to DateTimeType, DateType and TimeType
fabpot added a commit that referenced this pull request Sep 24, 2025
…Type` Doctrine type (wkania)

This PR was merged into the 7.4 branch.

Discussion
----------

[DoctrineBridge] Add new `DayPointType` and `TimePointType` Doctrine type

| Q             | A
| ------------- | ---
| Branch       | 7.4
| Bug fix      | no
| New feature  | yes
| Deprecations | no
| License       | MIT

Doctrine provides both [date_immutable](https://www.doctrine-project.org/projects/doctrine-dbal/en/4.2/reference/types.html#date-immutable) and [datetime_immutable](https://www.doctrine-project.org/projects/doctrine-dbal/en/4.2/reference/types.html#datetime-immutable) types. Restricting the conversion of DatePoint only to datetime_immutable is problematic.

New version:

Previous [pull request](#59900).

```yaml
doctrine:
    dbal:
        types:
            date_point: Symfony\Bridge\Doctrine\Types\DatePointType
            day_point: Symfony\Bridge\Doctrine\Types\DayPointType
            time_point: Symfony\Bridge\Doctrine\Types\TimePointType
```

```php

#[ORM\Column(type: 'date_point')]
public DatePoint $createdAt;

#[ORM\Column(type: 'day_point')]
public DatePoint $birthday;

#[ORM\Column(type: 'time_point')]
public DatePoint $openAt;
```

Old version:

Therefore, I propose renaming the current DatePointType to DateTimePointType, and introducing a new DatePointType.

Previous [pull request](#59900).

If this pull request is to be merged, it should be included in version 7.3 to avoid any breaking changes in the future.

```yaml
doctrine:
    dbal:
        types:
            date_point: Symfony\Bridge\Doctrine\Types\DatePointType
            datetime_point: Symfony\Bridge\Doctrine\Types\DateTimePointType
```

```php
#[ORM\Column(type: 'date_point')]
public DatePoint $birthday;

#[ORM\Column(type: 'datetime_point')]
public DatePoint $createdAt;

Commits
-------

7f383ef [DoctrineBridge] add new DayPointType and TimePointType Doctrine type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DoctrineBridge] DatePoint type

10 participants