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
f7fff511
Commit
f7fff511
authored
Jul 15, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Improved AnnotationReader implementation. Fixes #2345.
parent
a3d58e7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
35 deletions
+32
-35
AnnotationReader.php
lib/Doctrine/Common/Annotations/AnnotationReader.php
+32
-35
No files found.
lib/Doctrine/Common/Annotations/AnnotationReader.php
View file @
f7fff511
...
@@ -35,7 +35,6 @@ class AnnotationReader
...
@@ -35,7 +35,6 @@ class AnnotationReader
private
static
$CACHE_SALT
=
"@<Annot>"
;
private
static
$CACHE_SALT
=
"@<Annot>"
;
private
$_parser
;
private
$_parser
;
private
$_cache
;
private
$_cache
;
private
$_annotations
=
array
();
/**
/**
* Initiaizes a new AnnotationReader that uses the given Cache provider to cache annotations.
* Initiaizes a new AnnotationReader that uses the given Cache provider to cache annotations.
...
@@ -49,9 +48,10 @@ class AnnotationReader
...
@@ -49,9 +48,10 @@ class AnnotationReader
}
}
/**
/**
* Sets the default namespace that the AnnotationReader should assume for annotations
* with not fully qualified names.
*
*
* @param $defaultNamespace
* @param string $defaultNamespace
* @return unknown_type
*/
*/
public
function
setDefaultAnnotationNamespace
(
$defaultNamespace
)
public
function
setDefaultAnnotationNamespace
(
$defaultNamespace
)
{
{
...
@@ -67,25 +67,24 @@ class AnnotationReader
...
@@ -67,25 +67,24 @@ class AnnotationReader
*/
*/
public
function
getClassAnnotations
(
ReflectionClass
$class
)
public
function
getClassAnnotations
(
ReflectionClass
$class
)
{
{
$c
lassName
=
$class
->
getName
()
;
$c
acheKey
=
$class
->
getName
()
.
self
::
$CACHE_SALT
;
if
(
isset
(
$this
->
_annotations
[
$className
]))
{
if
(
$this
->
_cache
->
contains
(
$cacheKey
))
{
return
$this
->
_annotations
[
$className
];
return
$this
->
_cache
->
fetch
(
$cacheKey
);
}
else
if
(
$this
->
_cache
->
contains
(
$className
.
self
::
$CACHE_SALT
))
{
$this
->
_annotations
[
$className
]
=
$this
->
_cacheDriver
->
get
(
$className
.
self
::
$CACHE_SALT
);
return
$this
->
_annotations
[
$className
];
}
}
$this
->
_annotations
[
$className
]
=
$this
->
_parser
->
parse
(
$class
->
getDocComment
());
$annotations
=
$this
->
_parser
->
parse
(
$class
->
getDocComment
());
$this
->
_cache
->
save
(
$cacheKey
,
$annotations
,
null
);
return
$
this
->
_annotations
[
$className
]
;
return
$
annotations
;
}
}
/**
/**
* Gets a class annotation.
*
*
* @param $class
* @param $class
* @param
$annotation
* @param
string $annotation The name of the annotation.
* @return
unknown_type
* @return
The Annotation or NULL, if the requested annotation does not exist.
*/
*/
public
function
getClassAnnotation
(
ReflectionClass
$class
,
$annotation
)
public
function
getClassAnnotation
(
ReflectionClass
$class
,
$annotation
)
{
{
...
@@ -103,25 +102,24 @@ class AnnotationReader
...
@@ -103,25 +102,24 @@ class AnnotationReader
*/
*/
public
function
getPropertyAnnotations
(
ReflectionProperty
$property
)
public
function
getPropertyAnnotations
(
ReflectionProperty
$property
)
{
{
$
propertyName
=
$property
->
getDeclaringClass
()
->
getName
()
.
'$'
.
$property
->
getName
()
;
$
cacheKey
=
$property
->
getDeclaringClass
()
->
getName
()
.
'$'
.
$property
->
getName
()
.
self
::
$CACHE_SALT
;
if
(
isset
(
$this
->
_annotations
[
$propertyName
]))
{
if
(
$this
->
_cache
->
contains
(
$cacheKey
))
{
return
$this
->
_annotations
[
$propertyName
];
return
$this
->
_cache
->
fetch
(
$cacheKey
);
}
else
if
(
$this
->
_cache
->
contains
(
$propertyName
.
self
::
$CACHE_SALT
))
{
$this
->
_annotations
[
$propertyName
]
=
$this
->
_cacheDriver
->
get
(
$propertyName
.
self
::
$CACHE_SALT
);
return
$this
->
_annotations
[
$propertyName
];
}
}
$this
->
_annotations
[
$propertyName
]
=
$this
->
_parser
->
parse
(
$property
->
getDocComment
());
$annotations
=
$this
->
_parser
->
parse
(
$property
->
getDocComment
());
$this
->
_cache
->
save
(
$cacheKey
,
$annotations
,
null
);
return
$
this
->
_annotations
[
$propertyName
]
;
return
$
annotations
;
}
}
/**
/**
* Gets a property annotation.
*
*
* @param $property
* @param
ReflectionProperty
$property
* @param
$annotation
* @param
string $annotation The name of the annotation.
* @return
unknown_type
* @return
The Annotation or NULL, if the requested annotation does not exist.
*/
*/
public
function
getPropertyAnnotation
(
ReflectionProperty
$property
,
$annotation
)
public
function
getPropertyAnnotation
(
ReflectionProperty
$property
,
$annotation
)
{
{
...
@@ -139,25 +137,24 @@ class AnnotationReader
...
@@ -139,25 +137,24 @@ class AnnotationReader
*/
*/
public
function
getMethodAnnotations
(
ReflectionMethod
$method
)
public
function
getMethodAnnotations
(
ReflectionMethod
$method
)
{
{
$
methodName
=
$method
->
getDeclaringClass
()
->
getName
()
.
'#'
.
$method
->
getName
()
;
$
cacheKey
=
$method
->
getDeclaringClass
()
->
getName
()
.
'#'
.
$method
->
getName
()
.
self
::
$CACHE_SALT
;
if
(
isset
(
$this
->
_annotations
[
$methodName
]))
{
if
(
$this
->
_cache
->
contains
(
$cacheKey
))
{
return
$this
->
_annotations
[
$methodName
];
return
$this
->
_cache
->
fetch
(
$cacheKey
);
}
else
if
(
$this
->
_cache
->
contains
(
$methodName
.
self
::
$CACHE_SALT
))
{
$this
->
_annotations
[
$methodName
]
=
$this
->
_cacheDriver
->
get
(
$methodName
.
self
::
$CACHE_SALT
);
return
$this
->
_annotations
[
$methodName
];
}
}
$this
->
_annotations
[
$methodName
]
=
$this
->
_parser
->
parse
(
$method
->
getDocComment
());
$annotations
=
$this
->
_parser
->
parse
(
$method
->
getDocComment
());
$this
->
_cache
->
save
(
$cacheKey
,
$annotations
,
null
);
return
$
this
->
_annotations
[
$methodName
]
;
return
$
annotations
;
}
}
/**
/**
* Gets a method annotation.
*
*
* @param $method
* @param
ReflectionMethod
$method
* @param
$annotation
* @param
string $annotation The name of the annotation.
* @return
unknown_type
* @return
The Annotation or NULL, if the requested annotation does not exist.
*/
*/
public
function
getMethodAnnotation
(
ReflectionMethod
$method
,
$annotation
)
public
function
getMethodAnnotation
(
ReflectionMethod
$method
,
$annotation
)
{
{
...
...
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