Issue #2105825 by cosmicdreams, larowlan, hussainweb, Nitesh Sethia, dawehner, naveenvalecha, iMiksu: Update Doctrine/common Component to 2.5.1 (security) (includes cache/annotations too)

8.0.x
webchick 2015-09-04 07:56:50 -07:00
parent 9f8d68afe4
commit ca850b84e2
194 changed files with 3571 additions and 7759 deletions

View File

@ -19,7 +19,7 @@
"symfony/process": "2.7.*",
"symfony/yaml": "2.7.*",
"twig/twig": "1.20.*",
"doctrine/common": "~2.4.2",
"doctrine/common": "2.5.*",
"doctrine/annotations": "1.2.*",
"guzzlehttp/guzzle": "dev-master#1879fbe853b0c64d109e369c7aeff09849e62d1e",
"symfony-cmf/routing": "1.3.*",

162
core/composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "6d065bd806544df5f446905bc3d6379f",
"hash": "775f6be68f3d5efa8872e99cdf0e2f83",
"packages": [
{
"name": "behat/mink",
@ -126,7 +126,7 @@
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/minkphp/MinkGoutteDriver/zipball/cc5ce119b5a8e06662f634b35967aff0b0c7dfdd",
"url": "https://api.github.com/repos/minkphp/MinkGoutteDriver/zipball/7e9a7319cc0e8cf9d4d4c9e06e2020d3a31bd792",
"reference": "cc5ce119b5a8e06662f634b35967aff0b0c7dfdd",
"shasum": ""
},
@ -170,16 +170,16 @@
},
{
"name": "doctrine/annotations",
"version": "v1.2.1",
"version": "v1.2.7",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633"
"reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/6a6bec0670bb6e71a263b08bc1b98ea242928633",
"reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
"reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
"shasum": ""
},
"require": {
@ -234,20 +234,20 @@
"docblock",
"parser"
],
"time": "2014-09-25 16:45:30"
"time": "2015-08-31 12:32:49"
},
{
"name": "doctrine/cache",
"version": "v1.3.1",
"version": "v1.4.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7"
"reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/cf483685798a72c93bf4206e3dd6358ea07d64e7",
"reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7",
"url": "https://api.github.com/repos/doctrine/cache/zipball/8c434000f420ade76a07c64cbe08ca47e5c101ca",
"reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca",
"shasum": ""
},
"require": {
@ -258,12 +258,13 @@
},
"require-dev": {
"phpunit/phpunit": ">=3.7",
"predis/predis": "~1.0",
"satooshi/php-coveralls": "~0.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
"dev-master": "1.5.x-dev"
}
},
"autoload": {
@ -303,25 +304,28 @@
"cache",
"caching"
],
"time": "2014-09-17 14:24:04"
"time": "2015-08-31 12:36:41"
},
{
"name": "doctrine/collections",
"version": "v1.2",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/collections.git",
"reference": "b99c5c46c87126201899afe88ec490a25eedd6a2"
"reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/collections/zipball/b99c5c46c87126201899afe88ec490a25eedd6a2",
"reference": "b99c5c46c87126201899afe88ec490a25eedd6a2",
"url": "https://api.github.com/repos/doctrine/collections/zipball/6c1e4eef75f310ea1b3e30945e9f06e652128b8a",
"reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
@ -338,17 +342,6 @@
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/",
"role": "Creator"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
@ -357,11 +350,17 @@
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
"email": "schmittjoh@gmail.com"
}
],
"description": "Collections Abstraction library",
@ -371,20 +370,20 @@
"collections",
"iterator"
],
"time": "2014-02-03 23:07:43"
"time": "2015-04-14 22:21:58"
},
{
"name": "doctrine/common",
"version": "v2.4.2",
"version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common.git",
"reference": "5db6ab40e4c531f14dad4ca96a394dfce5d4255b"
"reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/5db6ab40e4c531f14dad4ca96a394dfce5d4255b",
"reference": "5db6ab40e4c531f14dad4ca96a394dfce5d4255b",
"url": "https://api.github.com/repos/doctrine/common/zipball/0009b8f0d4a917aabc971fb089eba80e872f83f9",
"reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9",
"shasum": ""
},
"require": {
@ -401,7 +400,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4.x-dev"
"dev-master": "2.6.x-dev"
}
},
"autoload": {
@ -414,17 +413,6 @@
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/",
"role": "Creator"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
@ -433,11 +421,17 @@
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
"email": "schmittjoh@gmail.com"
}
],
"description": "Common Library for Doctrine projects",
@ -449,26 +443,34 @@
"persistence",
"spl"
],
"time": "2014-05-21 19:28:51"
"time": "2015-08-31 13:00:22"
},
{
"name": "doctrine/inflector",
"version": "v1.0",
"version": "v1.0.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/inflector.git",
"reference": "v1.0"
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/54b8333d2a5682afdc690060c1cf384ba9f47f08",
"reference": "v1.0",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/0bcb2e79d8571787f18b7eb036ed3d004908e604",
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "4.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Common\\Inflector\\": "lib/"
@ -479,16 +481,6 @@
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
@ -498,34 +490,40 @@
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"inflection",
"pluarlize",
"singuarlize",
"pluralize",
"singularize",
"string"
],
"time": "2013-01-10 21:49:15"
"time": "2014-12-20 21:24:13"
},
{
"name": "doctrine/instantiator",
"version": "1.0.4",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119"
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119",
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
"shasum": ""
},
"require": {
@ -536,7 +534,7 @@
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "2.0.*@ALPHA"
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
@ -545,8 +543,8 @@
}
},
"autoload": {
"psr-0": {
"Doctrine\\Instantiator\\": "src"
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -566,7 +564,7 @@
"constructor",
"instantiate"
],
"time": "2014-10-13 12:58:55"
"time": "2015-06-14 21:17:01"
},
{
"name": "doctrine/lexer",
@ -796,7 +794,7 @@
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d687700d601f8b5f19b99ffc1c0f6af835a3c7b7",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/33af93ab4b5e76df7a4c774910590f814a3e576c",
"reference": "1879fbe853b0c64d109e369c7aeff09849e62d1e",
"shasum": ""
},

View File

@ -14,7 +14,6 @@ return array(
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
'Egulias\\' => array($vendorDir . '/egulias/email-validator/src'),
'EasyRdf_' => array($vendorDir . '/easyrdf/easyrdf/lib'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src'),
'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'),

View File

@ -37,6 +37,7 @@ return array(
'Drupal\\Driver\\' => array($baseDir . '/../drivers/lib/Drupal/Driver'),
'Drupal\\Core\\' => array($baseDir . '/lib/Drupal/Core'),
'Drupal\\Component\\' => array($baseDir . '/lib/Drupal/Component'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'Behat\\Mink\\Driver\\' => array($vendorDir . '/behat/mink-goutte-driver/src'),
'Behat\\Mink\\' => array($vendorDir . '/behat/mink/src'),
);

View File

@ -1,280 +1,4 @@
[
{
"name": "doctrine/inflector",
"version": "v1.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/inflector.git",
"reference": "v1.0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/54b8333d2a5682afdc690060c1cf384ba9f47f08",
"reference": "v1.0",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"time": "2013-01-10 21:49:15",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Inflector\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"inflection",
"pluarlize",
"singuarlize",
"string"
]
},
{
"name": "doctrine/collections",
"version": "v1.2",
"version_normalized": "1.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/collections.git",
"reference": "b99c5c46c87126201899afe88ec490a25eedd6a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/collections/zipball/b99c5c46c87126201899afe88ec490a25eedd6a2",
"reference": "b99c5c46c87126201899afe88ec490a25eedd6a2",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"time": "2014-02-03 23:07:43",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Collections\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/",
"role": "Creator"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
"description": "Collections Abstraction library",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"array",
"collections",
"iterator"
]
},
{
"name": "doctrine/cache",
"version": "v1.3.1",
"version_normalized": "1.3.1.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/cf483685798a72c93bf4206e3dd6358ea07d64e7",
"reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
},
"require-dev": {
"phpunit/phpunit": ">=3.7",
"satooshi/php-coveralls": "~0.6"
},
"time": "2014-09-17 14:24:04",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Cache\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Caching library offering an object-oriented API for many cache backends",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"cache",
"caching"
]
},
{
"name": "doctrine/annotations",
"version": "v1.2.1",
"version_normalized": "1.2.1.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/6a6bec0670bb6e71a263b08bc1b98ea242928633",
"reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "4.*"
},
"time": "2014-09-25 16:45:30",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Annotations\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Docblock Annotations Parser",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"docblock",
"parser"
]
},
{
"name": "phpunit/php-text-template",
"version": "1.2.0",
@ -321,62 +45,6 @@
"template"
]
},
{
"name": "doctrine/instantiator",
"version": "1.0.4",
"version_normalized": "1.0.4.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119",
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119",
"shasum": ""
},
"require": {
"php": ">=5.3,<8.0-DEV"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "2.0.*@ALPHA"
},
"time": "2014-10-13 12:58:55",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Instantiator\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.com/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"keywords": [
"constructor",
"instantiate"
]
},
{
"name": "phpunit/php-timer",
"version": "1.0.5",
@ -691,86 +359,6 @@
"global state"
]
},
{
"name": "doctrine/common",
"version": "v2.4.2",
"version_normalized": "2.4.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common.git",
"reference": "5db6ab40e4c531f14dad4ca96a394dfce5d4255b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/5db6ab40e4c531f14dad4ca96a394dfce5d4255b",
"reference": "5db6ab40e4c531f14dad4ca96a394dfce5d4255b",
"shasum": ""
},
"require": {
"doctrine/annotations": "1.*",
"doctrine/cache": "1.*",
"doctrine/collections": "1.*",
"doctrine/inflector": "1.*",
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~3.7"
},
"time": "2014-05-21 19:28:51",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/",
"role": "Creator"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
"description": "Common Library for Doctrine projects",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"collections",
"eventmanager",
"persistence",
"spl"
]
},
{
"name": "behat/mink",
"version": "v1.6.1",
@ -2121,7 +1709,7 @@
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d687700d601f8b5f19b99ffc1c0f6af835a3c7b7",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/33af93ab4b5e76df7a4c774910590f814a3e576c",
"reference": "1879fbe853b0c64d109e369c7aeff09849e62d1e",
"shasum": ""
},
@ -2236,7 +1824,7 @@
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/minkphp/MinkGoutteDriver/zipball/cc5ce119b5a8e06662f634b35967aff0b0c7dfdd",
"url": "https://api.github.com/repos/minkphp/MinkGoutteDriver/zipball/7e9a7319cc0e8cf9d4d4c9e06e2020d3a31bd792",
"reference": "cc5ce119b5a8e06662f634b35967aff0b0c7dfdd",
"shasum": ""
},
@ -3477,5 +3065,415 @@
"stream",
"uri"
]
},
{
"name": "doctrine/common",
"version": "v2.5.1",
"version_normalized": "2.5.1.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common.git",
"reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/0009b8f0d4a917aabc971fb089eba80e872f83f9",
"reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9",
"shasum": ""
},
"require": {
"doctrine/annotations": "1.*",
"doctrine/cache": "1.*",
"doctrine/collections": "1.*",
"doctrine/inflector": "1.*",
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~3.7"
},
"time": "2015-08-31 13:00:22",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Common Library for Doctrine projects",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"collections",
"eventmanager",
"persistence",
"spl"
]
},
{
"name": "doctrine/annotations",
"version": "v1.2.7",
"version_normalized": "1.2.7.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
"reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "4.*"
},
"time": "2015-08-31 12:32:49",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Annotations\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Docblock Annotations Parser",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"docblock",
"parser"
]
},
{
"name": "doctrine/instantiator",
"version": "1.0.5",
"version_normalized": "1.0.5.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
"shasum": ""
},
"require": {
"php": ">=5.3,<8.0-DEV"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"time": "2015-06-14 21:17:01",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.com/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"keywords": [
"constructor",
"instantiate"
]
},
{
"name": "doctrine/cache",
"version": "v1.4.2",
"version_normalized": "1.4.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/8c434000f420ade76a07c64cbe08ca47e5c101ca",
"reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
},
"require-dev": {
"phpunit/phpunit": ">=3.7",
"predis/predis": "~1.0",
"satooshi/php-coveralls": "~0.6"
},
"time": "2015-08-31 12:36:41",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Cache\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Caching library offering an object-oriented API for many cache backends",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"cache",
"caching"
]
},
{
"name": "doctrine/collections",
"version": "v1.3.0",
"version_normalized": "1.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/collections.git",
"reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/collections/zipball/6c1e4eef75f310ea1b3e30945e9f06e652128b8a",
"reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"time": "2015-04-14 22:21:58",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Collections\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Collections Abstraction library",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"array",
"collections",
"iterator"
]
},
{
"name": "doctrine/inflector",
"version": "v1.0.1",
"version_normalized": "1.0.1.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/inflector.git",
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/0bcb2e79d8571787f18b7eb036ed3d004908e604",
"reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "4.*"
},
"time": "2014-12-20 21:24:13",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Inflector\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"inflection",
"pluralize",
"singularize",
"string"
]
}
]

View File

@ -162,13 +162,14 @@ class AnnotationReader implements Reader
throw AnnotationException::optimizerPlusSaveComments();
}
if (PHP_VERSION_ID < 70000) {
if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.load_comments') === "0" || ini_get('opcache.load_comments') === "0")) {
throw AnnotationException::optimizerPlusLoadComments();
}
if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.load_comments') === "0" || ini_get('opcache.load_comments') === "0")) {
throw AnnotationException::optimizerPlusLoadComments();
}
if (extension_loaded('Zend OPcache') && ini_get('opcache.load_comments') == 0) {
throw AnnotationException::optimizerPlusLoadComments();
if (extension_loaded('Zend OPcache') && ini_get('opcache.load_comments') == 0) {
throw AnnotationException::optimizerPlusLoadComments();
}
}
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php');

View File

@ -84,7 +84,7 @@ final class DocLexer extends AbstractLexer
return array(
'[a-z_\\\][a-z0-9_\:\\\]*[a-z_][a-z0-9_]*',
'(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?',
'"(?:[^"]|"")*"',
'"(?:""|[^"])*+"',
);
}

View File

@ -24,6 +24,10 @@ namespace Doctrine\Common\Annotations;
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*
* @deprecated the FileCacheReader is deprecated and will be removed
* in version 2.0.0 of doctrine/annotations. Please use the
* {@see \Doctrine\Common\Annotations\CachedReader} instead.
*/
class FileCacheReader implements Reader
{
@ -52,6 +56,11 @@ class FileCacheReader implements Reader
*/
private $classNameHashes = array();
/**
* @var int
*/
private $umask;
/**
* Constructor.
*
@ -61,10 +70,19 @@ class FileCacheReader implements Reader
*
* @throws \InvalidArgumentException
*/
public function __construct(Reader $reader, $cacheDir, $debug = false)
public function __construct(Reader $reader, $cacheDir, $debug = false, $umask = 0002)
{
if ( ! is_int($umask)) {
throw new \InvalidArgumentException(sprintf(
'The parameter umask must be an integer, was: %s',
gettype($umask)
));
}
$this->reader = $reader;
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true)) {
$this->umask = $umask;
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777 & (~$this->umask), true)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $cacheDir));
}
@ -189,7 +207,25 @@ class FileCacheReader implements Reader
if (!is_writable($this->dir)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $this->dir));
}
file_put_contents($path, '<?php return unserialize('.var_export(serialize($data), true).');');
$tempfile = tempnam($this->dir, uniqid('', true));
if (false === $tempfile) {
throw new \RuntimeException(sprintf('Unable to create tempfile in directory: %s', $this->dir));
}
$written = file_put_contents($tempfile, '<?php return unserialize('.var_export(serialize($data), true).');');
if (false === $written) {
throw new \RuntimeException(sprintf('Unable to write cached file to: %s', $tempfile));
}
@chmod($tempfile, 0666 & (~$this->umask));
if (false === rename($tempfile, $path)) {
@unlink($tempfile);
throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
}
}
/**

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/Doctrine/Tests/TestInit.php"
>
<testsuites>
<testsuite name="Doctrine Annotations Test Suite">
<directory>./tests/Doctrine/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./lib/Doctrine/</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
</exclude>
</groups>
</phpunit>

View File

@ -1,645 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
use Doctrine\Common\Annotations\Annotation;
use Doctrine\Common\Annotations\Reader;
use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader;
require_once __DIR__ . '/TopLevelAnnotation.php';
abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase
{
public function getReflectionClass()
{
$className = 'Doctrine\Tests\Common\Annotations\DummyClass';
return new ReflectionClass($className);
}
public function testAnnotations()
{
$class = $this->getReflectionClass();
$reader = $this->getReader();
$this->assertEquals(1, count($reader->getClassAnnotations($class)));
$this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation', $annot = $reader->getClassAnnotation($class, $annotName));
$this->assertEquals("hello", $annot->dummyValue);
$field1Prop = $class->getProperty('field1');
$propAnnots = $reader->getPropertyAnnotations($field1Prop);
$this->assertEquals(1, count($propAnnots));
$this->assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName));
$this->assertEquals("fieldHello", $annot->dummyValue);
$getField1Method = $class->getMethod('getField1');
$methodAnnots = $reader->getMethodAnnotations($getField1Method);
$this->assertEquals(1, count($methodAnnots));
$this->assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName));
$this->assertEquals(array(1, 2, "three"), $annot->value);
$field2Prop = $class->getProperty('field2');
$propAnnots = $reader->getPropertyAnnotations($field2Prop);
$this->assertEquals(1, count($propAnnots));
$this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyJoinTable', $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName));
$this->assertEquals(1, count($joinTableAnnot->joinColumns));
$this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns));
$this->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn);
$this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn);
$this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
$this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
$this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
$this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
$dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
$this->assertEquals('', $dummyAnnot->dummyValue);
$this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value);
$dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
$this->assertEquals('fieldHello', $dummyAnnot->dummyValue);
$classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
$this->assertEquals('hello', $classAnnot->dummyValue);
}
public function testAnnotationsWithValidTargets()
{
$reader = $this->getReader();
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget');
$this->assertEquals(1,count($reader->getClassAnnotations($class)));
$this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('foo'))));
$this->assertEquals(1,count($reader->getMethodAnnotations($class->getMethod('someFunction'))));
$this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('nested'))));
}
public function testAnnotationsWithVarType()
{
$reader = $this->getReader();
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
$this->assertEquals(1,count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))));
$this->assertEquals(1,count($barAnnot = $reader->getMethodAnnotations($class->getMethod('bar'))));
$this->assertInternalType('string', $fooAnnot[0]->string);
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', $barAnnot[0]->annotation);
}
public function testAtInDescription()
{
$reader = $this->getReader();
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAtInDescriptionAndAnnotation');
$this->assertEquals(1, count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))));
$this->assertEquals(1, count($barAnnot = $reader->getPropertyAnnotations($class->getProperty('bar'))));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod', $fooAnnot[0]);
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod', $barAnnot[0]);
}
public function testClassWithWithDanglingComma()
{
$reader = $this->getReader();
$annots = $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClassWithDanglingComma'));
$this->assertCount(1, $annots);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetPropertyMethod is not allowed to be declared on class Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass. You may only use this annotation on these code elements: METHOD, PROPERTY
*/
public function testClassWithInvalidAnnotationTargetAtClassDocBlock()
{
$reader = $this->getReader();
$reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass'));
}
public function testClassWithWithInclude()
{
$reader = $this->getReader();
$annots = $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithRequire'));
$this->assertCount(1, $annots);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$foo. You may only use this annotation on these code elements: CLASS
*/
public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock()
{
$reader = $this->getReader();
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'foo'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetAnnotation is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$bar. You may only use this annotation on these code elements: ANNOTATION
*/
public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock()
{
$reader = $this->getReader();
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'bar'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod::functionName(). You may only use this annotation on these code elements: CLASS
*/
public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
{
$reader = $this->getReader();
$reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod', 'functionName'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
*/
public function testClassWithAnnotationWithTargetSyntaxErrorAtClassDocBlock()
{
$reader = $this->getReader();
$reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
*/
public function testClassWithAnnotationWithTargetSyntaxErrorAtPropertyDocBlock()
{
$reader = $this->getReader();
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','foo'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
*/
public function testClassWithAnnotationWithTargetSyntaxErrorAtMethodDocBlock()
{
$reader = $this->getReader();
$reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','bar'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Type Error] Attribute "string" of @AnnotationWithVarType declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::$invalidProperty expects a(n) string, but got integer.
*/
public function testClassWithPropertyInvalidVarTypeError()
{
$reader = $this->getReader();
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
$reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Type Error] Attribute "annotation" of @AnnotationWithVarType declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::invalidMethod() expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll, but got an instance of Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation.
*/
public function testClassWithMethodInvalidVarTypeError()
{
$reader = $this->getReader();
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
$reader->getMethodAnnotations($class->getMethod('invalidMethod'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in class Doctrine\Tests\Common\Annotations\DummyClassSyntaxError.
*/
public function testClassSyntaxErrorContext()
{
$reader = $this->getReader();
$reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClassSyntaxError'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in method Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError::foo().
*/
public function testMethodSyntaxErrorContext()
{
$reader = $this->getReader();
$reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError', 'foo'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in property Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError::$foo.
*/
public function testPropertySyntaxErrorContext()
{
$reader = $this->getReader();
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError', 'foo'));
}
/**
* @group regression
*/
public function testMultipleAnnotationsOnSameLine()
{
$reader = $this->getReader();
$annots = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClass2', 'id'));
$this->assertEquals(3, count($annots));
}
public function testNonAnnotationProblem()
{
$reader = $this->getReader();
$this->assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassNonAnnotationProblem', 'foo'), $name = 'Doctrine\Tests\Common\Annotations\DummyAnnotation'));
$this->assertInstanceOf($name, $annot);
}
public function testIncludeIgnoreAnnotation()
{
$reader = $this->getReader();
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithIgnoreAnnotation', 'foo'));
$this->assertFalse(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\IgnoreAnnotationClass', false));
}
public function testImportWithConcreteAnnotation()
{
$reader = $this->getReader();
$property = new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestImportWithConcreteAnnotation', 'field');
$annotations = $reader->getPropertyAnnotations($property);
$this->assertEquals(1, count($annotations));
$this->assertNotNull($reader->getPropertyAnnotation($property, 'Doctrine\Tests\Common\Annotations\DummyAnnotation'));
}
public function testImportWithInheritance()
{
$reader = $this->getReader();
$class = new TestParentClass();
$ref = new \ReflectionClass($class);
$childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child'));
$this->assertEquals(1, count($childAnnotations));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Foo\Name', reset($childAnnotations));
$parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent'));
$this->assertEquals(1, count($parentAnnotations));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Name', reset($parentAnnotations));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage The annotation "@NameFoo" in property Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass::$field was never imported.
*/
public function testImportDetectsNotImportedAnnotation()
{
$reader = $this->getReader();
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass', 'field'));
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage The annotation "@Foo\Bar\Name" in property Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass::$field was never imported.
*/
public function testImportDetectsNonExistentAnnotation()
{
$reader = $this->getReader();
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass', 'field'));
}
public function testTopLevelAnnotation()
{
$reader = $this->getReader();
$annotations = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestTopLevelAnnotationClass', 'field'));
$this->assertEquals(1, count($annotations));
$this->assertInstanceOf('\TopLevelAnnotation', reset($annotations));
}
public function testIgnoresAnnotationsNotPrefixedWithWhitespace()
{
$reader = $this->getReader();
$annotation = $reader->getClassAnnotation(new \ReflectionClass(new TestIgnoresNonAnnotationsClass()), 'Doctrine\Tests\Common\Annotations\Name');
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annotation);
}
private static $testResetsPhpParserAfterUseRun = false;
/**
* When getUseStatements isn't available on ReflectionClass the PhpParser has to use token_get_all(). If that
* happens various PHP compiler globals get set, and these can have seriously bad effects on the next file to be
* parsed.
* Notably the doc_comment compiler global can end up containing a docblock comment. The next file to be parsed
* on an include() will have this docblock comment attached to the first thing in the file that the compiler
* considers to own comments. If this is a class then any later calls to getDocComment() for that class will have
* undesirable effects. *sigh*
*/
public function testResetsPhpParserAfterUse()
{
// If someone has already included our main test fixture this test is invalid. It's important that our require
// causes this file to be parsed and compiled at a certain point.
$this->assertFalse(!self::$testResetsPhpParserAfterUseRun && class_exists('Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment'), 'Test invalid if class has already been compiled');
self::$testResetsPhpParserAfterUseRun = true;
$reader = $this->getReader();
// First make sure the annotation cache knows about the annotations we want to use.
// If we don't do this then loading of annotations into the cache will cause the parser to get out of the bad
// state we want to test.
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget');
$reader->getClassAnnotations($class);
// Now import an incredibly dull class which makes use of the same class level annotation that the previous class does.
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithClassAnnotationOnly');
$annotations = $reader->getClassAnnotations($class);
// This include needs to be here since we need the PHP compiler to run over it as the next thing the PHP
// parser sees since PhpParser called token_get_all() on the intro to ClassWithClassAnnotationOnly.
// Our test class cannot be in a namespace (some versions of PHP reset the doc_comment compiler global when
// you hit a namespace declaration), so cannot be autoloaded.
require_once __DIR__ . '/Fixtures/ClassNoNamespaceNoComment.php';
// So, hopefully, if all has gone OK, our class with class annotations should actually have them.
// If this fails then something is quite badly wrong elsewhere.
// Note that if this happens before the require it can cause other PHP files to be included, resetting the
// compiler global state, and invalidating this test case.
$this->assertNotEmpty($annotations);
$annotations = $reader->getClassAnnotations(new \ReflectionClass(new \Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment()));
// And if our workaround for this bug is OK, our class with no doc comment should not have any class annotations.
$this->assertEmpty($annotations);
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage The class "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation". If it is indeed no annotation, then you need to add @IgnoreAnnotation("NoAnnotation") to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass.
*/
public function testErrorWhenInvalidAnnotationIsUsed()
{
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass');
$reader->getClassAnnotations($ref);
}
public function testInvalidAnnotationUsageButIgnoredClass()
{
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageButIgnoredClass');
$annots = $reader->getClassAnnotations($ref);
$this->assertEquals(2, count($annots));
}
/**
* @group DDC-1660
* @group regression
*/
public function testInvalidAnnotationButIgnored()
{
$reader = $this->getReader();
$class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660');
$this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version'));
$this->assertCount(0, $reader->getClassAnnotations($class));
$this->assertCount(0, $reader->getMethodAnnotations($class->getMethod('bar')));
$this->assertCount(0, $reader->getPropertyAnnotations($class->getProperty('foo')));
}
public function testAnnotationEnumeratorException()
{
$reader = $this->getReader();
$class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum');
$this->assertCount(1, $bar = $reader->getMethodAnnotations($class->getMethod('bar')));
$this->assertCount(1, $foo = $reader->getPropertyAnnotations($class->getProperty('foo')));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $bar[0]);
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $foo[0]);
try {
$reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::$invalidProperty accept only [ONE, TWO, THREE], but got FOUR.', $exc->getMessage());
}
try {
$reader->getMethodAnnotations($class->getMethod('invalidMethod'));
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::invalidMethod() accept only [ONE, TWO, THREE], but got 5.', $exc->getMessage());
}
}
/**
* @group DCOM-106
*/
public function testIgnoreFixMeAndUpperCaseToDo()
{
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\DCOM106');
$reader->getClassAnnotations($ref);
}
/**
* @return AnnotationReader
*/
abstract protected function getReader();
}
/**
* @parseAnnotation("var")
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
*/
class TestParseAnnotationClass
{
/**
* @var
*/
private $field;
}
/**
* @Name
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class TestIgnoresNonAnnotationsClass
{
}
class TestTopLevelAnnotationClass
{
/**
* @\TopLevelAnnotation
*/
private $field;
}
class TestNonExistentAnnotationClass
{
/**
* @Foo\Bar\Name
*/
private $field;
}
class TestAnnotationNotImportedClass
{
/**
* @NameFoo
*/
private $field;
}
class TestChildClass
{
/**
* @\Doctrine\Tests\Common\Annotations\Foo\Name(name = "foo")
*/
protected $child;
}
class TestParentClass extends TestChildClass
{
/**
* @\Doctrine\Tests\Common\Annotations\Bar\Name(name = "bar")
*/
private $parent;
}
class TestImportWithConcreteAnnotation
{
/**
* @DummyAnnotation(dummyValue = "bar")
*/
private $field;
}
/**
* @ignoreAnnotation("var")
*/
class DummyClass2 {
/**
* @DummyId @DummyColumn(type="integer") @DummyGeneratedValue
* @var integer
*/
private $id;
}
/** @Annotation */
class DummyId extends Annotation {}
/** @Annotation */
class DummyColumn extends Annotation {
public $type;
}
/** @Annotation */
class DummyGeneratedValue extends Annotation {}
/** @Annotation */
class DummyAnnotation extends Annotation {
public $dummyValue;
}
/**
* @api
* @Annotation
*/
class DummyAnnotationWithIgnoredAnnotation extends Annotation {
public $dummyValue;
}
/** @Annotation */
class DummyJoinColumn extends Annotation {
public $name;
public $referencedColumnName;
}
/** @Annotation */
class DummyJoinTable extends Annotation {
public $name;
public $joinColumns;
public $inverseJoinColumns;
}
/**
* @DummyAnnotation(dummyValue = "bar",)
*/
class DummyClassWithDanglingComma
{
}
/**
* @DummyAnnotation(@)
*/
class DummyClassSyntaxError
{
}
class DummyClassMethodSyntaxError
{
/**
* @DummyAnnotation(@)
*/
public function foo()
{
}
}
class DummyClassPropertySyntaxError
{
/**
* @DummyAnnotation(@)
*/
public $foo;
}
/**
* @ignoreAnnotation({"since", "var"})
*/
class DummyClassNonAnnotationProblem
{
/**
* @DummyAnnotation
*
* @var \Test
* @since 0.1
*/
public $foo;
}
/**
* @DummyAnnotation Foo bar <foobar@1domain.com>
*/
class DummyClassWithEmail
{
}
/**
* @fixme public
* @TODO
*/
class DCOM106
{
}
namespace Doctrine\Tests\Common\Annotations\Foo;
/** @Annotation */
class Name extends \Doctrine\Common\Annotations\Annotation
{
public $name;
}
namespace Doctrine\Tests\Common\Annotations\Bar;
/** @Annotation */
class Name extends \Doctrine\Common\Annotations\Annotation
{
public $name;
}

View File

@ -1,59 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\AnnotationReader;
class AnnotationReaderTest extends AbstractReaderTest
{
protected function getReader()
{
return new AnnotationReader();
}
public function testMethodAnnotationFromTrait()
{
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('This test requires PHP 5.4 or later.');
}
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassUsesTrait');
$annotations = $reader->getMethodAnnotations($ref->getMethod('someMethod'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Autoload', $annotations[0]);
$annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]);
}
public function testMethodAnnotationFromOverwrittenTrait()
{
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('This test requires PHP 5.4 or later.');
}
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassOverwritesTrait');
$annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar2\Autoload', $annotations[0]);
}
public function testPropertyAnnotationFromTrait()
{
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('This test requires PHP 5.4 or later.');
}
$reader = $this->getReader();
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassUsesTrait');
$annotations = $reader->getPropertyAnnotations($ref->getProperty('aProperty'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Autoload', $annotations[0]);
$annotations = $reader->getPropertyAnnotations($ref->getProperty('traitProperty'));
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]);
}
}

View File

@ -1,56 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Cache\ArrayCache;
class CachedReaderTest extends AbstractReaderTest
{
private $cache;
public function testIgnoresStaleCache()
{
$file = __DIR__.'/Fixtures/Controller.php';
touch($file);
$name = 'Doctrine\Tests\Common\Annotations\Fixtures\Controller';
$cacheKey = $name.'@[Annot]';
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
$cache
->expects($this->at(0))
->method('fetch')
->with($this->equalTo($cacheKey))
->will($this->returnValue(array()))
;
$cache
->expects($this->at(1))
->method('fetch')
->with($this->equalTo('[C]'.$cacheKey))
->will($this->returnValue(time() - 10))
;
$cache
->expects($this->at(2))
->method('save')
->with($this->equalTo($cacheKey))
;
$cache
->expects($this->at(3))
->method('save')
->with($this->equalTo('[C]'.$cacheKey))
;
$reader = new CachedReader(new AnnotationReader(), $cache, true);
$route = new Route();
$route->pattern = '/someprefix';
$this->assertEquals(array($route), $reader->getClassAnnotations(new \ReflectionClass($name)));
}
protected function getReader()
{
$this->cache = new ArrayCache();
return new CachedReader(new AnnotationReader(), $this->cache);
}
}

View File

@ -1,157 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\DocLexer;
class DocLexerTest extends \PHPUnit_Framework_TestCase
{
public function testMarkerAnnotation()
{
$lexer = new DocLexer;
$lexer->setInput("@Name");
$this->assertNull($lexer->token);
$this->assertNull($lexer->lookahead);
$this->assertTrue($lexer->moveNext());
$this->assertNull($lexer->token);
$this->assertEquals('@', $lexer->lookahead['value']);
$this->assertTrue($lexer->moveNext());
$this->assertEquals('@', $lexer->token['value']);
$this->assertEquals('Name', $lexer->lookahead['value']);
$this->assertFalse($lexer->moveNext());
}
public function testScannerTokenizesDocBlockWhitConstants()
{
$lexer = new DocLexer();
$docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, ClassWithConstants::CONSTANT_, ClassWithConstants::CONST_ANT3, \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)';
$tokens = array (
array(
'value' => '@',
'position' => 0,
'type' => DocLexer::T_AT,
),
array(
'value' => 'AnnotationWithConstants',
'position' => 1,
'type' => DocLexer::T_IDENTIFIER,
),
array(
'value' => '(',
'position' => 24,
'type' => DocLexer::T_OPEN_PARENTHESIS,
),
array(
'value' => 'PHP_EOL',
'position' => 25,
'type' => DocLexer::T_IDENTIFIER,
),
array(
'value' => ',',
'position' => 32,
'type' => DocLexer::T_COMMA,
),
array(
'value' => 'ClassWithConstants::SOME_VALUE',
'position' => 34,
'type' => DocLexer::T_IDENTIFIER,
),
array(
'value' => ',',
'position' => 64,
'type' => DocLexer::T_COMMA,
),
array(
'value' => 'ClassWithConstants::CONSTANT_',
'position' => 66,
'type' => DocLexer::T_IDENTIFIER,
),
array(
'value' => ',',
'position' => 95,
'type' => DocLexer::T_COMMA,
),
array(
'value' => 'ClassWithConstants::CONST_ANT3',
'position' => 97,
'type' => DocLexer::T_IDENTIFIER,
),
array(
'value' => ',',
'position' => 127,
'type' => DocLexer::T_COMMA,
),
array(
'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\IntefaceWithConstants::SOME_VALUE',
'position' => 129,
'type' => DocLexer::T_IDENTIFIER,
),
array(
'value' => ')',
'position' => 206,
'type' => DocLexer::T_CLOSE_PARENTHESIS,
)
);
$lexer->setInput($docblock);
foreach ($tokens as $expected) {
$lexer->moveNext();
$lookahead = $lexer->lookahead;
$this->assertEquals($expected['value'], $lookahead['value']);
$this->assertEquals($expected['type'], $lookahead['type']);
$this->assertEquals($expected['position'], $lookahead['position']);
}
$this->assertFalse($lexer->moveNext());
}
public function testScannerTokenizesDocBlockWhitInvalidIdentifier()
{
$lexer = new DocLexer();
$docblock = '@Foo\3.42';
$tokens = array (
array(
'value' => '@',
'position' => 0,
'type' => DocLexer::T_AT,
),
array(
'value' => 'Foo',
'position' => 1,
'type' => DocLexer::T_IDENTIFIER,
),
array(
'value' => '\\',
'position' => 4,
'type' => DocLexer::T_NAMESPACE_SEPARATOR,
),
array(
'value' => 3.42,
'position' => 5,
'type' => DocLexer::T_FLOAT,
)
);
$lexer->setInput($docblock);
foreach ($tokens as $expected) {
$lexer->moveNext();
$lookahead = $lexer->lookahead;
$this->assertEquals($expected['value'], $lookahead['value']);
$this->assertEquals($expected['type'], $lookahead['type']);
$this->assertEquals($expected['position'], $lookahead['position']);
}
$this->assertFalse($lexer->moveNext());
}
}

View File

@ -1,48 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Tests\Common\Annotations\DummyAnnotation;
use Doctrine\Tests\Common\Annotations\Name;
use Doctrine\Tests\Common\Annotations\DummyJoinTable;
use Doctrine\Tests\Common\Annotations\DummyJoinColumn;
/**
* A description of this class.
*
* Let's see if the parser recognizes that this @ is not really referring to an
* annotation. Also make sure that @var \ is not concated to "@var\is".
*
* @author robo
* @since 2.0
* @DummyAnnotation(dummyValue="hello")
*/
class DummyClass
{
/**
* A nice property.
*
* @var mixed
* @DummyAnnotation(dummyValue="fieldHello")
*/
private $field1;
/**
* @DummyJoinTable(name="join_table",
* joinColumns={@DummyJoinColumn(name="col1", referencedColumnName="col2")},
* inverseJoinColumns={
* @DummyJoinColumn(name="col3", referencedColumnName="col4")
* })
*/
private $field2;
/**
* Gets the value of field1.
*
* @return mixed
* @DummyAnnotation({1,2,"three"})
*/
public function getField1()
{
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\FileCacheReader;
class FileCacheReaderTest extends AbstractReaderTest
{
private $cacheDir;
protected function getReader()
{
$this->cacheDir = sys_get_temp_dir() . "/annotations_". uniqid();
@mkdir($this->cacheDir);
return new FileCacheReader(new AnnotationReader(), $this->cacheDir);
}
public function tearDown()
{
foreach (glob($this->cacheDir.'/*.php') AS $file) {
unlink($file);
}
rmdir($this->cacheDir);
}
/**
* @group DCOM-81
*/
public function testAttemptToCreateAnnotationCacheDir()
{
$this->cacheDir = sys_get_temp_dir() . "/not_existed_dir_". uniqid();
$this->assertFalse(is_dir($this->cacheDir));
new FileCacheReader(new AnnotationReader(), $this->cacheDir);
$this->assertTrue(is_dir($this->cacheDir));
}
}

View File

@ -1,10 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/** @Annotation */
class AnnotWithDefaultValue
{
/** @var string */
public $foo = 'bar';
}

View File

@ -1,10 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/**
* @Annotation
*/
class Autoload
{
}

View File

@ -1,11 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/** @Annotation */
class Route
{
/** @var string @Required */
public $pattern;
public $name;
}

View File

@ -1,18 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/** @Annotation */
class Secure
{
private $roles;
public function __construct(array $values)
{
if (is_string($values['value'])) {
$values['value'] = array($values['value']);
}
$this->roles = $values['value'];
}
}

View File

@ -1,14 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/** @Annotation */
class Template
{
private $name;
public function __construct(array $values)
{
$this->name = isset($values['value']) ? $values['value'] : null;
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/**
* @Annotation
* @Target("PROPERTY")
*/
final class Version
{
}

View File

@ -1,21 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
*/
final class AnnotationEnum
{
const ONE = 'ONE';
const TWO = 'TWO';
const THREE = 'THREE';
/**
* @var mixed
*
* @Enum({"ONE","TWO","THREE"})
*/
public $value;
}

View File

@ -1,17 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
*/
final class AnnotationEnumInvalid
{
/**
* @var mixed
*
* @Enum({1, 2, "foo", "bar", {"foo":"bar"}})
*/
public $value;
}

View File

@ -1,34 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnumLiteral as SelfEnum;
/**
* @Annotation
* @Target("ALL")
*/
final class AnnotationEnumLiteral
{
const ONE = 1;
const TWO = 2;
const THREE = 3;
/**
* @var mixed
*
* @Enum(
* value = {
* 1,
* 2,
* 3,
* },
* literal = {
* 1 : "AnnotationEnumLiteral::ONE",
* 2 : "AnnotationEnumLiteral::TWO",
* 3 : "AnnotationEnumLiteral::THREE",
* }
* )
*/
public $value;
}

View File

@ -1,31 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
*/
final class AnnotationEnumLiteralInvalid
{
const ONE = 1;
const TWO = 2;
const THREE = 3;
/**
* @var mixed
*
* @Enum(
* value = {
* 1,
* 2
* },
* literal = {
* 1 : "AnnotationEnumLiteral::ONE",
* 2 : "AnnotationEnumLiteral::TWO",
* 3 : "AnnotationEnumLiteral::THREE"
* }
* )
*/
public $value;
}

View File

@ -1,14 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
*/
class AnnotationTargetAll
{
public $data;
public $name;
public $target;
}

View File

@ -1,14 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target({ "ANNOTATION" })
*/
final class AnnotationTargetAnnotation
{
public $data;
public $name;
public $target;
}

View File

@ -1,15 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("CLASS")
*/
final class AnnotationTargetClass
{
public $data;
public $name;
public $target;
}

View File

@ -1,15 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("METHOD")
*/
final class AnnotationTargetMethod
{
public $data;
public $name;
public $target;
}

View File

@ -1,14 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target({ "METHOD", "PROPERTY" })
*/
final class AnnotationTargetPropertyMethod
{
public $data;
public $name;
public $target;
}

View File

@ -1,129 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
* @Attributes({
@Attribute("mixed", type = "mixed"),
@Attribute("boolean", type = "boolean"),
@Attribute("bool", type = "bool"),
@Attribute("float", type = "float"),
@Attribute("string", type = "string"),
@Attribute("integer", type = "integer"),
@Attribute("array", type = "array"),
@Attribute("arrayOfIntegers", type = "array<integer>"),
@Attribute("arrayOfStrings", type = "string[]"),
@Attribute("annotation", type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll"),
@Attribute("arrayOfAnnotations", type = "array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>"),
})
*/
final class AnnotationWithAttributes
{
public final function __construct(array $data)
{
foreach ($data as $key => $value) {
$this->$key = $value;
}
}
private $mixed;
private $boolean;
private $bool;
private $float;
private $string;
private $integer;
private $array;
private $annotation;
private $arrayOfIntegers;
private $arrayOfStrings;
private $arrayOfAnnotations;
/**
* @return mixed
*/
public function getMixed()
{
return $this->mixed;
}
/**
* @return boolean
*/
public function getBoolean()
{
return $this->boolean;
}
/**
* @return bool
*/
public function getBool()
{
return $this->bool;
}
/**
* @return float
*/
public function getFloat()
{
return $this->float;
}
/**
* @return string
*/
public function getString()
{
return $this->string;
}
public function getInteger()
{
return $this->integer;
}
/**
* @return array
*/
public function getArray()
{
return $this->array;
}
/**
* @return Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll
*/
public function getAnnotation()
{
return $this->annotation;
}
/**
* @return string[]
*/
public function getArrayOfStrings()
{
return $this->arrayOfIntegers;
}
/**
* @return array<integer>
*/
public function getArrayOfIntegers()
{
return $this->arrayOfIntegers;
}
/**
* @return array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>
*/
public function getArrayOfAnnotations()
{
return $this->arrayOfAnnotations;
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
*/
final class AnnotationWithConstants
{
const INTEGER = 1;
const FLOAT = 1.2;
const STRING = '1.2.3';
/**
* @var mixed
*/
public $value;
}

View File

@ -1,50 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
* @Attributes({
@Attribute("value", required = true , type = "string"),
@Attribute("annot", required = true , type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation"),
})
*/
final class AnnotationWithRequiredAttributes
{
public final function __construct(array $data)
{
foreach ($data as $key => $value) {
$this->$key = $value;
}
}
/**
* @var string
*/
private $value;
/**
*
* @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation
*/
private $annot;
/**
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* @return Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation
*/
public function getAnnot()
{
return $this->annot;
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
*/
final class AnnotationWithRequiredAttributesWithoutContructor
{
/**
* @Required
* @var string
*/
public $value;
/**
* @Required
* @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation
*/
public $annot;
}

View File

@ -1,11 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target(@)
*/
final class AnnotationWithTargetSyntaxError
{
}

View File

@ -1,67 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @Annotation
* @Target("ALL")
*/
final class AnnotationWithVarType
{
/**
* @var mixed
*/
public $mixed;
/**
* @var boolean
*/
public $boolean;
/**
* @var bool
*/
public $bool;
/**
* @var float
*/
public $float;
/**
* @var string
*/
public $string;
/**
* @var integer
*/
public $integer;
/**
* @var array
*/
public $array;
/**
* @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll
*/
public $annotation;
/**
* @var array<integer>
*/
public $arrayOfIntegers;
/**
* @var string[]
*/
public $arrayOfStrings;
/**
* @var array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>
*/
public $arrayOfAnnotations;
}

View File

@ -1,10 +0,0 @@
<?php
/**
* This class is not an annotation
* It's a class build to test ClassWithInclude
*/
class Api
{
}

View File

@ -1,30 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @since 2.0
* @version $Id: SomeEntityClass.php 509 2012-02-03 09:38:48Z mf $
*/
class ClassDDC1660
{
/**
* @var string
* @since 2.0
* @version 1
*/
public $foo;
/**
* @param string
* @return string
* @since 2.0
* @version 1
*/
public function bar($param)
{
return null;
}
}

View File

@ -1,7 +0,0 @@
<?php
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment {
}

View File

@ -1,25 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Bar2\Autoload;
class ClassOverwritesTrait {
use TraitWithAnnotatedMethod;
/**
* @Autoload
*/
public function traitMethod()
{
}
}
namespace Doctrine\Tests\Common\Annotations\Bar2;
/** @Annotation */
class Autoload
{
}

View File

@ -1,30 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Bar\Autoload;
class ClassUsesTrait {
use TraitWithAnnotatedMethod;
/**
* @Autoload
*/
public $aProperty;
/**
* @Autoload
*/
public function someMethod()
{
}
}
namespace Doctrine\Tests\Common\Annotations\Bar;
/** @Annotation */
class Autoload
{
}

View File

@ -1,29 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum;
class ClassWithAnnotationEnum
{
/**
* @AnnotationEnum(AnnotationEnum::ONE)
*/
public $foo;
/**
* @AnnotationEnum("TWO")
*/
public function bar(){}
/**
* @AnnotationEnum("FOUR")
*/
public $invalidProperty;
/**
* @AnnotationEnum(5)
*/
public function invalidMethod(){}
}

View File

@ -1,21 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError;
/**
* @AnnotationWithTargetSyntaxError()
*/
class ClassWithAnnotationWithTargetSyntaxError
{
/**
* @AnnotationWithTargetSyntaxError()
*/
public $foo;
/**
* @AnnotationWithTargetSyntaxError()
*/
public function bar(){}
}

View File

@ -1,31 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
class ClassWithAnnotationWithVarType
{
/**
* @AnnotationWithVarType(string = "String Value")
*/
public $foo;
/**
* @AnnotationWithVarType(annotation = @AnnotationTargetAll)
*/
public function bar(){}
/**
* @AnnotationWithVarType(string = 123)
*/
public $invalidProperty;
/**
* @AnnotationWithVarType(annotation = @AnnotationTargetAnnotation)
*/
public function invalidMethod(){}
}

View File

@ -1,34 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod;
class ClassWithAtInDescriptionAndAnnotation
{
/**
* Lala
*
* {
* "email": "foo@example.com",
* "email2": "123@example.com",
* "email3": "@example.com"
* }
*
* @AnnotationTargetPropertyMethod("Bar")
*/
public $foo;
/**
* Lala
*
* {
* "email": "foo@example.com",
* "email2": "123@example.com",
* "email3": "@example.com"
* }
*
*@AnnotationTargetPropertyMethod("Bar")
*/
public $bar;
}

View File

@ -1,13 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
/**
* @AnnotationTargetClass("Some data")
*/
class ClassWithClassAnnotationOnly
{
}

View File

@ -1,52 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
/**
* @AnnotationTargetAll("Foo")
*/
final class ClassWithClosure
{
/**
* @AnnotationTargetAll(@AnnotationTargetAnnotation)
* @var string
*/
public $value;
/**
* @AnnotationTargetAll(@AnnotationTargetAnnotation)
*
* @param \Closure $callback
* @return \Closure
*/
public function methodName(\Closure $callback)
{
$self = $this;
return function() use ($self, $callback) {
return $callback;
};
}
/**
* @param integer $year
* @param integer $month
* @param integer $day
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getEventsForDate($year, $month, $day){
$extractEvents = null; // check if date of item is inside day given
$extractEvents = $this->events->filter(function ($item) use ($year, $month, $day) {
$leftDate = new \DateTime($year.'-'.$month.'-'.$day.' 00:00');
$rigthDate = new \DateTime($year.'-'.$month.'-'.$day.' +1 day 00:00');
return ( ( $leftDate <= $item->getDateStart() ) && ( $item->getDateStart() < $rigthDate ) );
}
);
return $extractEvents;
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
class ClassWithConstants
{
const SOME_VALUE = 'ClassWithConstants.SOME_VALUE';
const SOME_KEY = 'ClassWithConstants.SOME_KEY';
const OTHER_KEY_ = 'ClassWithConstants.OTHER_KEY_';
const OTHER_KEY_2 = 'ClassWithConstants.OTHER_KEY_2';
}

View File

@ -1,11 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use
\Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure,
\Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route
;
use \Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
class ClassWithFullyQualifiedUseStatements {}

View File

@ -1,14 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @ignoreAnnotation("IgnoreAnnotationClass")
*/
class ClassWithIgnoreAnnotation
{
/**
* @IgnoreAnnotationClass
*/
public $foo;
}

View File

@ -1,17 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod;
/**
* @AnnotationTargetPropertyMethod("Some data")
*/
class ClassWithInvalidAnnotationTargetAtClass
{
/**
* @AnnotationTargetPropertyMethod("Bar")
*/
public $foo;
}

View File

@ -1,20 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
/**
* @AnnotationTargetClass("Some data")
*/
class ClassWithInvalidAnnotationTargetAtMethod
{
/**
* @AnnotationTargetClass("functionName")
*/
public function functionName($param)
{
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
/**
* @AnnotationTargetClass("Some data")
*/
class ClassWithInvalidAnnotationTargetAtProperty
{
/**
* @AnnotationTargetClass("Bar")
*/
public $foo;
/**
* @AnnotationTargetAnnotation("Foo")
*/
public $bar;
}

View File

@ -1,15 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
// Include a class named Api
require_once(__DIR__ . '/Api.php');
use Doctrine\Tests\Common\Annotations\DummyAnnotationWithIgnoredAnnotation;
/**
* @DummyAnnotationWithIgnoredAnnotation(dummyValue="hello")
*/
class ClassWithRequire
{
}

View File

@ -1,40 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod;
/**
* @AnnotationTargetClass("Some data")
*/
class ClassWithValidAnnotationTarget
{
/**
* @AnnotationTargetPropertyMethod("Some data")
*/
public $foo;
/**
* @AnnotationTargetAll("Some data",name="Some name")
*/
public $name;
/**
* @AnnotationTargetPropertyMethod("Some data",name="Some name")
*/
public function someFunction()
{
}
/**
* @AnnotationTargetAll(@AnnotationTargetAnnotation)
*/
public $nested;
}

View File

@ -1,300 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
/**
* @Route("/someprefix")
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class Controller
{
/**
* @Route("/", name="_demo")
* @Template()
*/
public function indexAction()
{
return array();
}
/**
* @Route("/hello/{name}", name="_demo_hello")
* @Template()
*/
public function helloAction($name)
{
return array('name' => $name);
}
/**
* @Route("/contact", name="_demo_contact")
* @Template()
*/
public function contactAction()
{
$form = ContactForm::create($this->get('form.context'), 'contact');
$form->bind($this->container->get('request'), $form);
if ($form->isValid()) {
$form->send($this->get('mailer'));
$this->get('session')->setFlash('notice', 'Message sent!');
return new RedirectResponse($this->generateUrl('_demo'));
}
return array('form' => $form);
}
/**
* Creates the ACL for the passed object identity
*
* @param ObjectIdentityInterface $oid
* @return void
*/
private function createObjectIdentity(ObjectIdentityInterface $oid)
{
$classId = $this->createOrRetrieveClassId($oid->getType());
$this->connection->executeQuery($this->getInsertObjectIdentitySql($oid->getIdentifier(), $classId, true));
}
/**
* Returns the primary key for the passed class type.
*
* If the type does not yet exist in the database, it will be created.
*
* @param string $classType
* @return integer
*/
private function createOrRetrieveClassId($classType)
{
if (false !== $id = $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn()) {
return $id;
}
$this->connection->executeQuery($this->getInsertClassSql($classType));
return $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn();
}
/**
* Returns the primary key for the passed security identity.
*
* If the security identity does not yet exist in the database, it will be
* created.
*
* @param SecurityIdentityInterface $sid
* @return integer
*/
private function createOrRetrieveSecurityIdentityId(SecurityIdentityInterface $sid)
{
if (false !== $id = $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn()) {
return $id;
}
$this->connection->executeQuery($this->getInsertSecurityIdentitySql($sid));
return $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn();
}
/**
* Deletes all ACEs for the given object identity primary key.
*
* @param integer $oidPK
* @return void
*/
private function deleteAccessControlEntries($oidPK)
{
$this->connection->executeQuery($this->getDeleteAccessControlEntriesSql($oidPK));
}
/**
* Deletes the object identity from the database.
*
* @param integer $pk
* @return void
*/
private function deleteObjectIdentity($pk)
{
$this->connection->executeQuery($this->getDeleteObjectIdentitySql($pk));
}
/**
* Deletes all entries from the relations table from the database.
*
* @param integer $pk
* @return void
*/
private function deleteObjectIdentityRelations($pk)
{
$this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk));
}
/**
* This regenerates the ancestor table which is used for fast read access.
*
* @param AclInterface $acl
* @return void
*/
private function regenerateAncestorRelations(AclInterface $acl)
{
$pk = $acl->getId();
$this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk));
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
$parentAcl = $acl->getParentAcl();
while (null !== $parentAcl) {
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $parentAcl->getId()));
$parentAcl = $parentAcl->getParentAcl();
}
}
/**
* This processes changes on an ACE related property (classFieldAces, or objectFieldAces).
*
* @param string $name
* @param array $changes
* @return void
*/
private function updateFieldAceProperty($name, array $changes)
{
$sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage();
$currentIds = array();
foreach ($changes[1] as $field => $new) {
for ($i=0,$c=count($new); $i<$c; $i++) {
$ace = $new[$i];
if (null === $ace->getId()) {
if ($sids->contains($ace->getSecurityIdentity())) {
$sid = $sids->offsetGet($ace->getSecurityIdentity());
} else {
$sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity());
}
$oid = $ace->getAcl()->getObjectIdentity();
if ($classIds->contains($oid)) {
$classId = $classIds->offsetGet($oid);
} else {
$classId = $this->createOrRetrieveClassId($oid->getType());
}
$objectIdentityId = $name === 'classFieldAces' ? null : $ace->getAcl()->getId();
$this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure()));
$aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i))->fetchColumn();
$this->loadedAces[$aceId] = $ace;
$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
$aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, intval($aceId));
} else {
$currentIds[$ace->getId()] = true;
}
}
}
foreach ($changes[0] as $old) {
for ($i=0,$c=count($old); $i<$c; $i++) {
$ace = $old[$i];
if (!isset($currentIds[$ace->getId()])) {
$this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
unset($this->loadedAces[$ace->getId()]);
}
}
}
}
/**
* This processes changes on an ACE related property (classAces, or objectAces).
*
* @param string $name
* @param array $changes
* @return void
*/
private function updateAceProperty($name, array $changes)
{
list($old, $new) = $changes;
$sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage();
$currentIds = array();
for ($i=0,$c=count($new); $i<$c; $i++) {
$ace = $new[$i];
if (null === $ace->getId()) {
if ($sids->contains($ace->getSecurityIdentity())) {
$sid = $sids->offsetGet($ace->getSecurityIdentity());
} else {
$sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity());
}
$oid = $ace->getAcl()->getObjectIdentity();
if ($classIds->contains($oid)) {
$classId = $classIds->offsetGet($oid);
} else {
$classId = $this->createOrRetrieveClassId($oid->getType());
}
$objectIdentityId = $name === 'classAces' ? null : $ace->getAcl()->getId();
$this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, null, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure()));
$aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, null, $i))->fetchColumn();
$this->loadedAces[$aceId] = $ace;
$aceIdProperty = new \ReflectionProperty($ace, 'id');
$aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, intval($aceId));
} else {
$currentIds[$ace->getId()] = true;
}
}
for ($i=0,$c=count($old); $i<$c; $i++) {
$ace = $old[$i];
if (!isset($currentIds[$ace->getId()])) {
$this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
unset($this->loadedAces[$ace->getId()]);
}
}
}
/**
* Persists the changes which were made to ACEs to the database.
*
* @param \SplObjectStorage $aces
* @return void
*/
private function updateAces(\SplObjectStorage $aces)
{
foreach ($aces as $ace) {
$propertyChanges = $aces->offsetGet($ace);
$sets = array();
if (isset($propertyChanges['mask'])) {
$sets[] = sprintf('mask = %d', $propertyChanges['mask'][1]);
}
if (isset($propertyChanges['strategy'])) {
$sets[] = sprintf('granting_strategy = %s', $this->connection->quote($propertyChanges['strategy']));
}
if (isset($propertyChanges['aceOrder'])) {
$sets[] = sprintf('ace_order = %d', $propertyChanges['aceOrder'][1]);
}
if (isset($propertyChanges['auditSuccess'])) {
$sets[] = sprintf('audit_success = %s', $this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditSuccess'][1]));
}
if (isset($propertyChanges['auditFailure'])) {
$sets[] = sprintf('audit_failure = %s', $this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditFailure'][1]));
}
$this->connection->executeQuery($this->getUpdateAccessControlEntrySql($ace->getId(), $sets));
}
}
}

View File

@ -1,15 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
class DifferentNamespacesPerFileWithClassAsFirst {}
}
namespace {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
}
namespace Doctrine\Tests\Common\Annotations\Fixtures\Foo {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
}

View File

@ -1,15 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Foo {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
}
namespace {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
}
namespace Doctrine\Tests\Common\Annotations\Fixtures {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
class DifferentNamespacesPerFileWithClassAsLast {}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
class EqualNamespacesPerFileWithClassAsFirst {}
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;

View File

@ -1,12 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
class EqualNamespacesPerFileWithClassAsLast {}

View File

@ -1,12 +0,0 @@
<?php
namespace {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
class GlobalNamespacesPerFileWithClassAsFirst {}
}
namespace {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
}

View File

@ -1,12 +0,0 @@
<?php
namespace {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
}
namespace {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
class GlobalNamespacesPerFileWithClassAsLast {}
}

View File

@ -1,7 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
class IgnoreAnnotationClass
{
}

View File

@ -1,10 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
interface IntefaceWithConstants
{
const SOME_VALUE = 'IntefaceWithConstants.SOME_VALUE';
const SOME_KEY = 'IntefaceWithConstants.SOME_KEY';
}

View File

@ -1,14 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
/**
* @NoAnnotation
* @IgnoreAnnotation("NoAnnotation")
* @Route("foo")
*/
class InvalidAnnotationUsageButIgnoredClass
{
}

View File

@ -1,10 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
/**
* @NoAnnotation
*/
class InvalidAnnotationUsageClass
{
}

View File

@ -1,9 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
class AnotherClass { }
class MultipleClassesInFile { }

View File

@ -1,10 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use
Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route,
Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure
;
class MultipleImportsInUseStatement {}

View File

@ -1,20 +0,0 @@
<?php
// namespace Doctrine\Tests\Common\Annotations\Fixtures;
namespace Doctrine\Tests\Common\Annotations\Fixtures\Foo {
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
// class NamespaceAndClassCommentedOut {}
}
namespace Doctrine\Tests\Common\Annotations\Fixtures {
// class NamespaceAndClassCommentedOut {}
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
// namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
class NamespaceAndClassCommentedOut {}
}

View File

@ -1,12 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
$var = 1;
function () use ($var) {};
class NamespaceWithClosureDeclaration {}

View File

@ -1,5 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
class NoAnnotation {}

View File

@ -1,10 +0,0 @@
<?php
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
/**
* @Route("foo")
* @Template
*/
class AnnotationsTestsFixturesNonNamespacedClass { }

View File

@ -1,13 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
interface TestInterface
{
/**
* @Secure
*/
function foo();
}

View File

@ -1,19 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures;
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload;
trait TraitWithAnnotatedMethod {
/**
* @Autoload
*/
public $traitProperty;
/**
* @Autoload
*/
public function traitMethod()
{
}
}

View File

@ -1,194 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\FileCacheReader;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\DocLexer;
use Doctrine\Common\Annotations\DocParser;
use Doctrine\Common\Annotations\PhpParser;
use Doctrine\Common\Annotations\AnnotationReader;
require_once __DIR__ . '/Fixtures/Annotation/Route.php';
require_once __DIR__ . '/Fixtures/Annotation/Template.php';
require_once __DIR__ . '/Fixtures/Annotation/Secure.php';
require_once __DIR__ . '/Fixtures/SingleClassLOC1000.php';
class PerformanceTest extends \PHPUnit_Framework_TestCase
{
/**
* @group performance
*/
public function testCachedReadPerformanceWithInMemory()
{
$reader = new CachedReader(new AnnotationReader(), new ArrayCache());
$method = $this->getMethod();
$time = microtime(true);
for ($i=0,$c=500; $i<$c; $i++) {
$reader->getMethodAnnotations($method);
}
$time = microtime(true) - $time;
$this->printResults('cached reader (in-memory)', $time, $c);
}
/**
* @group performance
*/
public function testCachedReadPerformanceWithFileCache()
{
$method = $this->getMethod();
// prime cache
$reader = new FileCacheReader(new AnnotationReader(), sys_get_temp_dir());
$reader->getMethodAnnotations($method);
$time = microtime(true);
for ($i=0,$c=500; $i<$c; $i++) {
$reader = new FileCacheReader(new AnnotationReader(), sys_get_temp_dir());
$reader->getMethodAnnotations($method);
clearstatcache();
}
$time = microtime(true) - $time;
$this->printResults('cached reader (file)', $time, $c);
}
/**
* @group performance
*/
public function testReadPerformance()
{
$method = $this->getMethod();
$time = microtime(true);
for ($i=0,$c=150; $i<$c; $i++) {
$reader = new AnnotationReader();
$reader->getMethodAnnotations($method);
}
$time = microtime(true) - $time;
$this->printResults('reader', $time, $c);
}
/**
* @group performance
*/
public function testDocParsePerformance()
{
$imports = array(
'ignorephpdoc' => 'Annotations\Annotation\IgnorePhpDoc',
'ignoreannotation' => 'Annotations\Annotation\IgnoreAnnotation',
'route' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route',
'template' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template',
'__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations\Fixtures',
);
$ignored = array(
'access', 'author', 'copyright', 'deprecated', 'example', 'ignore',
'internal', 'link', 'see', 'since', 'tutorial', 'version', 'package',
'subpackage', 'name', 'global', 'param', 'return', 'staticvar',
'static', 'var', 'throws', 'inheritdoc',
);
$method = $this->getMethod();
$methodComment = $method->getDocComment();
$classComment = $method->getDeclaringClass()->getDocComment();
$time = microtime(true);
for ($i=0,$c=200; $i<$c; $i++) {
$parser = new DocParser();
$parser->setImports($imports);
$parser->setIgnoredAnnotationNames($ignored);
$parser->setIgnoreNotImportedAnnotations(true);
$parser->parse($methodComment);
$parser->parse($classComment);
}
$time = microtime(true) - $time;
$this->printResults('doc-parser', $time, $c);
}
/**
* @group performance
*/
public function testDocLexerPerformance()
{
$method = $this->getMethod();
$methodComment = $method->getDocComment();
$classComment = $method->getDeclaringClass()->getDocComment();
$time = microtime(true);
for ($i=0,$c=500; $i<$c; $i++) {
$lexer = new DocLexer();
$lexer->setInput($methodComment);
$lexer->setInput($classComment);
}
$time = microtime(true) - $time;
$this->printResults('doc-lexer', $time, $c);
}
/**
* @group performance
*/
public function testPhpParserPerformanceWithShortCut()
{
$class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\NamespacedSingleClassLOC1000');
$time = microtime(true);
for ($i=0,$c=500; $i<$c; $i++) {
$parser = new PhpParser();
$parser->parseClass($class);
}
$time = microtime(true) - $time;
$this->printResults('doc-parser-with-short-cut', $time, $c);
}
/**
* @group performance
*/
public function testPhpParserPerformanceWithoutShortCut()
{
$class = new \ReflectionClass('SingleClassLOC1000');
$time = microtime(true);
for ($i=0,$c=500; $i<$c; $i++) {
$parser = new PhpParser();
$parser->parseClass($class);
}
$time = microtime(true) - $time;
$this->printResults('doc-parser-without-short-cut', $time, $c);
}
private function getMethod()
{
return new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\Controller', 'helloAction');
}
private function printResults($test, $time, $iterations)
{
if (0 == $iterations) {
throw new \InvalidArgumentException('$iterations cannot be zero.');
}
$title = $test." results:\n";
$iterationsText = sprintf("Iterations: %d\n", $iterations);
$totalTime = sprintf("Total Time: %.3f s\n", $time);
$iterationTime = sprintf("Time per iteration: %.3f ms\n", $time/$iterations * 1000);
$max = max(strlen($title), strlen($iterationTime)) - 1;
echo "\n".str_repeat('-', $max)."\n";
echo $title;
echo str_repeat('=', $max)."\n";
echo $iterationsText;
echo $totalTime;
echo $iterationTime;
echo str_repeat('-', $max)."\n";
}
}

View File

@ -1,207 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use ReflectionClass;
use Doctrine\Common\Annotations\PhpParser;
require_once __DIR__.'/Fixtures/NonNamespacedClass.php';
require_once __DIR__.'/Fixtures/GlobalNamespacesPerFileWithClassAsFirst.php';
require_once __DIR__.'/Fixtures/GlobalNamespacesPerFileWithClassAsLast.php';
class PhpParserTest extends \PHPUnit_Framework_TestCase
{
public function testParseClassWithMultipleClassesInFile()
{
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\MultipleClassesInFile');
$parser = new PhpParser();
$this->assertEquals(array(
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
), $parser->parseClass($class));
}
public function testParseClassWithMultipleImportsInUseStatement()
{
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\MultipleImportsInUseStatement');
$parser = new PhpParser();
$this->assertEquals(array(
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
), $parser->parseClass($class));
}
public function testParseClassWhenNotUserDefined()
{
$parser = new PhpParser();
$this->assertEquals(array(), $parser->parseClass(new \ReflectionClass('\stdClass')));
}
public function testClassFileDoesNotExist()
{
$class = $this->getMockBuilder('\ReflectionClass')
->disableOriginalConstructor()
->getMock();
$class->expects($this->once())
->method('getFilename')
->will($this->returnValue('/valid/class/Fake.php(35) : eval()d code'));
$parser = new PhpParser();
$this->assertEquals(array(), $parser->parseClass($class));
}
public function testParseClassWhenClassIsNotNamespaced()
{
$parser = new PhpParser();
$class = new ReflectionClass('\AnnotationsTestsFixturesNonNamespacedClass');
$this->assertEquals(array(
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
}
public function testParseClassWhenClassIsInterface()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\TestInterface');
$this->assertEquals(array(
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
), $parser->parseClass($class));
}
public function testClassWithFullyQualifiedUseStatements()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\ClassWithFullyQualifiedUseStatements');
$this->assertEquals(array(
'secure' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
}
public function testNamespaceAndClassCommentedOut()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceAndClassCommentedOut');
$this->assertEquals(array(
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
}
public function testEqualNamespacesPerFileWithClassAsFirst()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\EqualNamespacesPerFileWithClassAsFirst');
$this->assertEquals(array(
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
), $parser->parseClass($class));
}
public function testEqualNamespacesPerFileWithClassAsLast()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\EqualNamespacesPerFileWithClassAsLast');
$this->assertEquals(array(
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
}
public function testDifferentNamespacesPerFileWithClassAsFirst()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\DifferentNamespacesPerFileWithClassAsFirst');
$this->assertEquals(array(
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
), $parser->parseClass($class));
}
public function testDifferentNamespacesPerFileWithClassAsLast()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\DifferentNamespacesPerFileWithClassAsLast');
$this->assertEquals(array(
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
}
public function testGlobalNamespacesPerFileWithClassAsFirst()
{
$parser = new PhpParser();
$class = new \ReflectionClass('\GlobalNamespacesPerFileWithClassAsFirst');
$this->assertEquals(array(
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
), $parser->parseClass($class));
}
public function testGlobalNamespacesPerFileWithClassAsLast()
{
$parser = new PhpParser();
$class = new ReflectionClass('\GlobalNamespacesPerFileWithClassAsLast');
$this->assertEquals(array(
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
}
public function testNamespaceWithClosureDeclaration()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceWithClosureDeclaration');
$this->assertEquals(array(
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
}
public function testIfPointerResetsOnMultipleParsingTries()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceWithClosureDeclaration');
$this->assertEquals(array(
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
$this->assertEquals(array(
'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure',
'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route',
'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template',
), $parser->parseClass($class));
}
/**
* @group DCOM-97
* @group regression
*/
public function testClassWithClosure()
{
$parser = new PhpParser();
$class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\ClassWithClosure');
$this->assertEquals(array(
'annotationtargetall' => __NAMESPACE__ . '\Fixtures\AnnotationTargetAll',
'annotationtargetannotation' => __NAMESPACE__ . '\Fixtures\AnnotationTargetAnnotation',
), $parser->parseClass($class));
}
}

View File

@ -1,102 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\SimpleAnnotationReader;
class SimpleAnnotationReaderTest extends AbstractReaderTest
{
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*/
public function testImportDetectsNotImportedAnnotation()
{
parent::testImportDetectsNotImportedAnnotation();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*/
public function testImportDetectsNonExistentAnnotation()
{
parent::testImportDetectsNonExistentAnnotation();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*/
public function testClassWithInvalidAnnotationTargetAtClassDocBlock()
{
parent::testClassWithInvalidAnnotationTargetAtClassDocBlock();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*/
public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock()
{
parent::testClassWithInvalidAnnotationTargetAtPropertyDocBlock();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*/
public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock()
{
parent::testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock();
}
/**
* Contrary to the behavior of the default annotation reader, we do just ignore
* these in the simple annotation reader (so, no expected exception here).
*/
public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
{
parent::testClassWithInvalidAnnotationTargetAtMethodDocBlock();
}
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
*/
public function testInvalidAnnotationUsageButIgnoredClass()
{
parent::testInvalidAnnotationUsageButIgnoredClass();
}
public function testIncludeIgnoreAnnotation()
{
$this->markTestSkipped('The simplified annotation reader would always autoload annotations');
}
/**
* @group DDC-1660
* @group regression
*
* Contrary to the behavior of the default annotation reader, @version is not ignored
*/
public function testInvalidAnnotationButIgnored()
{
$reader = $this->getReader();
$class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660');
$this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version'));
$this->assertCount(1, $reader->getClassAnnotations($class));
$this->assertCount(1, $reader->getMethodAnnotations($class->getMethod('bar')));
$this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo')));
}
protected function getReader()
{
$reader = new SimpleAnnotationReader();
$reader->addNamespace(__NAMESPACE__);
$reader->addNamespace(__NAMESPACE__ . '\Fixtures');
$reader->addNamespace(__NAMESPACE__ . '\Fixtures\Annotation');
return $reader;
}
}

View File

@ -1,66 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Ticket;
use Doctrine\Tests\Common\Annotations\Fixtures\Controller;
use Doctrine\Common\Annotations\AnnotationReader;
/**
* @group
*/
class DCOM55Test extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Semantical Error] The class "Doctrine\Tests\Common\Annotations\Fixtures\Controller" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\Tests\Common\Annotations\Fixtures\Controller". If it is indeed no annotation, then you need to add @IgnoreAnnotation("Controller") to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Ticket\Dummy.
*/
public function testIssue()
{
$class = new \ReflectionClass(__NAMESPACE__ . '\\Dummy');
$reader = new AnnotationReader();
$reader->getClassAnnotations($class);
}
public function testAnnotation()
{
$class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Consumer');
$reader = new AnnotationReader();
$annots = $reader->getClassAnnotations($class);
$this->assertEquals(1, count($annots));
$this->assertInstanceOf(__NAMESPACE__.'\\DCOM55Annotation', $annots[0]);
}
public function testParseAnnotationDocblocks()
{
$class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Annotation');
$reader = new AnnotationReader();
$annots = $reader->getClassAnnotations($class);
$this->assertEquals(0, count($annots));
}
}
/**
* @Controller
*/
class Dummy
{
}
/**
* @Annotation
*/
class DCOM55Annotation
{
}
/**
* @DCOM55Annotation
*/
class DCOM55Consumer
{
}

View File

@ -1,8 +0,0 @@
<?php
// Some class named Entity in the global namespace
/**
* @Annotation
*/
class Entity
{
}

View File

@ -1,116 +0,0 @@
<?php
namespace Doctrine\Tests\Common\Annotations\Ticket;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\DocParser;
use Doctrine\Common\Annotations\SimpleAnnotationReader;
//Some class named Entity in the global namespace
include __DIR__ .'/DCOM58Entity.php';
/**
* @group DCOM58
*/
class DCOM58Test extends \PHPUnit_Framework_TestCase
{
public function testIssue()
{
$reader = new AnnotationReader();
$result = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass"));
foreach ($result as $annot) {
$classAnnotations[get_class($annot)] = $annot;
}
$this->assertTrue(!isset($classAnnotations['']), 'Class "xxx" is not a valid entity or mapped super class.');
}
public function testIssueGlobalNamespace()
{
$docblock = "@Entity";
$parser = new DocParser();
$parser->setImports(array(
"__NAMESPACE__" =>"Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping"
));
$annots = $parser->parse($docblock);
$this->assertEquals(1, count($annots));
$this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]);
}
public function testIssueNamespaces()
{
$docblock = "@Entity";
$parser = new DocParser();
$parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM");
$annots = $parser->parse($docblock);
$this->assertEquals(1, count($annots));
$this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Entity", $annots[0]);
}
public function testIssueMultipleNamespaces()
{
$docblock = "@Entity";
$parser = new DocParser();
$parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping");
$parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM");
$annots = $parser->parse($docblock);
$this->assertEquals(1, count($annots));
$this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]);
}
public function testIssueWithNamespacesOrImports()
{
$docblock = "@Entity";
$parser = new DocParser();
$annots = $parser->parse($docblock);
$this->assertEquals(1, count($annots));
$this->assertInstanceOf("Entity", $annots[0]);
$this->assertEquals(1, count($annots));
}
public function testIssueSimpleAnnotationReader()
{
$reader = new SimpleAnnotationReader();
$reader->addNamespace('Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping');
$annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass"));
$this->assertEquals(1, count($annots));
$this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]);
}
}
/**
* @Entity
*/
class MappedClass
{
}
namespace Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping;
/**
* @Annotation
*/
class Entity
{
}
namespace Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM;
/**
* @Annotation
*/
class Entity
{
}

View File

@ -1,8 +0,0 @@
<?php
use Doctrine\Common\Annotations\Annotation;
/** @Annotation */
class TopLevelAnnotation extends Annotation
{
}

View File

@ -1,10 +0,0 @@
<?php
namespace Doctrine\Tests;
/**
* Base testcase class for all Doctrine testcases.
*/
abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
{
}

View File

@ -1,24 +0,0 @@
<?php
/*
* This file bootstraps the test environment.
*/
error_reporting(E_ALL | E_STRICT);
// register silently failing autoloader
spl_autoload_register(function($class)
{
if (0 === strpos($class, 'Doctrine\Tests\\')) {
$path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php';
if (is_file($path) && is_readable($path)) {
require_once $path;
return true;
}
}
});
require_once __DIR__ . "/../../../vendor/autoload.php";
\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace(
'Doctrine\Tests\Common\Annotations\Fixtures', __DIR__ . '/../../'
);

View File

@ -13,13 +13,15 @@ services:
- memcached
- redis-server
before_script:
before_install:
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ]; then pecl install riak-beta; fi"
- sh -c "if [[ $TRAVIS_PHP_VERSION != 'hhvm' && `php-config --vernum` -ge 50500 ]] ; then pecl config-set preferred_state beta; printf "yes\n" | pecl install apcu ; else echo 'extension="apc.so"' >> ./tests/travis/php.ini ;fi"
- composer self-update
- composer --prefer-source --dev install
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ]; then phpenv config-add ./tests/travis/php.ini; fi"
install:
- composer --prefer-source --dev install
script:
- ./vendor/bin/phpunit -c ./tests/travis/phpunit.travis.xml -v

16
core/vendor/doctrine/cache/UPGRADE.md vendored Normal file
View File

@ -0,0 +1,16 @@
# Upgrade to 1.4
## Minor BC Break: `Doctrine\Common\Cache\FileCache#$extension` is now `private`.
If you need to override the value of `Doctrine\Common\Cache\FileCache#$extension`, then use the
second parameter of `Doctrine\Common\Cache\FileCache#__construct()` instead of overriding
the property in your own implementation.
## Minor BC Break: file based caches paths changed
`Doctrine\Common\Cache\FileCache`, `Doctrine\Common\Cache\PhpFileCache` and
`Doctrine\Common\Cache\FilesystemCache` are using a different cache paths structure.
If you rely on warmed up caches for deployments, consider that caches generated
with `doctrine/cache` `<1.4` are not compatible with the new directory structure,
and will be ignored.

View File

@ -17,7 +17,8 @@
},
"require-dev": {
"phpunit/phpunit": ">=3.7",
"satooshi/php-coveralls": "~0.6"
"satooshi/php-coveralls": "~0.6",
"predis/predis": "~1.0"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
@ -27,7 +28,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
"dev-master": "1.5.x-dev"
}
}
}

View File

@ -72,12 +72,20 @@ class ApcCache extends CacheProvider
return apc_clear_cache() && apc_clear_cache('user');
}
/**
* {@inheritdoc}
*/
protected function doFetchMultiple(array $keys)
{
return apc_fetch($keys);
}
/**
* {@inheritdoc}
*/
protected function doGetStats()
{
$info = apc_cache_info();
$info = apc_cache_info('', true);
$sma = apc_sma_info();
// @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42

View File

@ -50,6 +50,7 @@ class ArrayCache extends CacheProvider
*/
protected function doContains($id)
{
// isset() is required for performance optimizations, to avoid unnecessary function calls to array_key_exists.
return isset($this->data[$id]) || array_key_exists($id, $this->data);
}

View File

@ -29,6 +29,7 @@ namespace Doctrine\Common\Cache;
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
* @author Kévin Dunglas <dunglas@gmail.com>
*/
interface Cache
{
@ -51,7 +52,7 @@ interface Cache
*
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
*/
function fetch($id);
public function fetch($id);
/**
* Tests if an entry exists in the cache.
@ -60,7 +61,7 @@ interface Cache
*
* @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise.
*/
function contains($id);
public function contains($id);
/**
* Puts data into the cache.
@ -72,7 +73,7 @@ interface Cache
*
* @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.
*/
function save($id, $data, $lifeTime = 0);
public function save($id, $data, $lifeTime = 0);
/**
* Deletes a cache entry.
@ -81,7 +82,7 @@ interface Cache
*
* @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
*/
function delete($id);
public function delete($id);
/**
* Retrieves cached information from the data store.
@ -107,5 +108,5 @@ interface Cache
*
* @return array|null An associative array with server's statistics if available, NULL otherwise.
*/
function getStats();
public function getStats();
}

View File

@ -29,7 +29,7 @@ namespace Doctrine\Common\Cache;
* @author Roman Borschel <roman@code-factory.org>
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
*/
abstract class CacheProvider implements Cache
abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiGetCache
{
const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
@ -78,6 +78,27 @@ abstract class CacheProvider implements Cache
return $this->doFetch($this->getNamespacedId($id));
}
/**
* {@inheritdoc}
*/
public function fetchMultiple(array $keys)
{
// note: the array_combine() is in place to keep an association between our $keys and the $namespacedKeys
$namespacedKeys = array_combine($keys, array_map(array($this, 'getNamespacedId'), $keys));
$items = $this->doFetchMultiple($namespacedKeys);
$foundItems = array();
// no internal array function supports this sort of mapping: needs to be iterative
// this filters and combines keys in one pass
foreach ($namespacedKeys as $requestedKey => $namespacedKey) {
if (isset($items[$namespacedKey])) {
$foundItems[$requestedKey] = $items[$namespacedKey];
}
}
return $foundItems;
}
/**
* {@inheritdoc}
*/
@ -111,9 +132,7 @@ abstract class CacheProvider implements Cache
}
/**
* Flushes all cache entries.
*
* @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise.
* {@inheritDoc}
*/
public function flushAll()
{
@ -121,9 +140,7 @@ abstract class CacheProvider implements Cache
}
/**
* Deletes all cache entries.
*
* @return boolean TRUE if the cache entries were successfully deleted, FALSE otherwise.
* {@inheritDoc}
*/
public function deleteAll()
{
@ -184,12 +201,31 @@ abstract class CacheProvider implements Cache
return $this->namespaceVersion;
}
/**
* Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.
*
* @param array $keys Array of keys to retrieve from cache
* @return array Array of values retrieved for the given keys.
*/
protected function doFetchMultiple(array $keys)
{
$returnValues = array();
foreach ($keys as $index => $key) {
if (false !== ($item = $this->doFetch($key))) {
$returnValues[$key] = $item;
}
}
return $returnValues;
}
/**
* Fetches an entry from the cache.
*
* @param string $id The id of the cache entry to fetch.
*
* @return string|boolean The cached data or FALSE, if no cache entry exists for the given id.
* @return mixed|boolean The cached data or FALSE, if no cache entry exists for the given id.
*/
abstract protected function doFetch($id);
@ -226,7 +262,7 @@ abstract class CacheProvider implements Cache
/**
* Flushes all cache entries.
*
* @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
* @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise.
*/
abstract protected function doFlush();

View File

@ -0,0 +1,147 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common\Cache;
/**
* Cache provider that allows to easily chain multiple cache providers
*
* @author Michaël Gallego <mic.gallego@gmail.com>
*/
class ChainCache extends CacheProvider
{
/**
* @var CacheProvider[]
*/
private $cacheProviders = array();
/**
* Constructor
*
* @param CacheProvider[] $cacheProviders
*/
public function __construct($cacheProviders = array())
{
$this->cacheProviders = $cacheProviders;
}
/**
* {@inheritDoc}
*/
public function setNamespace($namespace)
{
parent::setNamespace($namespace);
foreach ($this->cacheProviders as $cacheProvider) {
$cacheProvider->setNamespace($namespace);
}
}
/**
* {@inheritDoc}
*/
protected function doFetch($id)
{
foreach ($this->cacheProviders as $key => $cacheProvider) {
if ($cacheProvider->doContains($id)) {
$value = $cacheProvider->doFetch($id);
// We populate all the previous cache layers (that are assumed to be faster)
for ($subKey = $key - 1 ; $subKey >= 0 ; $subKey--) {
$this->cacheProviders[$subKey]->doSave($id, $value);
}
return $value;
}
}
return false;
}
/**
* {@inheritDoc}
*/
protected function doContains($id)
{
foreach ($this->cacheProviders as $cacheProvider) {
if ($cacheProvider->doContains($id)) {
return true;
}
}
return false;
}
/**
* {@inheritDoc}
*/
protected function doSave($id, $data, $lifeTime = 0)
{
$stored = true;
foreach ($this->cacheProviders as $cacheProvider) {
$stored = $cacheProvider->doSave($id, $data, $lifeTime) && $stored;
}
return $stored;
}
/**
* {@inheritDoc}
*/
protected function doDelete($id)
{
$deleted = true;
foreach ($this->cacheProviders as $cacheProvider) {
$deleted = $cacheProvider->doDelete($id) && $deleted;
}
return $deleted;
}
/**
* {@inheritDoc}
*/
protected function doFlush()
{
$flushed = true;
foreach ($this->cacheProviders as $cacheProvider) {
$flushed = $cacheProvider->doFlush() && $flushed;
}
return $flushed;
}
/**
* {@inheritDoc}
*/
protected function doGetStats()
{
// We return all the stats from all adapters
$stats = array();
foreach ($this->cacheProviders as $cacheProvider) {
$stats[] = $cacheProvider->doGetStats();
}
return $stats;
}
}

View File

@ -0,0 +1,40 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common\Cache;
/**
* Interface for cache that can be flushed.
*
* Intended to be used for partial clearing of a cache namespace. For a more
* global "flushing", see {@see FlushableCache}.
*
* @link www.doctrine-project.org
* @since 1.4
* @author Adirelle <adirelle@gmail.com>
*/
interface ClearableCache
{
/**
* Deletes all cache entries in the current cache namespace.
*
* @return boolean TRUE if the cache entries were successfully deleted, FALSE otherwise.
*/
public function deleteAll();
}

View File

@ -37,21 +37,48 @@ abstract class FileCache extends CacheProvider
/**
* The cache file extension.
*
* @var string|null
* @var string
*/
protected $extension;
private $extension;
/**
* @var string[] regular expressions for replacing disallowed characters in file name
*/
private $disallowedCharacterPatterns = array(
'/\-/', // replaced to disambiguate original `-` and `-` derived from replacements
'/[^a-zA-Z0-9\-_\[\]]/' // also excludes non-ascii chars (not supported, depending on FS)
);
/**
* @var string[] replacements for disallowed file characters
*/
private $replacementCharacters = array('__', '-');
/**
* @var int
*/
private $umask;
/**
* Constructor.
*
* @param string $directory The cache directory.
* @param string|null $extension The cache file extension.
* @param string $directory The cache directory.
* @param string $extension The cache file extension.
*
* @throws \InvalidArgumentException
*/
public function __construct($directory, $extension = null)
public function __construct($directory, $extension = '', $umask = 0002)
{
if ( ! is_dir($directory) && ! @mkdir($directory, 0777, true)) {
// YES, this needs to be *before* createPathIfNeeded()
if ( ! is_int($umask)) {
throw new \InvalidArgumentException(sprintf(
'The umask parameter is required to be integer, was: %s',
gettype($umask)
));
}
$this->umask = $umask;
if ( ! $this->createPathIfNeeded($directory)) {
throw new \InvalidArgumentException(sprintf(
'The directory "%s" does not exist and could not be created.',
$directory
@ -65,8 +92,9 @@ abstract class FileCache extends CacheProvider
));
}
// YES, this needs to be *after* createPathIfNeeded()
$this->directory = realpath($directory);
$this->extension = $extension ?: $this->extension;
$this->extension = (string) $extension;
}
/**
@ -96,12 +124,12 @@ abstract class FileCache extends CacheProvider
*/
protected function getFilename($id)
{
$hash = hash('sha256', $id);
$path = implode(str_split($hash, 16), DIRECTORY_SEPARATOR);
$path = $this->directory . DIRECTORY_SEPARATOR . $path;
$id = preg_replace('@[\\\/:"*?<>|]+@', '', $id);
return $path . DIRECTORY_SEPARATOR . $id . $this->extension;
return $this->directory
. DIRECTORY_SEPARATOR
. implode(str_split(hash('sha256', $id), 2), DIRECTORY_SEPARATOR)
. DIRECTORY_SEPARATOR
. preg_replace($this->disallowedCharacterPatterns, $this->replacementCharacters, $id)
. $this->extension;
}
/**
@ -145,14 +173,65 @@ abstract class FileCache extends CacheProvider
);
}
/**
* Create path if needed.
*
* @param string $path
* @return bool TRUE on success or if path already exists, FALSE if path cannot be created.
*/
private function createPathIfNeeded($path)
{
if ( ! is_dir($path)) {
if (false === @mkdir($path, 0777 & (~$this->umask), true) && !is_dir($path)) {
return false;
}
}
return true;
}
/**
* Writes a string content to file in an atomic way.
*
* @param string $filename Path to the file where to write the data.
* @param string $content The content to write
*
* @return bool TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error.
*/
protected function writeFile($filename, $content)
{
$filepath = pathinfo($filename, PATHINFO_DIRNAME);
if ( ! $this->createPathIfNeeded($filepath)) {
return false;
}
if ( ! is_writable($filepath)) {
return false;
}
$tmpFile = tempnam($filepath, 'swap');
@chmod($tmpFile, 0666 & (~$this->umask));
if (file_put_contents($tmpFile, $content) !== false) {
if (@rename($tmpFile, $filename)) {
return true;
}
@unlink($tmpFile);
}
return false;
}
/**
* @return \Iterator
*/
private function getIterator()
{
$pattern = '/^.+\\' . $this->extension . '$/i';
$iterator = new \RecursiveDirectoryIterator($this->directory);
$iterator = new \RecursiveIteratorIterator($iterator);
return new \RegexIterator($iterator, $pattern);
return new \RegexIterator(
new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory)),
'/^.+' . preg_quote($this->extension, '/') . '$/i'
);
}
}

View File

@ -32,7 +32,10 @@ class FilesystemCache extends FileCache
/**
* {@inheritdoc}
*/
protected $extension = self::EXTENSION;
public function __construct($directory, $extension = self::EXTENSION, $umask = 0002)
{
parent::__construct($directory, $extension, $umask);
}
/**
* {@inheritdoc}
@ -100,26 +103,9 @@ class FilesystemCache extends FileCache
$lifeTime = time() + $lifeTime;
}
$data = serialize($data);
$filename = $this->getFilename($id);
$filepath = pathinfo($filename, PATHINFO_DIRNAME);
$data = serialize($data);
$filename = $this->getFilename($id);
if ( ! is_dir($filepath)) {
if (false === @mkdir($filepath, 0777, true) && !is_dir($filepath)) {
return false;
}
} elseif ( ! is_writable($filepath)) {
return false;
}
$tmpFile = tempnam($filepath, basename($filename));
if ((file_put_contents($tmpFile, $lifeTime . PHP_EOL . $data) !== false) && @rename($tmpFile, $filename)) {
@chmod($filename, 0666 & ~umask());
return true;
}
return false;
return $this->writeFile($filename, $lifeTime . PHP_EOL . $data);
}
}

View File

@ -0,0 +1,37 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common\Cache;
/**
* Interface for cache that can be flushed.
*
* @link www.doctrine-project.org
* @since 1.4
* @author Adirelle <adirelle@gmail.com>
*/
interface FlushableCache
{
/**
* Flushes all cache entries, globally.
*
* @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise.
*/
public function flushAll();
}

View File

@ -74,7 +74,11 @@ class MemcacheCache extends CacheProvider
*/
protected function doContains($id)
{
return (bool) $this->memcache->get($id);
$flags = null;
$this->memcache->get($id, $flags);
//if memcache has changed the value of "flags", it means the value exists
return ($flags !== null);
}
/**

View File

@ -69,6 +69,14 @@ class MemcachedCache extends CacheProvider
return $this->memcached->get($id);
}
/**
* {@inheritdoc}
*/
protected function doFetchMultiple(array $keys)
{
return $this->memcached->getMulti($keys);
}
/**
* {@inheritdoc}
*/

Some files were not shown because too many files have changed in this diff Show More