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
a4e928e1
Commit
a4e928e1
authored
May 28, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Moved addendum library to vendor dir.
parent
292e93de
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1144 additions
and
376 deletions
+1144
-376
EventArgs.php
lib/Doctrine/Common/EventArgs.php
+0
-1
AnnotationDriver.php
lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
+3
-3
DoctrineAnnotations.php
lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
+21
-21
annotations.php
lib/Doctrine/ORM/Mapping/Driver/addendum/annotations.php
+0
-341
LICENSE
lib/vendor/addendum/LICENSE
+0
-0
annotations.php
lib/vendor/addendum/annotations.php
+341
-0
annotation_parser.php
lib/vendor/addendum/annotations/annotation_parser.php
+2
-4
doc_comment.php
lib/vendor/addendum/annotations/doc_comment.php
+0
-0
acceptance_test.php
lib/vendor/addendum/annotations/tests/acceptance_test.php
+233
-0
all_tests.php
lib/vendor/addendum/annotations/tests/all_tests.php
+33
-0
annotation_parser_test.php
...dor/addendum/annotations/tests/annotation_parser_test.php
+312
-0
annotation_test.php
lib/vendor/addendum/annotations/tests/annotation_test.php
+27
-0
constrained_annotation_test.php
...ddendum/annotations/tests/constrained_annotation_test.php
+73
-0
doc_comment_test.php
lib/vendor/addendum/annotations/tests/doc_comment_test.php
+87
-0
SingleTableInheritanceTest.php
...trine/Tests/ORM/Functional/SingleTableInheritanceTest.php
+12
-6
No files found.
lib/Doctrine/Common/EventArgs.php
View file @
a4e928e1
...
...
@@ -28,7 +28,6 @@ namespace Doctrine\Common;
* information to an event handler when an event is raised. The single empty EventArgs
* instance can be obtained through {@link getEmptyInstance()}.
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
...
...
lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
View file @
a4e928e1
...
...
@@ -26,8 +26,8 @@ use Doctrine\ORM\Mapping\ClassMetadata;
use
Doctrine\ORM\Mapping\MappingException
;
/* Addendum annotation reflection extensions */
if
(
!
class_exists
(
'
\
Addendum'
,
false
))
{
require
__DIR__
.
'/addendum/annotations.php'
;
if
(
!
class_exists
(
'Addendum'
,
false
))
{
require
__DIR__
.
'/
../../../../vendor/
addendum/annotations.php'
;
}
require
__DIR__
.
'/DoctrineAnnotations.php'
;
...
...
@@ -45,7 +45,7 @@ class AnnotationDriver
*/
public
function
loadMetadataForClass
(
$className
,
ClassMetadata
$metadata
)
{
$annotClass
=
new
\
Addendum\
ReflectionAnnotatedClass
(
$className
);
$annotClass
=
new
\ReflectionAnnotatedClass
(
$className
);
// Evaluate DoctrineEntity annotation
if
((
$entityAnnot
=
$annotClass
->
getAnnotation
(
'DoctrineEntity'
))
===
false
)
{
...
...
lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php
View file @
a4e928e1
...
...
@@ -21,25 +21,25 @@
/* Annotations */
final
class
DoctrineEntity
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineEntity
extends
\Annotation
{
public
$repositoryClass
;
}
final
class
DoctrineInheritanceType
extends
\A
ddendum\A
nnotation
{}
final
class
DoctrineDiscriminatorColumn
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineInheritanceType
extends
\Annotation
{}
final
class
DoctrineDiscriminatorColumn
extends
\Annotation
{
public
$name
;
public
$type
;
public
$length
;
}
final
class
DoctrineDiscriminatorMap
extends
\A
ddendum\A
nnotation
{}
final
class
DoctrineDiscriminatorValue
extends
\A
ddendum\A
nnotation
{}
final
class
DoctrineSubClasses
extends
\A
ddendum\A
nnotation
{}
final
class
DoctrineId
extends
\A
ddendum\A
nnotation
{}
final
class
DoctrineGeneratedValue
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineDiscriminatorMap
extends
\Annotation
{}
final
class
DoctrineDiscriminatorValue
extends
\Annotation
{}
final
class
DoctrineSubClasses
extends
\Annotation
{}
final
class
DoctrineId
extends
\Annotation
{}
final
class
DoctrineGeneratedValue
extends
\Annotation
{
public
$strategy
;
//public $generator;
}
final
class
DoctrineVersion
extends
\A
ddendum\A
nnotation
{}
final
class
DoctrineJoinColumn
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineVersion
extends
\Annotation
{}
final
class
DoctrineJoinColumn
extends
\Annotation
{
public
$name
;
public
$referencedColumnName
;
public
$unique
=
false
;
...
...
@@ -47,55 +47,55 @@ final class DoctrineJoinColumn extends \Addendum\Annotation {
public
$onDelete
;
public
$onUpdate
;
}
final
class
DoctrineJoinColumns
extends
\A
ddendum\A
nnotation
{}
final
class
DoctrineColumn
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineJoinColumns
extends
\Annotation
{}
final
class
DoctrineColumn
extends
\Annotation
{
public
$type
;
public
$length
;
public
$unique
=
false
;
public
$nullable
=
false
;
public
$quote
=
false
;
}
final
class
DoctrineOneToOne
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineOneToOne
extends
\Annotation
{
public
$targetEntity
;
public
$mappedBy
;
public
$cascade
;
public
$fetch
;
public
$optional
;
}
final
class
DoctrineOneToMany
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineOneToMany
extends
\Annotation
{
public
$mappedBy
;
public
$targetEntity
;
public
$cascade
;
public
$fetch
;
}
final
class
DoctrineManyToOne
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineManyToOne
extends
\Annotation
{
public
$targetEntity
;
public
$cascade
;
public
$fetch
;
public
$optional
;
}
final
class
DoctrineManyToMany
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineManyToMany
extends
\Annotation
{
public
$targetEntity
;
public
$mappedBy
;
public
$cascade
;
public
$fetch
;
}
final
class
DoctrineElementCollection
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineElementCollection
extends
\Annotation
{
public
$tableName
;
}
final
class
DoctrineTable
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineTable
extends
\Annotation
{
public
$name
;
public
$catalog
;
public
$schema
;
}
final
class
DoctrineJoinTable
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineJoinTable
extends
\Annotation
{
public
$name
;
public
$catalog
;
public
$schema
;
public
$joinColumns
;
public
$inverseJoinColumns
;
}
final
class
DoctrineSequenceGenerator
extends
\A
ddendum\A
nnotation
{
final
class
DoctrineSequenceGenerator
extends
\Annotation
{
//public $name;
public
$sequenceName
;
public
$allocationSize
=
20
;
...
...
@@ -103,4 +103,4 @@ final class DoctrineSequenceGenerator extends \Addendum\Annotation {
/** The name of the class that defines the generator. */
//public $definingClass;
}
final
class
DoctrineChangeTrackingPolicy
{}
final
class
DoctrineChangeTrackingPolicy
extends
\Annotation
{}
lib/Doctrine/ORM/Mapping/Driver/addendum/annotations.php
deleted
100755 → 0
View file @
292e93de
<?php
/**
* Addendum PHP Reflection Annotations
* http://code.google.com/p/addendum/
*
* Copyright (C) 2006 Jan "johno Suchal <johno@jsmf.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**/
namespace
Addendum
;
use
\ReflectionClass
;
use
\ReflectionMethod
;
use
\ReflectionProperty
;
require_once
(
dirname
(
__FILE__
)
.
'/annotations/annotation_parser.php'
);
class
Annotation
{
public
$value
;
public
final
function
__construct
(
$data
,
$target
)
{
$reflection
=
new
ReflectionClass
(
$this
);
foreach
(
$data
as
$key
=>
$value
)
{
if
(
$reflection
->
hasProperty
(
$key
))
{
$this
->
$key
=
$value
;
}
else
{
$class
=
$reflection
->
getName
();
trigger_error
(
"Property '
$key
' not defined for annotation '
$class
'"
);
}
}
$this
->
checkTargetConstraints
(
$target
);
$this
->
checkConstraints
(
$target
);
}
private
function
checkTargetConstraints
(
$target
)
{
$reflection
=
new
ReflectionAnnotatedClass
(
$this
);
if
(
$reflection
->
hasAnnotation
(
'Target'
))
{
$value
=
$reflection
->
getAnnotation
(
'Target'
)
->
value
;
$values
=
is_array
(
$value
)
?
$value
:
array
(
$value
);
foreach
(
$values
as
$value
)
{
if
(
$value
==
'class'
&&
$target
instanceof
ReflectionClass
)
return
;
if
(
$value
==
'method'
&&
$target
instanceof
ReflectionMethod
)
return
;
if
(
$value
==
'property'
&&
$target
instanceof
ReflectionProperty
)
return
;
}
trigger_error
(
"Annotation '"
.
get_class
(
$this
)
.
"' not allowed on "
.
$this
->
createName
(
$target
),
E_USER_ERROR
);
}
}
private
function
createName
(
$target
)
{
if
(
$target
instanceof
ReflectionMethod
)
{
return
$target
->
getDeclaringClass
()
->
getName
()
.
'::'
.
$target
->
getName
();
}
elseif
(
$target
instanceof
ReflectionProperty
)
{
return
$target
->
getDeclaringClass
()
->
getName
()
.
'::$'
.
$target
->
getName
();
}
else
{
return
$target
->
getName
();
}
}
protected
function
checkConstraints
(
$target
)
{}
}
class
Target
extends
Annotation
{}
class
AnnotationsBuilder
{
private
static
$cache
=
array
();
public
function
build
(
$targetReflection
)
{
$data
=
$this
->
parse
(
$targetReflection
);
$annotations
=
array
();
foreach
(
$data
as
$class
=>
$parameters
)
{
if
(
is_subclass_of
(
$class
,
'\Addendum\Annotation'
))
{
foreach
(
$parameters
as
$params
)
{
$annotationReflection
=
new
ReflectionClass
(
$class
);
$annotations
[
$class
][]
=
$annotationReflection
->
newInstance
(
$params
,
$targetReflection
);
}
}
}
return
$annotations
;
}
private
function
parse
(
$reflection
)
{
$key
=
$this
->
createName
(
$reflection
);
if
(
!
isset
(
self
::
$cache
[
$key
]))
{
$parser
=
new
AnnotationsMatcher
;
$parser
->
matches
(
$this
->
getDocComment
(
$reflection
),
$data
);
self
::
$cache
[
$key
]
=
$data
;
}
return
self
::
$cache
[
$key
];
}
private
function
createName
(
$target
)
{
if
(
$target
instanceof
ReflectionMethod
)
{
return
$target
->
getDeclaringClass
()
->
getName
()
.
'::'
.
$target
->
getName
();
}
elseif
(
$target
instanceof
ReflectionProperty
)
{
return
$target
->
getDeclaringClass
()
->
getName
()
.
'::$'
.
$target
->
getName
();
}
else
{
return
$target
->
getName
();
}
}
protected
function
getDocComment
(
$reflection
)
{
return
Addendum
::
getDocComment
(
$reflection
);
}
public
static
function
clearCache
()
{
self
::
$cache
=
array
();
}
}
class
ReflectionAnnotatedClass
extends
ReflectionClass
{
private
$annotations
;
public
function
__construct
(
$class
)
{
parent
::
__construct
(
$class
);
$this
->
annotations
=
$this
->
createAnnotationBuilder
()
->
build
(
$this
);
}
public
function
hasAnnotation
(
$annotation
)
{
return
isset
(
$this
->
annotations
[
$annotation
]);
}
public
function
getAnnotation
(
$annotation
)
{
return
$this
->
hasAnnotation
(
$annotation
)
?
end
(
$this
->
annotations
[
$annotation
])
:
false
;
}
public
function
getAnnotations
()
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$instances
)
{
$result
[]
=
end
(
$instances
);
}
return
$result
;
}
public
function
getAllAnnotations
(
$restriction
=
false
)
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$class
=>
$instances
)
{
if
(
!
$restriction
||
$restriction
==
$class
)
{
$result
=
array_merge
(
$result
,
$instances
);
}
}
return
$result
;
}
public
function
getConstructor
()
{
return
$this
->
createReflectionAnnotatedMethod
(
parent
::
getConstructor
());
}
public
function
getMethod
(
$name
)
{
return
$this
->
createReflectionAnnotatedMethod
(
parent
::
getMethod
(
$name
));
}
public
function
getMethods
(
$filter
=
-
1
)
{
$result
=
array
();
foreach
(
parent
::
getMethods
(
$filter
)
as
$method
)
{
$result
[]
=
$this
->
createReflectionAnnotatedMethod
(
$method
);
}
return
$result
;
}
public
function
getProperty
(
$name
)
{
return
$this
->
createReflectionAnnotatedProperty
(
parent
::
getProperty
(
$name
));
}
public
function
getProperties
(
$filter
=
-
1
)
{
$result
=
array
();
foreach
(
parent
::
getProperties
(
$filter
)
as
$property
)
{
$result
[]
=
$this
->
createReflectionAnnotatedProperty
(
$property
);
}
return
$result
;
}
public
function
getInterfaces
()
{
$result
=
array
();
foreach
(
parent
::
getInterfaces
()
as
$interface
)
{
$result
[]
=
$this
->
createReflectionAnnotatedClass
(
$interface
);
}
return
$result
;
}
public
function
getParentClass
()
{
$class
=
parent
::
getParentClass
();
return
$this
->
createReflectionAnnotatedClass
(
$class
);
}
protected
function
createAnnotationBuilder
()
{
return
new
AnnotationsBuilder
();
}
private
function
createReflectionAnnotatedClass
(
$class
)
{
return
(
$class
!==
false
)
?
new
ReflectionAnnotatedClass
(
$class
->
getName
())
:
false
;
}
private
function
createReflectionAnnotatedMethod
(
$method
)
{
return
(
$method
!==
null
)
?
new
ReflectionAnnotatedMethod
(
$this
->
getName
(),
$method
->
getName
())
:
null
;
}
private
function
createReflectionAnnotatedProperty
(
$property
)
{
return
(
$property
!==
null
)
?
new
ReflectionAnnotatedProperty
(
$this
->
getName
(),
$property
->
getName
())
:
null
;
}
}
class
ReflectionAnnotatedMethod
extends
ReflectionMethod
{
private
$annotations
;
public
function
__construct
(
$class
,
$name
)
{
parent
::
__construct
(
$class
,
$name
);
$this
->
annotations
=
$this
->
createAnnotationBuilder
()
->
build
(
$this
);
}
public
function
hasAnnotation
(
$annotation
)
{
return
isset
(
$this
->
annotations
[
$annotation
]);
}
public
function
getAnnotation
(
$annotation
)
{
return
(
$this
->
hasAnnotation
(
$annotation
))
?
end
(
$this
->
annotations
[
$annotation
])
:
false
;
}
public
function
getAnnotations
()
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$instances
)
{
$result
[]
=
end
(
$instances
);
}
return
$result
;
}
public
function
getAllAnnotations
(
$restriction
=
false
)
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$class
=>
$instances
)
{
if
(
!
$restriction
||
$restriction
==
$class
)
{
$result
=
array_merge
(
$result
,
$instances
);
}
}
return
$result
;
}
public
function
getDeclaringClass
()
{
$class
=
parent
::
getDeclaringClass
();
return
new
ReflectionAnnotatedClass
(
$class
->
getName
());
}
protected
function
createAnnotationBuilder
()
{
return
new
AnnotationsBuilder
();
}
}
class
ReflectionAnnotatedProperty
extends
ReflectionProperty
{
private
$annotations
;
public
function
__construct
(
$class
,
$name
)
{
parent
::
__construct
(
$class
,
$name
);
$this
->
annotations
=
$this
->
createAnnotationBuilder
()
->
build
(
$this
);
}
public
function
hasAnnotation
(
$annotation
)
{
return
isset
(
$this
->
annotations
[
$annotation
]);
}
public
function
getAnnotation
(
$annotation
)
{
return
(
$this
->
hasAnnotation
(
$annotation
))
?
end
(
$this
->
annotations
[
$annotation
])
:
false
;
}
public
function
getAnnotations
()
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$instances
)
{
$result
[]
=
end
(
$instances
);
}
return
$result
;
}
public
function
getAllAnnotations
(
$restriction
=
false
)
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$class
=>
$instances
)
{
if
(
!
$restriction
||
$restriction
==
$class
)
{
$result
=
array_merge
(
$result
,
$instances
);
}
}
return
$result
;
}
public
function
getDeclaringClass
()
{
$class
=
parent
::
getDeclaringClass
();
return
new
ReflectionAnnotatedClass
(
$class
->
getName
());
}
protected
function
createAnnotationBuilder
()
{
return
new
AnnotationsBuilder
();
}
}
class
Addendum
{
private
static
$rawMode
;
private
static
$ignored
;
public
static
function
getDocComment
(
$reflection
)
{
if
(
self
::
checkRawDocCommentParsingNeeded
())
{
$docComment
=
new
DocComment
();
return
$docComment
->
get
(
$reflection
);
}
else
{
return
$reflection
->
getDocComment
();
}
}
/** Raw mode test */
private
static
function
checkRawDocCommentParsingNeeded
()
{
if
(
self
::
$rawMode
===
null
)
{
$reflection
=
new
ReflectionClass
(
'\Addendum\Addendum'
);
$method
=
$reflection
->
getMethod
(
'checkRawDocCommentParsingNeeded'
);
self
::
setRawMode
(
$method
->
getDocComment
()
===
false
);
}
return
self
::
$rawMode
;
}
public
static
function
setRawMode
(
$enabled
=
true
)
{
if
(
$enabled
)
{
require_once
(
dirname
(
__FILE__
)
.
'/annotations/doc_comment.php'
);
}
self
::
$rawMode
=
$enabled
;
}
public
static
function
ignore
(
array
$annotations
)
{
self
::
$ignored
=
array_combine
(
$annotations
,
array_fill
(
0
,
count
(
$annotations
),
true
));
}
public
static
function
ignores
(
$annotation
)
{
return
isset
(
self
::
$ignored
[
$annotation
]);
}
}
lib/
Doctrine/ORM/Mapping/Drive
r/addendum/LICENSE
→
lib/
vendo
r/addendum/LICENSE
View file @
a4e928e1
File moved
lib/vendor/addendum/annotations.php
0 → 100755
View file @
a4e928e1
<?php
/**
* Addendum PHP Reflection Annotations
* http://code.google.com/p/addendum/
*
* Copyright (C) 2006 Jan "johno Suchal <johno@jsmf.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**/
require_once
(
dirname
(
__FILE__
)
.
'/annotations/annotation_parser.php'
);
class
Annotation
{
public
$value
;
public
final
function
__construct
(
$data
,
$target
)
{
$reflection
=
new
ReflectionClass
(
$this
);
foreach
(
$data
as
$key
=>
$value
)
{
if
(
$reflection
->
hasProperty
(
$key
))
{
$this
->
$key
=
$value
;
}
else
{
$class
=
$reflection
->
getName
();
trigger_error
(
"Property '
$key
' not defined for annotation '
$class
'"
);
}
}
$this
->
checkTargetConstraints
(
$target
);
$this
->
checkConstraints
(
$target
);
}
private
function
checkTargetConstraints
(
$target
)
{
$reflection
=
new
ReflectionAnnotatedClass
(
$this
);
if
(
$reflection
->
hasAnnotation
(
'Target'
))
{
$value
=
$reflection
->
getAnnotation
(
'Target'
)
->
value
;
$values
=
is_array
(
$value
)
?
$value
:
array
(
$value
);
foreach
(
$values
as
$value
)
{
if
(
$value
==
'class'
&&
$target
instanceof
ReflectionClass
)
return
;
if
(
$value
==
'method'
&&
$target
instanceof
ReflectionMethod
)
return
;
if
(
$value
==
'property'
&&
$target
instanceof
ReflectionProperty
)
return
;
}
trigger_error
(
"Annotation '"
.
get_class
(
$this
)
.
"' not allowed on "
.
$this
->
createName
(
$target
),
E_USER_ERROR
);
}
}
private
function
createName
(
$target
)
{
if
(
$target
instanceof
ReflectionMethod
)
{
return
$target
->
getDeclaringClass
()
->
getName
()
.
'::'
.
$target
->
getName
();
}
elseif
(
$target
instanceof
ReflectionProperty
)
{
return
$target
->
getDeclaringClass
()
->
getName
()
.
'::$'
.
$target
->
getName
();
}
else
{
return
$target
->
getName
();
}
}
protected
function
checkConstraints
(
$target
)
{}
}
class
Target
extends
Annotation
{}
class
AnnotationsBuilder
{
private
static
$cache
=
array
();
public
function
build
(
$targetReflection
)
{
$data
=
$this
->
parse
(
$targetReflection
);
$annotations
=
array
();
foreach
(
$data
as
$class
=>
$parameters
)
{
if
(
!
Addendum
::
ignores
(
$class
))
{
foreach
(
$parameters
as
$params
)
{
$annotationReflection
=
new
ReflectionClass
(
$class
);
$annotations
[
$class
][]
=
$annotationReflection
->
newInstance
(
$params
,
$targetReflection
);
}
}
}
return
$annotations
;
}
private
function
parse
(
$reflection
)
{
$key
=
$this
->
createName
(
$reflection
);
if
(
!
isset
(
self
::
$cache
[
$key
]))
{
$parser
=
new
AnnotationsMatcher
;
$parser
->
matches
(
$this
->
getDocComment
(
$reflection
),
$data
);
self
::
$cache
[
$key
]
=
$data
;
}
return
self
::
$cache
[
$key
];
}
private
function
createName
(
$target
)
{
if
(
$target
instanceof
ReflectionMethod
)
{
return
$target
->
getDeclaringClass
()
->
getName
()
.
'::'
.
$target
->
getName
();
}
elseif
(
$target
instanceof
ReflectionProperty
)
{
return
$target
->
getDeclaringClass
()
->
getName
()
.
'::$'
.
$target
->
getName
();
}
else
{
return
$target
->
getName
();
}
}
protected
function
getDocComment
(
$reflection
)
{
return
Addendum
::
getDocComment
(
$reflection
);
}
public
static
function
clearCache
()
{
self
::
$cache
=
array
();
}
}
class
ReflectionAnnotatedClass
extends
ReflectionClass
{
private
$annotations
;
public
function
__construct
(
$class
)
{
parent
::
__construct
(
$class
);
$this
->
annotations
=
$this
->
createAnnotationBuilder
()
->
build
(
$this
);
}
public
function
hasAnnotation
(
$annotation
)
{
return
isset
(
$this
->
annotations
[
$annotation
]);
}
public
function
getAnnotation
(
$annotation
)
{
return
$this
->
hasAnnotation
(
$annotation
)
?
end
(
$this
->
annotations
[
$annotation
])
:
false
;
}
public
function
getAnnotations
()
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$instances
)
{
$result
[]
=
end
(
$instances
);
}
return
$result
;
}
public
function
getAllAnnotations
(
$restriction
=
false
)
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$class
=>
$instances
)
{
if
(
!
$restriction
||
$restriction
==
$class
)
{
$result
=
array_merge
(
$result
,
$instances
);
}
}
return
$result
;
}
public
function
getConstructor
()
{
return
$this
->
createReflectionAnnotatedMethod
(
parent
::
getConstructor
());
}
public
function
getMethod
(
$name
)
{
return
$this
->
createReflectionAnnotatedMethod
(
parent
::
getMethod
(
$name
));
}
public
function
getMethods
(
$filter
=
-
1
)
{
$result
=
array
();
foreach
(
parent
::
getMethods
(
$filter
)
as
$method
)
{
$result
[]
=
$this
->
createReflectionAnnotatedMethod
(
$method
);
}
return
$result
;
}
public
function
getProperty
(
$name
)
{
return
$this
->
createReflectionAnnotatedProperty
(
parent
::
getProperty
(
$name
));
}
public
function
getProperties
(
$filter
=
-
1
)
{
$result
=
array
();
foreach
(
parent
::
getProperties
(
$filter
)
as
$property
)
{
$result
[]
=
$this
->
createReflectionAnnotatedProperty
(
$property
);
}
return
$result
;
}
public
function
getInterfaces
()
{
$result
=
array
();
foreach
(
parent
::
getInterfaces
()
as
$interface
)
{
$result
[]
=
$this
->
createReflectionAnnotatedClass
(
$interface
);
}
return
$result
;
}
public
function
getParentClass
()
{
$class
=
parent
::
getParentClass
();
return
$this
->
createReflectionAnnotatedClass
(
$class
);
}
protected
function
createAnnotationBuilder
()
{
return
new
AnnotationsBuilder
();
}
private
function
createReflectionAnnotatedClass
(
$class
)
{
return
(
$class
!==
false
)
?
new
ReflectionAnnotatedClass
(
$class
->
getName
())
:
false
;
}
private
function
createReflectionAnnotatedMethod
(
$method
)
{
return
(
$method
!==
null
)
?
new
ReflectionAnnotatedMethod
(
$this
->
getName
(),
$method
->
getName
())
:
null
;
}
private
function
createReflectionAnnotatedProperty
(
$property
)
{
return
(
$property
!==
null
)
?
new
ReflectionAnnotatedProperty
(
$this
->
getName
(),
$property
->
getName
())
:
null
;
}
}
class
ReflectionAnnotatedMethod
extends
ReflectionMethod
{
private
$annotations
;
public
function
__construct
(
$class
,
$name
)
{
parent
::
__construct
(
$class
,
$name
);
$this
->
annotations
=
$this
->
createAnnotationBuilder
()
->
build
(
$this
);
}
public
function
hasAnnotation
(
$annotation
)
{
return
isset
(
$this
->
annotations
[
$annotation
]);
}
public
function
getAnnotation
(
$annotation
)
{
return
(
$this
->
hasAnnotation
(
$annotation
))
?
end
(
$this
->
annotations
[
$annotation
])
:
false
;
}
public
function
getAnnotations
()
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$instances
)
{
$result
[]
=
end
(
$instances
);
}
return
$result
;
}
public
function
getAllAnnotations
(
$restriction
=
false
)
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$class
=>
$instances
)
{
if
(
!
$restriction
||
$restriction
==
$class
)
{
$result
=
array_merge
(
$result
,
$instances
);
}
}
return
$result
;
}
public
function
getDeclaringClass
()
{
$class
=
parent
::
getDeclaringClass
();
return
new
ReflectionAnnotatedClass
(
$class
->
getName
());
}
protected
function
createAnnotationBuilder
()
{
return
new
AnnotationsBuilder
();
}
}
class
ReflectionAnnotatedProperty
extends
ReflectionProperty
{
private
$annotations
;
public
function
__construct
(
$class
,
$name
)
{
parent
::
__construct
(
$class
,
$name
);
$this
->
annotations
=
$this
->
createAnnotationBuilder
()
->
build
(
$this
);
}
public
function
hasAnnotation
(
$annotation
)
{
return
isset
(
$this
->
annotations
[
$annotation
]);
}
public
function
getAnnotation
(
$annotation
)
{
return
(
$this
->
hasAnnotation
(
$annotation
))
?
end
(
$this
->
annotations
[
$annotation
])
:
false
;
}
public
function
getAnnotations
()
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$instances
)
{
$result
[]
=
end
(
$instances
);
}
return
$result
;
}
public
function
getAllAnnotations
(
$restriction
=
false
)
{
$result
=
array
();
foreach
(
$this
->
annotations
as
$class
=>
$instances
)
{
if
(
!
$restriction
||
$restriction
==
$class
)
{
$result
=
array_merge
(
$result
,
$instances
);
}
}
return
$result
;
}
public
function
getDeclaringClass
()
{
$class
=
parent
::
getDeclaringClass
();
return
new
ReflectionAnnotatedClass
(
$class
->
getName
());
}
protected
function
createAnnotationBuilder
()
{
return
new
AnnotationsBuilder
();
}
}
class
Addendum
{
private
static
$rawMode
;
private
static
$ignore
;
public
static
function
getDocComment
(
$reflection
)
{
if
(
self
::
checkRawDocCommentParsingNeeded
())
{
$docComment
=
new
DocComment
();
return
$docComment
->
get
(
$reflection
);
}
else
{
return
$reflection
->
getDocComment
();
}
}
/** Raw mode test */
private
static
function
checkRawDocCommentParsingNeeded
()
{
if
(
self
::
$rawMode
===
null
)
{
$reflection
=
new
ReflectionClass
(
'Addendum'
);
$method
=
$reflection
->
getMethod
(
'checkRawDocCommentParsingNeeded'
);
self
::
setRawMode
(
$method
->
getDocComment
()
===
false
);
}
return
self
::
$rawMode
;
}
public
static
function
setRawMode
(
$enabled
=
true
)
{
if
(
$enabled
)
{
require_once
(
dirname
(
__FILE__
)
.
'/annotations/doc_comment.php'
);
}
self
::
$rawMode
=
$enabled
;
}
public
static
function
resetIgnoredAnnotations
()
{
self
::
$ignore
=
array
();
}
public
static
function
ignores
(
$class
)
{
return
isset
(
self
::
$ignore
[
$class
]);
}
public
static
function
ignore
()
{
foreach
(
func_get_args
()
as
$class
)
{
self
::
$ignore
[
$class
]
=
true
;
}
}
}
?>
lib/
Doctrine/ORM/Mapping/Drive
r/addendum/annotations/annotation_parser.php
→
lib/
vendo
r/addendum/annotations/annotation_parser.php
View file @
a4e928e1
...
...
@@ -20,8 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**/
namespace
Addendum
;
class
CompositeMatcher
{
protected
$matchers
=
array
();
private
$wasConstructed
=
false
;
...
...
@@ -334,4 +332,4 @@ namespace Addendum;
return
$matches
[
1
];
}
}
?>
lib/
Doctrine/ORM/Mapping/Drive
r/addendum/annotations/doc_comment.php
→
lib/
vendo
r/addendum/annotations/doc_comment.php
View file @
a4e928e1
File moved
lib/vendor/addendum/annotations/tests/acceptance_test.php
0 → 100755
View file @
a4e928e1
<?php
require_once
(
'simpletest/autorun.php'
);
require_once
(
'simpletest/mock_objects.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/../../annotations.php'
);
interface
DummyInterface
{}
class
ParentExample
{}
/** @FirstAnnotation @SecondAnnotation */
class
Example
extends
ParentExample
implements
DummyInterface
{
/** @SecondAnnotation */
private
$exampleProperty
;
public
$publicOne
;
public
function
__construct
()
{}
/** @FirstAnnotation */
public
function
exampleMethod
()
{
}
private
function
justPrivate
()
{}
}
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
class
MultiExample
{
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
public
$property
;
/** @FirstAnnotation(1) @FirstAnnotation(2) @SecondAnnotation(3) */
public
function
aMethod
()
{}
}
class
FirstAnnotation
extends
Annotation
{}
class
SecondAnnotation
extends
Annotation
{}
class
TestOfAnnotations
extends
UnitTestCase
{
public
function
testReflectionAnnotatedClass
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'Example'
);
$this
->
assertTrue
(
$reflection
->
hasAnnotation
(
'FirstAnnotation'
));
$this
->
assertTrue
(
$reflection
->
hasAnnotation
(
'SecondAnnotation'
));
$this
->
assertFalse
(
$reflection
->
hasAnnotation
(
'NonExistentAnnotation'
));
$this
->
assertIsA
(
$reflection
->
getAnnotation
(
'FirstAnnotation'
),
'FirstAnnotation'
);
$this
->
assertIsA
(
$reflection
->
getAnnotation
(
'SecondAnnotation'
),
'SecondAnnotation'
);
$annotations
=
$reflection
->
getAnnotations
();
$this
->
assertEqual
(
count
(
$annotations
),
2
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
1
],
'SecondAnnotation'
);
$this
->
assertFalse
(
$reflection
->
getAnnotation
(
'NonExistentAnnotation'
));
$this
->
assertIsA
(
$reflection
->
getConstructor
(),
'ReflectionAnnotatedMethod'
);
$this
->
assertIsA
(
$reflection
->
getMethod
(
'exampleMethod'
),
'ReflectionAnnotatedMethod'
);
foreach
(
$reflection
->
getMethods
()
as
$method
)
{
$this
->
assertIsA
(
$method
,
'ReflectionAnnotatedMethod'
);
}
$this
->
assertIsA
(
$reflection
->
getProperty
(
'exampleProperty'
),
'ReflectionAnnotatedProperty'
);
foreach
(
$reflection
->
getProperties
()
as
$property
)
{
$this
->
assertIsA
(
$property
,
'ReflectionAnnotatedProperty'
);
}
foreach
(
$reflection
->
getInterfaces
()
as
$interface
)
{
$this
->
assertIsA
(
$interface
,
'ReflectionAnnotatedClass'
);
}
$this
->
assertIsA
(
$reflection
->
getParentClass
(),
'ReflectionAnnotatedClass'
);
}
public
function
testReflectionAnnotatedMethod
()
{
$reflection
=
new
ReflectionAnnotatedMethod
(
'Example'
,
'exampleMethod'
);
$this
->
assertTrue
(
$reflection
->
hasAnnotation
(
'FirstAnnotation'
));
$this
->
assertFalse
(
$reflection
->
hasAnnotation
(
'NonExistentAnnotation'
));
$this
->
assertIsA
(
$reflection
->
getAnnotation
(
'FirstAnnotation'
),
'FirstAnnotation'
);
$this
->
assertFalse
(
$reflection
->
getAnnotation
(
'NonExistentAnnotation'
));
$annotations
=
$reflection
->
getAnnotations
();
$this
->
assertEqual
(
count
(
$annotations
),
1
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$reflection
->
getDeclaringClass
(),
'ReflectionAnnotatedClass'
);
}
public
function
testReflectionAnnotatedProperty
()
{
$reflection
=
new
ReflectionAnnotatedProperty
(
'Example'
,
'exampleProperty'
);
$this
->
assertTrue
(
$reflection
->
hasAnnotation
(
'SecondAnnotation'
));
$this
->
assertFalse
(
$reflection
->
hasAnnotation
(
'FirstAnnotation'
));
$this
->
assertIsA
(
$reflection
->
getAnnotation
(
'SecondAnnotation'
),
'SecondAnnotation'
);
$this
->
assertFalse
(
$reflection
->
getAnnotation
(
'NonExistentAnnotation'
));
$annotations
=
$reflection
->
getAnnotations
();
$this
->
assertEqual
(
count
(
$annotations
),
1
);
$this
->
assertIsA
(
$annotations
[
0
],
'SecondAnnotation'
);
$this
->
assertIsA
(
$reflection
->
getDeclaringClass
(),
'ReflectionAnnotatedClass'
);
}
public
function
testReflectionClassCanFilterMethodsByAccess
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'Example'
);
$privateMethods
=
$reflection
->
getMethods
(
ReflectionMethod
::
IS_PRIVATE
);
$this
->
assertEqual
(
count
(
$privateMethods
),
1
);
$this
->
assertEqual
(
$privateMethods
[
0
]
->
getName
(),
'justPrivate'
);
}
public
function
testReflectionClassCanFilterPropertiesByAccess
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'Example'
);
$privateProperties
=
$reflection
->
getProperties
(
ReflectionProperty
::
IS_PUBLIC
);
$this
->
assertEqual
(
count
(
$privateProperties
),
1
);
$this
->
assertEqual
(
$privateProperties
[
0
]
->
getName
(),
'publicOne'
);
}
public
function
testReflectionClassShouldReturnAllMethodsWithNoFilter
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'Example'
);
$methods
=
$reflection
->
getMethods
();
$this
->
assertEqual
(
count
(
$methods
),
3
);
}
public
function
testReflectionClassShouldReturnAllPropertiesWithNoFilter
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'Example'
);
$properties
=
$reflection
->
getProperties
();
$this
->
assertEqual
(
count
(
$properties
),
2
);
}
public
function
testMultipleAnnotationsOnClass
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'MultiExample'
);
$annotations
=
$reflection
->
getAllAnnotations
();
$this
->
assertEqual
(
count
(
$annotations
),
3
);
$this
->
assertEqual
(
$annotations
[
0
]
->
value
,
1
);
$this
->
assertEqual
(
$annotations
[
1
]
->
value
,
2
);
$this
->
assertEqual
(
$annotations
[
2
]
->
value
,
3
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
1
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
2
],
'SecondAnnotation'
);
}
public
function
testMultipleAnnotationsOnClassWithRestriction
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'MultiExample'
);
$annotations
=
$reflection
->
getAllAnnotations
(
'FirstAnnotation'
);
$this
->
assertEqual
(
count
(
$annotations
),
2
);
$this
->
assertEqual
(
$annotations
[
0
]
->
value
,
1
);
$this
->
assertEqual
(
$annotations
[
1
]
->
value
,
2
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
1
],
'FirstAnnotation'
);
}
public
function
testMultipleAnnotationsOnProperty
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'MultiExample'
);
$reflection
=
$reflection
->
getProperty
(
'property'
);
$annotations
=
$reflection
->
getAllAnnotations
();
$this
->
assertEqual
(
count
(
$annotations
),
3
);
$this
->
assertEqual
(
$annotations
[
0
]
->
value
,
1
);
$this
->
assertEqual
(
$annotations
[
1
]
->
value
,
2
);
$this
->
assertEqual
(
$annotations
[
2
]
->
value
,
3
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
1
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
2
],
'SecondAnnotation'
);
}
public
function
testMultipleAnnotationsOnPropertyWithRestriction
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'MultiExample'
);
$reflection
=
$reflection
->
getProperty
(
'property'
);
$annotations
=
$reflection
->
getAllAnnotations
(
'FirstAnnotation'
);
$this
->
assertEqual
(
count
(
$annotations
),
2
);
$this
->
assertEqual
(
$annotations
[
0
]
->
value
,
1
);
$this
->
assertEqual
(
$annotations
[
1
]
->
value
,
2
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
1
],
'FirstAnnotation'
);
}
public
function
testMultipleAnnotationsOnMethod
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'MultiExample'
);
$reflection
=
$reflection
->
getMethod
(
'aMethod'
);
$annotations
=
$reflection
->
getAllAnnotations
();
$this
->
assertEqual
(
count
(
$annotations
),
3
);
$this
->
assertEqual
(
$annotations
[
0
]
->
value
,
1
);
$this
->
assertEqual
(
$annotations
[
1
]
->
value
,
2
);
$this
->
assertEqual
(
$annotations
[
2
]
->
value
,
3
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
1
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
2
],
'SecondAnnotation'
);
}
public
function
testMultipleAnnotationsOnMethodWithRestriction
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'MultiExample'
);
$reflection
=
$reflection
->
getMethod
(
'aMethod'
);
$annotations
=
$reflection
->
getAllAnnotations
(
'FirstAnnotation'
);
$this
->
assertEqual
(
count
(
$annotations
),
2
);
$this
->
assertEqual
(
$annotations
[
0
]
->
value
,
1
);
$this
->
assertEqual
(
$annotations
[
1
]
->
value
,
2
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
1
],
'FirstAnnotation'
);
}
}
Mock
::
generatePartial
(
'AnnotationsBuilder'
,
'MockedAnnotationsBuilder'
,
array
(
'getDocComment'
));
class
TestOfPerformanceFeatures
extends
UnitTestCase
{
public
function
setUp
()
{
AnnotationsBuilder
::
clearCache
();
}
public
function
tearDown
()
{
AnnotationsBuilder
::
clearCache
();
}
public
function
testBuilderShouldCacheResults
()
{
$builder
=
new
MockedAnnotationsBuilder
;
$reflection
=
new
ReflectionClass
(
'Example'
);
$builder
->
build
(
$reflection
);
$builder
->
build
(
$reflection
);
$builder
->
expectOnce
(
'getDocComment'
);
}
}
class
TestOfSupportingFeatures
extends
UnitTestCase
{
public
function
setUp
()
{
Addendum
::
resetIgnoredAnnotations
();
}
public
function
tearDown
()
{
Addendum
::
resetIgnoredAnnotations
();
}
public
function
testIgnoredAnnotationsAreNotUsed
()
{
Addendum
::
ignore
(
'FirstAnnotation'
,
'SecondAnnotation'
);
$reflection
=
new
ReflectionAnnotatedClass
(
'Example'
);
$this
->
assertFalse
(
$reflection
->
hasAnnotation
(
'FirstAnnotation'
));
$this
->
assertFalse
(
$reflection
->
hasAnnotation
(
'SecondAnnotation'
));
}
}
?>
lib/vendor/addendum/annotations/tests/all_tests.php
0 → 100755
View file @
a4e928e1
<?php
require_once
(
'simpletest/unit_tester.php'
);
require_once
(
'simpletest/reporter.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/acceptance_test.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/annotation_test.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/constrained_annotation_test.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/annotation_parser_test.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/doc_comment_test.php'
);
class
AllTests
extends
GroupTest
{
function
__construct
(
$title
=
false
)
{
parent
::
__construct
(
$title
);
$this
->
addTestClass
(
'TestOfAnnotations'
);
$this
->
addTestClass
(
'TestOfPerformanceFeatures'
);
$this
->
addTestClass
(
'TestOfSupportingFeatures'
);
$this
->
addTestClass
(
'TestOfAnnotation'
);
$this
->
addTestClass
(
'TestOfConstrainedAnnotation'
);
$this
->
addTestClass
(
'TestOfMatchers'
);
$this
->
addTestClass
(
'TestOfAnnotationMatchers'
);
$this
->
addTestClass
(
'TestOfDocComment'
);
}
}
Addendum
::
setRawMode
(
false
);
$test
=
new
AllTests
(
'All tests in reflection mode'
);
$test
->
run
(
new
HtmlReporter
());
Addendum
::
setRawMode
(
true
);
$test
=
new
AllTests
(
'All tests in raw mode'
);
$test
->
run
(
new
HtmlReporter
());
?>
lib/vendor/addendum/annotations/tests/annotation_parser_test.php
0 → 100755
View file @
a4e928e1
<?php
require_once
(
'simpletest/autorun.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/../annotation_parser.php'
);
class
TestOfMatchers
extends
UnitTestCase
{
public
function
testRegexMatcherShouldMatchPatternAndReturnLengthOfMatch
()
{
$matcher
=
new
RegexMatcher
(
'[0-9]+'
);
$this
->
assertIdentical
(
$matcher
->
matches
(
'1234a'
,
$value
),
4
);
$this
->
assertIdentical
(
$value
,
'1234'
);
}
public
function
testRegexMatcherShouldReturnFalseOnNoMatch
()
{
$matcher
=
new
RegexMatcher
(
'[0-9]+'
);
$this
->
assertFalse
(
$matcher
->
matches
(
'abc123'
,
$value
));
}
public
function
testParallelMatcherShouldMatchLongerStringOnColision
()
{
$matcher
=
new
ParallelMatcher
;
$matcher
->
add
(
new
RegexMatcher
(
'true'
));
$matcher
->
add
(
new
RegexMatcher
(
'.+'
));
$this
->
assertEqual
(
$matcher
->
matches
(
'truestring'
,
$value
),
10
);
$this
->
assertEqual
(
$value
,
'truestring'
);
}
public
function
testSerialMatcherShouldMatchAllParts
()
{
$matcher
=
new
SerialMatcher
;
$matcher
->
add
(
new
RegexMatcher
(
'[a-zA-Z0-9_]+'
));
$matcher
->
add
(
new
RegexMatcher
(
'='
));
$matcher
->
add
(
new
RegexMatcher
(
'[0-9]+'
));
$this
->
assertEqual
(
$matcher
->
matches
(
'key=20'
,
$value
),
6
);
$this
->
assertEqual
(
$value
,
'key=20'
);
}
public
function
testSerialMatcherShouldFailIfAnyPartDoesNotMatch
()
{
$matcher
=
new
SerialMatcher
;
$matcher
->
add
(
new
RegexMatcher
(
'[a-zA-Z0-9_]+'
));
$matcher
->
add
(
new
RegexMatcher
(
'='
));
$matcher
->
add
(
new
RegexMatcher
(
'[0-9]+'
));
$this
->
assertFalse
(
$matcher
->
matches
(
'key=a20'
,
$value
));
}
public
function
testSimpleSerialMatcherShouldReturnRequestedPartOnMatch
()
{
$matcher
=
new
SimpleSerialMatcher
(
1
);
$matcher
->
add
(
new
RegexMatcher
(
'\('
));
$matcher
->
add
(
new
RegexMatcher
(
'[0-9]+'
));
$matcher
->
add
(
new
RegexMatcher
(
'\)'
));
$this
->
assertEqual
(
$matcher
->
matches
(
'(1234)'
,
$value
),
6
);
$this
->
assertEqual
(
$value
,
'1234'
);
}
}
class
TestOfAnnotationMatchers
extends
UnitTestCase
{
public
function
testAnnotationsMatcherShouldMatchAnnotationWithGarbage
()
{
$expected
=
array
(
'Annotation'
=>
array
(
array
(
'value'
=>
true
),
));
$matcher
=
new
AnnotationsMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'/** asd bla bla @Annotation(true) */@'
,
$expected
);
}
public
function
testAnnotationsMatcherShouldNotMatchEmail
()
{
$matcher
=
new
AnnotationsMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'johno@example.com'
,
array
());
}
public
function
testAnnotationsMatcherShouldMatchMultipleAnnotations
()
{
$expected
=
array
(
'Annotation'
=>
array
(
array
(
'value'
=>
true
),
array
(
'value'
=>
false
)
));
$matcher
=
new
AnnotationsMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
' ss @Annotation(true) @Annotation(false)'
,
$expected
);
}
public
function
testAnnotationsMatcherShouldMatchMultipleAnnotationsOnManyLines
()
{
$expected
=
array
(
'Annotation'
=>
array
(
array
(
'value'
=>
true
),
array
(
'value'
=>
false
)
));
$block
=
"/**
@Annotation(true)
@Annotation(false)
**/"
;
$matcher
=
new
AnnotationsMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
$block
,
$expected
);
}
public
function
testAnnotationMatcherShouldMatchMultilineAnnotations
()
{
$block
=
'/**
* @Annotation(
paramOne="value1",
paramTwo={
"value2" ,
{"one", "two"}
},
paramThree="three"
)
*/'
;
$expected
=
array
(
'Annotation'
=>
array
(
array
(
'paramOne'
=>
'value1'
,
'paramTwo'
=>
array
(
'value2'
,
array
(
'one'
,
'two'
)),
'paramThree'
=>
'three'
,
)
));
$matcher
=
new
AnnotationsMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
$block
,
$expected
);
}
public
function
testAnnotationMatcherShouldMatchSimpleAnnotation
()
{
$matcher
=
new
AnnotationMatcher
;
$this
->
assertNotFalse
(
$matcher
->
matches
(
'@Namespace_Annotation'
,
$value
));
$this
->
assertEqual
(
$value
,
array
(
'Namespace_Annotation'
,
array
()));
}
public
function
testAnnotationMatcherShouldNotMatchAnnotationWithSmallStartingLetter
()
{
$matcher
=
new
AnnotationMatcher
;
$this
->
assertFalse
(
$matcher
->
matches
(
'@annotation'
,
$value
));
}
public
function
testAnnotationMatcherShouldMatchAlsoBrackets
()
{
$matcher
=
new
AnnotationMatcher
;
$this
->
assertEqual
(
$matcher
->
matches
(
'@Annotation()'
,
$value
),
13
);
$this
->
assertEqual
(
$value
,
array
(
'Annotation'
,
array
()));
}
public
function
testAnnotationMatcherShouldMatchValuedAnnotation
()
{
$matcher
=
new
AnnotationMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'@Annotation(true)'
,
array
(
'Annotation'
,
array
(
'value'
=>
true
)));
}
public
function
testAnnotationMatcherShouldMatchMultiValuedAnnotation
()
{
$matcher
=
new
AnnotationMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'@Annotation(key=true, key2=3.14)'
,
array
(
'Annotation'
,
array
(
'key'
=>
true
,
'key2'
=>
3.14
)));
}
public
function
testParametersMatcherShouldMatchEmptyStringAndReturnEmptyArray
()
{
$matcher
=
new
AnnotationParametersMatcher
;
$this
->
assertIdentical
(
$matcher
->
matches
(
''
,
$value
),
0
);
$this
->
assertEqual
(
$value
,
array
());
}
public
function
testParametersMatcherShouldMatchEmptyBracketsAndReturnEmptyArray
()
{
$matcher
=
new
AnnotationParametersMatcher
;
$this
->
assertIdentical
(
$matcher
->
matches
(
'()'
,
$value
),
2
);
$this
->
assertEqual
(
$value
,
array
());
}
public
function
testParametersMatcherShouldMatchMultilinedParameters
()
{
$matcher
=
new
AnnotationParametersMatcher
;
$block
=
"(
key = true,
key2 = false
)"
;
$this
->
assertMatcherResult
(
$matcher
,
$block
,
array
(
'key'
=>
true
,
'key2'
=>
false
));
}
public
function
testValuesMatcherShouldMatchSimpleValueOrHash
()
{
$matcher
=
new
AnnotationValuesMatcher
;
$this
->
assertNotFalse
(
$matcher
->
matches
(
'true'
,
$value
));
$this
->
assertNotFalse
(
$matcher
->
matches
(
'key=true'
,
$value
));
}
public
function
testValueMatcherShouldMatchConstants
()
{
$matcher
=
new
AnnotationValueMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'true'
,
true
);
$this
->
assertMatcherResult
(
$matcher
,
'false'
,
false
);
$this
->
assertMatcherResult
(
$matcher
,
'TRUE'
,
true
);
$this
->
assertMatcherResult
(
$matcher
,
'FALSE'
,
false
);
}
public
function
testValueMatcherShouldMatchStrings
()
{
$matcher
=
new
AnnotationValueMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'"string"'
,
'string'
);
$this
->
assertMatcherResult
(
$matcher
,
"'string'"
,
'string'
);
}
public
function
testValueMatcherShouldMatchNumbers
()
{
$matcher
=
new
AnnotationValueMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'-3.14'
,
-
3.14
);
$this
->
assertMatcherResult
(
$matcher
,
'100'
,
100
);
}
public
function
testValueMatcherShouldMatchArray
()
{
$matcher
=
new
AnnotationValueMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'{1}'
,
array
(
1
));
}
public
function
testArrayMatcherShouldMatchEmptyArray
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'{}'
,
array
());
}
public
function
testValueInArrayMatcherReturnsAValueInArray
()
{
$matcher
=
new
AnnotationValueInArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'1'
,
array
(
1
));
}
public
function
testArrayMatcherShouldMatchSimpleValueInArray
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'{1}'
,
array
(
1
));
}
public
function
testArrayMatcherShouldMatchSimplePair
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'{key=5}'
,
array
(
'key'
=>
5
));
}
public
function
TODO_testArrayMatcherShouldMatchPairWithNumericKeys
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'{1="one", 2="two"}'
,
array
(
1
=>
'one'
,
2
=>
'two'
));
}
public
function
testArrayMatcherShouldMatchMultiplePairs
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'{key=5, "bla"=false}'
,
array
(
'key'
=>
5
,
'bla'
=>
false
));
}
public
function
testArrayMatcherShouldMatchValuesMixedWithPairs
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'{key=5, 1, 2, key2="ff"}'
,
array
(
'key'
=>
5
,
1
,
2
,
'key2'
=>
"ff"
));
}
public
function
testArrayMatcherShouldMatchMoreValuesInArrayWithWhiteSpace
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
"{1 , 2}"
,
array
(
1
,
2
));
}
public
function
testArrayMatcherShouldMatchNestedArray
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
"{1 , {2, 3}, 4}"
,
array
(
1
,
array
(
2
,
3
),
4
));
}
public
function
testArrayMatcherShouldMatchWithMoreWhiteSpace
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
"{ 1 , 2 , 3 }"
,
array
(
1
,
2
,
3
));
}
public
function
testArrayMatcherShouldMatchWithMultilineWhiteSpace
()
{
$matcher
=
new
AnnotationArrayMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
"
\n
{1, 2, 3
\n
}"
,
array
(
1
,
2
,
3
));
}
public
function
testNumberMatcherShouldMatchInteger
()
{
$matcher
=
new
AnnotationNumberMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'-314'
,
-
314
);
}
public
function
testNumberMatcherShouldMatchFloat
()
{
$matcher
=
new
AnnotationNumberMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'-3.14'
,
-
3.14
);
}
public
function
testHashMatcherShouldMatchSimpleHash
()
{
$matcher
=
new
AnnotationHashMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'key=true'
,
array
(
'key'
=>
true
));
}
public
function
testHashMatcherShouldMatchAlsoMultipleKeys
()
{
$matcher
=
new
AnnotationHashMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'key=true,key2=false'
,
array
(
'key'
=>
true
,
'key2'
=>
false
));
}
public
function
testHashMatcherShouldMatchAlsoMultipleKeysWithWhiteSpace
()
{
$matcher
=
new
AnnotationHashMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
"key=true
\n\t\r
,
\n\t\r
key2=false"
,
array
(
'key'
=>
true
,
'key2'
=>
false
));
}
public
function
testPairMatcherShouldMatchNumericKey
()
{
$matcher
=
new
AnnotationPairMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'2 = true'
,
array
(
2
=>
true
));
}
public
function
testPairMatcherShouldMatchAlsoWhitespace
()
{
$matcher
=
new
AnnotationPairMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'key = true'
,
array
(
'key'
=>
true
));
}
public
function
testKeyMatcherShouldMatchSimpleKeysOrStrings
()
{
$matcher
=
new
AnnotationKeyMatcher
;
$this
->
assertNotFalse
(
$matcher
->
matches
(
'key'
,
$value
));
$this
->
assertNotFalse
(
$matcher
->
matches
(
'"key"'
,
$value
));
$this
->
assertNotFalse
(
$matcher
->
matches
(
"'key'"
,
$value
));
}
public
function
testKeyMatcherShouldMatchIntegerKeys
()
{
$matcher
=
new
AnnotationKeyMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'123'
,
123
);
}
public
function
testStringMatcherShouldMatchDoubleAndSingleQuotedStringsAndHandleEscapes
()
{
$matcher
=
new
AnnotationStringMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'"string string"'
,
'string string'
);
$this
->
assertMatcherResult
(
$matcher
,
"'string string'"
,
"string string"
);
}
public
function
TODO_testStringMatcherShouldMatchEscapedStringsCorrectly
()
{
$matcher
=
new
AnnotationStringMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'"string\"string"'
,
'string"string'
);
$this
->
assertMatcherResult
(
$matcher
,
"'string\'string'"
,
"string'string"
);
}
private
function
assertNotFalse
(
$value
)
{
$this
->
assertNotIdentical
(
$value
,
false
);
}
private
function
assertMatcherResult
(
$matcher
,
$string
,
$expected
)
{
$this
->
assertNotIdentical
(
$matcher
->
matches
(
$string
,
$value
),
false
);
$this
->
assertIdentical
(
$value
,
$expected
);
}
}
?>
\ No newline at end of file
lib/vendor/addendum/annotations/tests/annotation_test.php
0 → 100755
View file @
a4e928e1
<?php
require_once
(
'simpletest/autorun.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/../../annotations.php'
);
class
TestingAnnotation
extends
Annotation
{
public
$optional
=
'default'
;
public
$required
;
}
class
TestOfAnnotation
extends
UnitTestCase
{
public
function
testConstructorsFillsParameters
()
{
$annotation
=
new
TestingAnnotation
(
array
(
'optional'
=>
1
,
'required'
=>
2
),
$this
);
$this
->
assertEqual
(
$annotation
->
optional
,
1
);
$this
->
assertEqual
(
$annotation
->
required
,
2
);
}
public
function
testConstructorThrowsErrorOnInvalidParameter
()
{
$annotation
=
new
TestingAnnotation
(
array
(
'unknown'
=>
1
),
$this
);
$this
->
assertError
(
"Property 'unknown' not defined for annotation 'TestingAnnotation'"
);
}
public
function
TODO_testConstructorThrowsErrorWithoutSpecifingRequiredParameters
()
{
$annotation
=
new
TestingAnnotation
();
$this
->
assertError
(
"Property 'required' in annotation 'TestingAnnotation' is required"
);
}
}
?>
lib/vendor/addendum/annotations/tests/constrained_annotation_test.php
0 → 100755
View file @
a4e928e1
<?php
require_once
(
'simpletest/autorun.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/../../annotations.php'
);
/** @Target("class") */
class
ClassRestrictedAnnotation
extends
Annotation
{}
/** @Target("method") */
class
MethodRestrictedAnnotation
extends
Annotation
{}
/** @Target("property") */
class
PropertyRestrictedAnnotation
extends
Annotation
{}
/** @Target({"class", "property"}) */
class
ClassOrPropertyRestrictedAnnotation
extends
Annotation
{}
class
BadlyAnnotatedClass
{
/** @ClassRestrictedAnnotation */
private
$property
;
/** @ClassRestrictedAnnotation */
public
function
method
()
{}
/** @ClassOrPropertyRestrictedAnnotation */
public
function
method2
()
{}
}
/** @ClassRestrictedAnnotation */
class
SuccesfullyAnnotatedClass
{
/** @PropertyRestrictedAnnotation */
private
$property
;
/** @ClassOrPropertyRestrictedAnnotation */
private
$property2
;
/** @MethodRestrictedAnnotation */
public
function
method
()
{}
}
class
TestOfConstrainedAnnotation
extends
UnitTestCase
{
public
function
testClassAnnotationThrowsErrorWhenOnMethod
()
{
$this
->
expectError
(
"Annotation 'ClassRestrictedAnnotation' not allowed on BadlyAnnotatedClass::method"
);
$reflection
=
new
ReflectionAnnotatedClass
(
'BadlyAnnotatedClass'
);
$method
=
$reflection
->
getMethod
(
'method'
);
}
public
function
testClassAnnotationThrowsErrorWhenOnProperty
()
{
$this
->
expectError
(
"Annotation 'ClassRestrictedAnnotation' not allowed on BadlyAnnotatedClass::
\$
property"
);
$reflection
=
new
ReflectionAnnotatedClass
(
'BadlyAnnotatedClass'
);
$method
=
$reflection
->
getProperty
(
'property'
);
}
public
function
testSingleTargetAnnotationThrowsNoErrorWhenOnRightPlace
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'SuccesfullyAnnotatedClass'
);
$method
=
$reflection
->
getMethod
(
'method'
);
$property
=
$reflection
->
getProperty
(
'property'
);
$this
->
assertNoErrors
();
}
public
function
testMultiTargetAnnotationThrowsErrorWhenOnWrongPlace
()
{
$this
->
expectError
(
"Annotation 'ClassOrPropertyRestrictedAnnotation' not allowed on BadlyAnnotatedClass::method2"
);
$reflection
=
new
ReflectionAnnotatedClass
(
'BadlyAnnotatedClass'
);
$method
=
$reflection
->
getMethod
(
'method2'
);
}
public
function
testMultiTargetAnnotationThrowsNoErrorWhenOnRightPlace
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'SuccesfullyAnnotatedClass'
);
$method
=
$reflection
->
getProperty
(
'property2'
);
$this
->
assertNoErrors
();
}
}
?>
\ No newline at end of file
lib/vendor/addendum/annotations/tests/doc_comment_test.php
0 → 100755
View file @
a4e928e1
<?php
require_once
(
'simpletest/autorun.php'
);
require_once
(
'simpletest/mock_objects.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/../doc_comment.php'
);
Mock
::
generatePartial
(
'DocComment'
,
'MockDocComment'
,
array
(
'parse'
));
/** class doccomment */
class
SomeClass
{
/** field doccomment */
private
$field1
;
private
$field2
;
/** method1 doccomment */
public
function
method1
()
{
}
public
function
method2
()
{}
/** bad one */
}
class
SomeOtherClass
{
/** field doccomment */
private
$field1
;
}
class
TestOfDocComment
extends
UnitTestCase
{
public
function
setUp
()
{
DocComment
::
clearCache
();
}
public
function
testFinderFindsClassDocBlock
()
{
$reflection
=
new
ReflectionClass
(
'SomeClass'
);
$finder
=
new
DocComment
();
$this
->
assertEqual
(
$finder
->
get
(
$reflection
),
'/** class doccomment */'
);
}
public
function
testFinderFindsFieldDocBlock
()
{
$reflection
=
new
ReflectionClass
(
'SomeClass'
);
$property
=
$reflection
->
getProperty
(
'field1'
);
$finder
=
new
DocComment
();
$this
->
assertEqual
(
$finder
->
get
(
$property
),
'/** field doccomment */'
);
$property
=
$reflection
->
getProperty
(
'field2'
);
$finder
=
new
DocComment
();
$this
->
assertFalse
(
$finder
->
get
(
$property
));
}
public
function
testFinderFindsMethodDocBlock
()
{
$reflection
=
new
ReflectionClass
(
'SomeClass'
);
$method
=
$reflection
->
getMethod
(
'method1'
);
$finder
=
new
DocComment
();
$this
->
assertEqual
(
$finder
->
get
(
$method
),
'/** method1 doccomment */'
);
$method
=
$reflection
->
getMethod
(
'method2'
);
$finder
=
new
DocComment
();
$this
->
assertFalse
(
$finder
->
get
(
$method
));
}
public
function
testMisplacedDocCommentDoesNotCausesDisaster
()
{
$reflection
=
new
ReflectionClass
(
'SomeOtherClass'
);
$finder
=
new
DocComment
();
$this
->
assertEqual
(
$finder
->
get
(
$reflection
),
false
);
}
public
function
testUnanotatedClassCanHaveAnotatedField
()
{
$reflection
=
new
ReflectionClass
(
'SomeOtherClass'
);
$property
=
$reflection
->
getProperty
(
'field1'
);
$finder
=
new
DocComment
();
$this
->
assertEqual
(
$finder
->
get
(
$property
),
'/** field doccomment */'
);
}
public
function
testParserIsOnlyCalledOncePerFile
()
{
$reflection
=
new
ReflectionClass
(
'SomeClass'
);
$finder
=
new
MockDocComment
();
$finder
->
expectOnce
(
'parse'
);
$this
->
assertEqual
(
$finder
->
get
(
$reflection
),
false
);
$this
->
assertEqual
(
$finder
->
get
(
$reflection
),
false
);
$reflection
=
new
ReflectionClass
(
'SomeClass'
);
$finder
=
new
MockDocComment
();
$finder
->
expectNever
(
'parse'
);
$this
->
assertEqual
(
$finder
->
get
(
$reflection
),
false
);
}
}
?>
tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php
View file @
a4e928e1
...
...
@@ -13,11 +13,17 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected
function
setUp
()
{
parent
::
setUp
();
try
{
$this
->
_schemaTool
->
createSchema
(
array
(
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\ParentEntity'
),
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\ChildEntity'
),
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\RelatedEntity'
)
));
}
catch
(
\Exception
$e
)
{
if
(
stripos
(
$e
->
getMessage
(),
'already exists'
)
===
false
)
{
throw
$e
;
}
}
}
public
function
testCRUD
()
...
...
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