Skip to content
Snippets Groups Projects
Commit ca850b84 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2105825 by cosmicdreams, larowlan, hussainweb, Nitesh Sethia, dawehner,...

Issue #2105825 by cosmicdreams, larowlan, hussainweb, Nitesh Sethia, dawehner, naveenvalecha, iMiksu: Update Doctrine/common Component to 2.5.1 (security) (includes cache/annotations too)
parent 9f8d68af
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing
with 1752 additions and 4163 deletions
......@@ -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.*",
......
......@@ -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": ""
},
......
......@@ -14,7 +14,6 @@
'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'),
......
......@@ -37,6 +37,7 @@
'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'),
);
This diff is collapsed.
......@@ -162,7 +162,7 @@ public function __construct()
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();
}
......@@ -170,6 +170,7 @@ public function __construct()
if (extension_loaded('Zend OPcache') && ini_get('opcache.load_comments') == 0) {
throw AnnotationException::optimizerPlusLoadComments();
}
}
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php');
......
......@@ -84,7 +84,7 @@ protected function getCatchablePatterns()
return array(
'[a-z_\\\][a-z0-9_\:\\\]*[a-z_][a-z0-9_]*',
'(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?',
'"(?:[^"]|"")*"',
'"(?:""|[^"])*+"',
);
}
......
......@@ -24,6 +24,10 @@
*
* @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 @@ private function saveCacheFile($path, $data)
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));
}
}
/**
......
<?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>
<?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]);
}
}
\ No newline at end of file
<?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);
}
}
\ No newline at end of file
<?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());
}
}
\ No newline at end of file
<?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()
{
}
}
<?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));
}
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/** @Annotation */
class AnnotWithDefaultValue
{
/** @var string */
public $foo = 'bar';
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/**
* @Annotation
*/
class Autoload
{
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
/** @Annotation */
class Route
{
/** @var string @Required */
public $pattern;
public $name;
}
\ No newline at end of file
<?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'];
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment