Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
034ed255
Unverified
Commit
034ed255
authored
Jul 05, 2020
by
Sergei Morozov
Committed by
GitHub
Jul 05, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4145 from morozov/type-registry-constructor
Add TypeRegistry constructor
parents
d7df55d6
66d68217
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
+16
-7
Type.php
lib/Doctrine/DBAL/Types/Type.php
+3
-3
TypeRegistry.php
lib/Doctrine/DBAL/Types/TypeRegistry.php
+9
-1
TypeRegistryTest.php
tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php
+4
-3
No files found.
lib/Doctrine/DBAL/Types/Type.php
View file @
034ed255
...
...
@@ -208,13 +208,13 @@ abstract class Type
private
static
function
createTypeRegistry
()
:
TypeRegistry
{
$
registry
=
new
TypeRegistry
()
;
$
instances
=
[]
;
foreach
(
self
::
BUILTIN_TYPES_MAP
as
$name
=>
$class
)
{
$
registry
->
register
(
$name
,
new
$class
()
);
$
instances
[
$name
]
=
new
$class
(
);
}
return
$registry
;
return
new
TypeRegistry
(
$instances
)
;
}
/**
...
...
lib/Doctrine/DBAL/Types/TypeRegistry.php
View file @
034ed255
...
...
@@ -18,7 +18,15 @@ use function in_array;
final
class
TypeRegistry
{
/** @var array<string, Type> Map of type names and their corresponding flyweight objects. */
private
$instances
=
[];
private
$instances
;
/**
* @param array<string, Type> $instances
*/
public
function
__construct
(
array
$instances
=
[])
{
$this
->
instances
=
$instances
;
}
/**
* Finds a type by the given name.
...
...
tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php
View file @
034ed255
...
...
@@ -31,9 +31,10 @@ class TypeRegistryTest extends TestCase
$this
->
testType
=
new
BlobType
();
$this
->
otherTestType
=
new
BinaryType
();
$this
->
registry
=
new
TypeRegistry
();
$this
->
registry
->
register
(
self
::
TEST_TYPE_NAME
,
$this
->
testType
);
$this
->
registry
->
register
(
self
::
OTHER_TEST_TYPE_NAME
,
$this
->
otherTestType
);
$this
->
registry
=
new
TypeRegistry
([
self
::
TEST_TYPE_NAME
=>
$this
->
testType
,
self
::
OTHER_TEST_TYPE_NAME
=>
$this
->
otherTestType
,
]);
}
public
function
testGet
()
:
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment