-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92d08dd
commit a03fa9a
Showing
35 changed files
with
515 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
lam/lib/3rdParty/composer/carbonphp/carbon-doctrine-types/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Carbon | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
14 changes: 14 additions & 0 deletions
14
lam/lib/3rdParty/composer/carbonphp/carbon-doctrine-types/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# carbonphp/carbon-doctrine-types | ||
|
||
Types to use Carbon in Doctrine | ||
|
||
## Documentation | ||
|
||
[Check how to use in the official Carbon documentation](https://carbon.nesbot.com/symfony/) | ||
|
||
This package is an externalization of [src/Carbon/Doctrine](https://github.com/briannesbitt/Carbon/tree/2.71.0/src/Carbon/Doctrine) | ||
from `nestbot/carbon` package. | ||
|
||
Externalization allows to better deal with different versions of dbal. With | ||
version 4.0 of dbal, it no longer sustainable to be compatible with all version | ||
using a single code. |
36 changes: 36 additions & 0 deletions
36
lam/lib/3rdParty/composer/carbonphp/carbon-doctrine-types/composer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "carbonphp/carbon-doctrine-types", | ||
"description": "Types to use Carbon in Doctrine", | ||
"type": "library", | ||
"keywords": [ | ||
"date", | ||
"time", | ||
"DateTime", | ||
"Carbon", | ||
"Doctrine" | ||
], | ||
"require": { | ||
"php": "^7.4 || ^8.0" | ||
}, | ||
"require-dev": { | ||
"doctrine/dbal": "^3.7.0", | ||
"nesbot/carbon": "^2.71.0 || ^3.0.0", | ||
"phpunit/phpunit": "^10.3" | ||
}, | ||
"conflict": { | ||
"doctrine/dbal": "<3.7.0 || >=4.0.0" | ||
}, | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"Carbon\\Doctrine\\": "src/Carbon/Doctrine/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "KyleKatarn", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev" | ||
} |
9 changes: 0 additions & 9 deletions
9
...rc/Carbon/Doctrine/CarbonDoctrineType.php → ...rc/Carbon/Doctrine/CarbonDoctrineType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Carbon package. | ||
* | ||
* (c) Brian Nesbitt <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Carbon\Doctrine; | ||
|
||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
|
7 changes: 7 additions & 0 deletions
7
...arty/composer/carbonphp/carbon-doctrine-types/src/Carbon/Doctrine/CarbonImmutableType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Carbon\Doctrine; | ||
|
||
class CarbonImmutableType extends DateTimeImmutableType implements CarbonDoctrineType | ||
{ | ||
} |
7 changes: 7 additions & 0 deletions
7
lam/lib/3rdParty/composer/carbonphp/carbon-doctrine-types/src/Carbon/Doctrine/CarbonType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Carbon\Doctrine; | ||
|
||
class CarbonType extends DateTimeType implements CarbonDoctrineType | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Carbon package. | ||
* | ||
* (c) Brian Nesbitt <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Carbon\Doctrine; | ||
|
||
use Carbon\Carbon; | ||
|
@@ -23,6 +14,14 @@ | |
*/ | ||
trait CarbonTypeConverter | ||
{ | ||
/** | ||
* This property differentiates types installed by carbonphp/carbon-doctrine-types | ||
* from the ones embedded previously in nesbot/carbon source directly. | ||
* | ||
* @readonly | ||
*/ | ||
public bool $external = true; | ||
|
||
/** | ||
* @return class-string<T> | ||
*/ | ||
|
@@ -31,20 +30,9 @@ protected function getCarbonClassName(): string | |
return Carbon::class; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) | ||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string | ||
{ | ||
$precision = $fieldDeclaration['precision'] ?: 10; | ||
|
||
if ($fieldDeclaration['secondPrecision'] ?? false) { | ||
$precision = 0; | ||
} | ||
|
||
if ($precision === 10) { | ||
$precision = DateTimeDefaultPrecision::get(); | ||
} | ||
$precision = $fieldDeclaration['precision'] ?? DateTimeDefaultPrecision::get(); | ||
|
||
$type = parent::getSQLDeclaration($fieldDeclaration, $platform); | ||
|
||
|
@@ -90,7 +78,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) | |
if (!$date) { | ||
throw ConversionException::conversionFailedFormat( | ||
$value, | ||
$this->getName(), | ||
$this->getTypeName(), | ||
'Y-m-d H:i:s.u or any format supported by '.$class.'::parse()', | ||
$error | ||
); | ||
|
@@ -101,10 +89,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform) | |
|
||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
* | ||
* @return string|null | ||
*/ | ||
public function convertToDatabaseValue($value, AbstractPlatform $platform) | ||
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string | ||
{ | ||
if ($value === null) { | ||
return $value; | ||
|
@@ -116,8 +102,16 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) | |
|
||
throw ConversionException::conversionFailedInvalidType( | ||
$value, | ||
$this->getName(), | ||
$this->getTypeName(), | ||
['null', 'DateTime', 'Carbon'] | ||
); | ||
} | ||
|
||
private function getTypeName(): string | ||
{ | ||
$chunks = explode('\\', static::class); | ||
$type = preg_replace('/Type$/', '', end($chunks)); | ||
|
||
return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $type)); | ||
} | ||
} |
Oops, something went wrong.