Skip to content

Commit 32defe8

Browse files
committed
composer udpated
1 parent 96f509b commit 32defe8

File tree

280 files changed

+6063
-3944
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+6063
-3944
lines changed

composer.lock

Lines changed: 267 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/autoload.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@
33
// autoload.php @generated by Composer
44

55
if (PHP_VERSION_ID < 50600) {
6-
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
7-
exit(1);
6+
if (!headers_sent()) {
7+
header('HTTP/1.1 500 Internal Server Error');
8+
}
9+
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10+
if (!ini_get('display_errors')) {
11+
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12+
fwrite(STDERR, $err);
13+
} elseif (!headers_sent()) {
14+
echo $err;
15+
}
16+
}
17+
trigger_error(
18+
$err,
19+
E_USER_ERROR
20+
);
821
}
922

1023
require_once __DIR__ . '/composer/autoload_real.php';

lib/bin/carbon

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ if (PHP_VERSION_ID < 80000) {
108108
}
109109
}
110110

111-
if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
112-
include("phpvfscomposer://" . __DIR__ . '/..'.'/nesbot/carbon/bin/carbon');
113-
exit(0);
111+
if (
112+
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
113+
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
114+
) {
115+
return include("phpvfscomposer://" . __DIR__ . '/..'.'/nesbot/carbon/bin/carbon');
114116
}
115117
}
116118

117-
include __DIR__ . '/..'.'/nesbot/carbon/bin/carbon';
119+
return include __DIR__ . '/..'.'/nesbot/carbon/bin/carbon';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Carbon
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# carbonphp/carbon-doctrine-types
2+
3+
Types to use Carbon in Doctrine
4+
5+
## Documentation
6+
7+
[Check how to use in the official Carbon documentation](https://carbon.nesbot.com/symfony/)
8+
9+
This package is an externalization of [src/Carbon/Doctrine](https://github.com/briannesbitt/Carbon/tree/2.71.0/src/Carbon/Doctrine)
10+
from `nestbot/carbon` package.
11+
12+
Externalization allows to better deal with different versions of dbal. With
13+
version 4.0 of dbal, it no longer sustainable to be compatible with all version
14+
using a single code.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "carbonphp/carbon-doctrine-types",
3+
"description": "Types to use Carbon in Doctrine",
4+
"type": "library",
5+
"keywords": [
6+
"date",
7+
"time",
8+
"DateTime",
9+
"Carbon",
10+
"Doctrine"
11+
],
12+
"require": {
13+
"php": "^8.1"
14+
},
15+
"require-dev": {
16+
"doctrine/dbal": "^4.0.0",
17+
"nesbot/carbon": "^2.71.0 || ^3.0.0",
18+
"phpunit/phpunit": "^10.3"
19+
},
20+
"conflict": {
21+
"doctrine/dbal": "<4.0.0 || >=5.0.0"
22+
},
23+
"license": "MIT",
24+
"autoload": {
25+
"psr-4": {
26+
"Carbon\\Doctrine\\": "src/Carbon/Doctrine/"
27+
}
28+
},
29+
"authors": [
30+
{
31+
"name": "KyleKatarn",
32+
"email": "kylekatarnls@gmail.com"
33+
}
34+
],
35+
"minimum-stability": "dev"
36+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Carbon\Doctrine;
6+
7+
use Doctrine\DBAL\Platforms\AbstractPlatform;
8+
9+
interface CarbonDoctrineType
10+
{
11+
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform);
12+
13+
public function convertToPHPValue(mixed $value, AbstractPlatform $platform);
14+
15+
public function convertToDatabaseValue($value, AbstractPlatform $platform);
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Carbon\Doctrine;
6+
7+
class CarbonImmutableType extends DateTimeImmutableType implements CarbonDoctrineType
8+
{
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Carbon\Doctrine;
6+
7+
class CarbonType extends DateTimeType implements CarbonDoctrineType
8+
{
9+
}
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
<?php
22

3-
/**
4-
* This file is part of the Carbon package.
5-
*
6-
* (c) Brian Nesbitt <brian@nesbot.com>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
3+
declare(strict_types=1);
114

125
namespace Carbon\Doctrine;
136

147
use Carbon\Carbon;
158
use Carbon\CarbonInterface;
169
use DateTimeInterface;
1710
use Doctrine\DBAL\Platforms\AbstractPlatform;
18-
use Doctrine\DBAL\Types\ConversionException;
11+
use Doctrine\DBAL\Platforms\DB2Platform;
12+
use Doctrine\DBAL\Platforms\OraclePlatform;
13+
use Doctrine\DBAL\Platforms\SQLitePlatform;
14+
use Doctrine\DBAL\Platforms\SQLServerPlatform;
15+
use Doctrine\DBAL\Types\Exception\InvalidType;
16+
use Doctrine\DBAL\Types\Exception\ValueNotConvertible;
1917
use Exception;
2018

2119
/**
2220
* @template T of CarbonInterface
2321
*/
2422
trait CarbonTypeConverter
2523
{
24+
/**
25+
* This property differentiates types installed by carbonphp/carbon-doctrine-types
26+
* from the ones embedded previously in nesbot/carbon source directly.
27+
*
28+
* @readonly
29+
*/
30+
public bool $external = true;
31+
2632
/**
2733
* @return class-string<T>
2834
*/
@@ -31,20 +37,12 @@ protected function getCarbonClassName(): string
3137
return Carbon::class;
3238
}
3339

34-
/**
35-
* @return string
36-
*/
37-
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
40+
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
3841
{
39-
$precision = $fieldDeclaration['precision'] ?: 10;
40-
41-
if ($fieldDeclaration['secondPrecision'] ?? false) {
42-
$precision = 0;
43-
}
44-
45-
if ($precision === 10) {
46-
$precision = DateTimeDefaultPrecision::get();
47-
}
42+
$precision = min(
43+
$fieldDeclaration['precision'] ?? DateTimeDefaultPrecision::get(),
44+
$this->getMaximumPrecision($platform),
45+
);
4846

4947
$type = parent::getSQLDeclaration($fieldDeclaration, $platform);
5048

@@ -63,10 +61,25 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla
6361

6462
/**
6563
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
66-
*
67-
* @return T|null
6864
*/
69-
public function convertToPHPValue($value, AbstractPlatform $platform)
65+
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
66+
{
67+
if ($value === null) {
68+
return $value;
69+
}
70+
71+
if ($value instanceof DateTimeInterface) {
72+
return $value->format('Y-m-d H:i:s.u');
73+
}
74+
75+
throw InvalidType::new(
76+
$value,
77+
static::class,
78+
['null', 'DateTime', 'Carbon']
79+
);
80+
}
81+
82+
private function doConvertToPHPValue(mixed $value)
7083
{
7184
$class = $this->getCarbonClassName();
7285

@@ -88,9 +101,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
88101
}
89102

90103
if (!$date) {
91-
throw ConversionException::conversionFailedFormat(
104+
throw ValueNotConvertible::new(
92105
$value,
93-
$this->getName(),
106+
static::class,
94107
'Y-m-d H:i:s.u or any format supported by '.$class.'::parse()',
95108
$error
96109
);
@@ -99,25 +112,20 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
99112
return $date;
100113
}
101114

102-
/**
103-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
104-
*
105-
* @return string|null
106-
*/
107-
public function convertToDatabaseValue($value, AbstractPlatform $platform)
115+
private function getMaximumPrecision(AbstractPlatform $platform): int
108116
{
109-
if ($value === null) {
110-
return $value;
117+
if ($platform instanceof DB2Platform) {
118+
return 12;
111119
}
112120

113-
if ($value instanceof DateTimeInterface) {
114-
return $value->format('Y-m-d H:i:s.u');
121+
if ($platform instanceof OraclePlatform) {
122+
return 9;
115123
}
116124

117-
throw ConversionException::conversionFailedInvalidType(
118-
$value,
119-
$this->getName(),
120-
['null', 'DateTime', 'Carbon']
121-
);
125+
if ($platform instanceof SQLServerPlatform || $platform instanceof SQLitePlatform) {
126+
return 3;
127+
}
128+
129+
return 6;
122130
}
123131
}

0 commit comments

Comments
 (0)