diff --git a/Bpi/Sdk/Authorization.php b/Bpi/Sdk/Authorization.php index 7a81912..13d5bc3 100644 --- a/Bpi/Sdk/Authorization.php +++ b/Bpi/Sdk/Authorization.php @@ -1,15 +1,33 @@ token = crypt($this->agency_id . $this->public_key . $this->secret_key); + $this->token = crypt($this->agency_id.$this->public_key.$this->secret_key); } /** * Represent as HTTP Authorization string. - * Will return value part, e.g. Authorization: + * Will return value part, e.g. Authorization: . * * @return string */ diff --git a/Bpi/Sdk/Bpi.php b/Bpi/Sdk/Bpi.php index 802667b..648ac99 100644 --- a/Bpi/Sdk/Bpi.php +++ b/Bpi/Sdk/Bpi.php @@ -1,38 +1,38 @@ endpoint; $nodes->firstItem('name', 'node') ->template('push') - ->eachField(function ($field) use ($data) { - if (!isset($data[(string)$field])) - throw new \InvalidArgumentException(sprintf('Field [%s] is required', (string) $field)); + ->eachField( + function ($field) use ($data) { + if (!isset($data[(string) $field])) { + throw new \InvalidArgumentException(sprintf('Field [%s] is required', (string) $field)); + } - $field->setValue($data[(string) $field]); - })->post($node); + $field->setValue($data[(string) $field]); + } + )->post($node); $this->current_document = $node; @@ -103,10 +109,11 @@ public function push(array $data) } /** - * Mark node as syndicated + * Mark node as syndicated. * * @param string $id BPI node ID - * @return boolean operation status + * + * @return bool operation status */ public function syndicateNode($id) { @@ -123,10 +130,11 @@ public function syndicateNode($id) } /** - * Mark node as deleted + * Mark node as deleted. * * @param string $id BPI node ID - * @return boolean operation status + * + * @return bool operation status */ public function deleteNode($id) { @@ -144,10 +152,12 @@ public function deleteNode($id) /** * Get statistics - * Parameterformat: Y-m-d + * Parameterformat: Y-m-d. * * @param string $dateFrom * @param string $dateTo + * + * @return \Bpi\Sdk\Item\BaseItem */ public function getStatistics($dateFrom, $dateTo) { @@ -155,7 +165,7 @@ public function getStatistics($dateFrom, $dateTo) $endpoint = clone $this->endpoint; $endpoint->firstItem('name', 'node') ->query('statistics') - ->send($result, array('dateFrom'=>$dateFrom, 'dateTo'=>$dateTo)); + ->send($result, array('dateFrom' => $dateFrom, 'dateTo' => $dateTo)); $this->current_document = $result; @@ -163,9 +173,10 @@ public function getStatistics($dateFrom, $dateTo) } /** - * Get single Node by ID + * Get single Node by ID. * * @param string $id BPI node ID + * * @return \Bpi\Sdk\Item\Node */ public function getNode($id) @@ -183,7 +194,7 @@ public function getNode($id) } /** - * Get list of dictionaries + * Get list of dictionaries. * * @return array */ @@ -199,12 +210,13 @@ public function getDictionaries() $this->current_document = $result; $dictionary = array(); - foreach ($result as $item) - { + foreach ($result as $item) { $properties = array(); - $item->walkProperties(function($property) use (&$properties){ - $properties[$property['name']] = $property['@value']; - }); + $item->walkProperties( + function ($property) use (&$properties) { + $properties[$property['name']] = $property['@value']; + } + ); $dictionary[$properties['group']][] = $properties['name']; } @@ -213,10 +225,11 @@ public function getDictionaries() } /** + * Get current document. * * @return \Bpi\Sdk\Document */ - public function _getCurrentDocument() + protected function _getCurrentDocument() { return $this->current_document; } diff --git a/Bpi/Sdk/Document.php b/Bpi/Sdk/Document.php index 17bd067..306bf9d 100644 --- a/Bpi/Sdk/Document.php +++ b/Bpi/Sdk/Document.php @@ -1,32 +1,32 @@ request('GET', $endpoint); + return $this; } /** - * Gateway to make direct requests to API + * Gateway to make direct requests to API. * * @param string $method * @param string $uri - * @param array $params + * @param array $params + * + * @throws Exception\HTTP\ClientError + * @throws Exception\HTTP\ServerError + * @throws Exception\HTTP\Error * * @return \Bpi\Sdk\Document same instance */ @@ -65,13 +73,14 @@ public function request($method, $uri, array $params = array()) $this->crawler = $this->crawler->filter('bpi > item'); $this->crawler->rewind(); - if ($this->status()->isError()) - { - if ($this->status()->isClientError()) + if ($this->status()->isError()) { + if ($this->status()->isClientError()) { throw new Exception\HTTP\ClientError($this->http_client->getResponse()->getContent(), $this->status()->getCode()); + } - if ($this->status()->isServerError()) + if ($this->status()->isServerError()) { throw new Exception\HTTP\ServerError($this->http_client->getResponse()->getContent(), $this->status()->getCode()); + } throw new Exception\HTTP\Error($this->http_client->getResponse()->getContent(), $this->status()->getCode()); } @@ -80,7 +89,7 @@ public function request($method, $uri, array $params = array()) } /** - * Get last response status + * Get last response status. * * @return \Bpi\Sdk\ResponseStatus */ @@ -90,9 +99,9 @@ public function status() } /** - * Dump latest raw response data + * Dump latest raw response data. * - * @return string + * @return string response from web service */ public function dumpRawResponse() { @@ -100,9 +109,9 @@ public function dumpRawResponse() } /** - * Dump latest raw request data + * Dump latest raw request data. * - * @return string + * @return string response from wev service */ public function dumpRawRequest() { @@ -113,7 +122,9 @@ public function dumpRawRequest() * Access hypermedia link. * * @throws Exception\UndefinedHypermedia + * * @param string $rel + * * @return \Bpi\Sdk\Link */ public function link($rel) @@ -121,13 +132,10 @@ public function link($rel) try { $crawler = $this->crawler ->filter("hypermedia > link[rel='{$rel}']") - ->first() - ; + ->first(); return new Link($crawler); - } - catch (\InvalidArgumentException $e) - { + } catch (\InvalidArgumentException $e) { throw new Exception\UndefinedHypermedia(sprintf('There is no such link [%s]', $rel)); } } @@ -146,22 +154,20 @@ public function followLink(Link $link) * Access hypermedia query. * * @throws Exception\UndefinedHypermedia + * * @param string $rel + * * @return \Bpi\Sdk\Query */ public function query($rel) { - try - { + try { $query = $this->crawler - ->filter("hypermedia > query[rel='{$rel}']") - ->first() - ; + ->filter("hypermedia > query[rel='{$rel}']") + ->first(); return new Query($query); - } - catch (\InvalidArgumentException $e) - { + } catch (\InvalidArgumentException $e) { throw new Exception\UndefinedHypermedia(sprintf('There is no query [%s]', $rel)); } } @@ -170,7 +176,7 @@ public function query($rel) * Send query. * * @param \Bpi\Sdk\Query $query - * @param array $params + * @param array $params */ public function sendQuery(Query $query, $params) { @@ -181,22 +187,20 @@ public function sendQuery(Query $query, $params) * Access hypermedia template. * * @throws Exception\UndefinedHypermedia + * * @param string $rel + * * @return \Bpi\Sdk\Template */ public function template($rel) { - try - { + try { $query = $this->crawler - ->filter("hypermedia > template[rel='{$rel}']") - ->first() - ; + ->filter("hypermedia > template[rel='{$rel}']") + ->first(); return new Template($query); - } - catch (\InvalidArgumentException $e) - { + } catch (\InvalidArgumentException $e) { throw new Exception\UndefinedHypermedia(sprintf('There is no such template [%s]', $rel)); } } @@ -212,9 +216,10 @@ public function postTemplate(Template $template) } /** - * Checks current item type + * Checks current item type. * * @param string $type + * * @return bool */ public function isTypeOf($type) @@ -223,63 +228,76 @@ public function isTypeOf($type) } /** - * Iterates over all properties of current item + * Iterates over all properties of current item. + * + * @return closure */ public function walkProperties($callback) { $crawler = new Crawler($this->crawler->current()); - return $crawler->filter('item property')->each(function($e) use($callback) { - $sxml = simplexml_import_dom($e); - $callback(current($sxml->attributes()) + array('@value' => (string) $sxml)); - }); + + return $crawler->filter('item property')->each( + function ($e) use ($callback) { + $sxml = simplexml_import_dom($e->getNode(0)); + $callback(current($sxml->attributes()) + array('@value' => (string) $sxml)); + } + ); } /** + * Convert xml to php array. * * @return array */ public function propertiesToArray() { $properties = array(); - $this->walkProperties(function($p) use(&$properties){ - $properties[$p['name']] = $p['@value']; - }); + $this->walkProperties( + function ($p) use (&$properties) { + $properties[$p['name']] = $p['@value']; + } + ); return $properties; } /** - * Finds first matched item by attribute value + * Finds first matched item by attribute value. + * + * @param string $attr + * @param mixed $value * - * @param string $name - * @param mixed $value * @throws \InvalidArgumentException * * @return \Bpi\Sdk\Document same instance */ - public function firstItem($attr, $value) { + public function firstItem($attr, $value) + { $this->crawler = $this->crawler ->filter("item[$attr='{$value}']") - ->first() - ; + ->first(); - if (!$this->crawler->count()) + if (!$this->crawler->count()) { throw new \InvalidArgumentException(sprintf('Item with attribute "%s" and value "%s" was not found', $attr, $value)); + } $this->crawler->rewind(); + return $this; } /** - * Filter items ( tags) by attribute values + * Filter items ( tags) by attribute values. + * + * @param string $attr + * @param mixed $value * - * @param string $name - * @param mixed $value * @throws \Bpi\Sdk\Exception\EmptyList * * @return \Bpi\Sdk\Document same instance */ - public function reduceItemsByAttr($attr, $value) { + public function reduceItemsByAttr($attr, $value) + { $this->crawler = $this->crawler->filter("item[$attr='{$value}']"); if (!$this->crawler->count()) { @@ -287,11 +305,12 @@ public function reduceItemsByAttr($attr, $value) { } $this->crawler->rewind(); + return $this; } /** - * Clear previous response if any + * Clear previous response if any. */ public function clear() { @@ -299,61 +318,67 @@ public function clear() } /** - * Iterator interface implementation + * Iterator interface implementation. * * @group Iterator */ - function rewind() + public function rewind() { $this->crawler->rewind(); } /** - * Returns same instance but with internal pointer to current item in collection + * Returns same instance but with internal pointer to current item in collection. * * @group Iterator + * * @return \Bpi\Sdk\Document will return same instance */ - function current() + public function current() { return $this; } /** - * Key of current iteration position + * Key of current iteration position. * * @group Iterator + * + * @return string */ - function key() + public function key() { return $this->crawler->key(); } /** - * Iterate to next item + * Iterate to next item. * * @group Iterator */ - function next() + public function next() { $this->crawler->next(); } /** - * Checks if is ready for iteration + * Checks if is ready for iteration. * * @group Iterator - * @return boolean + * + * @return bool */ - function valid() + public function valid() { return $this->crawler->valid(); } /** - * Length of items in document + * Length of items in document. * * @group Iterator + * + * @return int */ public function count() { diff --git a/Bpi/Sdk/Exception/EmptyList.php b/Bpi/Sdk/Exception/EmptyList.php index 64b101d..7a7d6ac 100644 --- a/Bpi/Sdk/Exception/EmptyList.php +++ b/Bpi/Sdk/Exception/EmptyList.php @@ -1,4 +1,10 @@ document->walkProperties(function($e) use(&$properties) { - if (isset($properties[$e['name']])) { - if (is_array($properties[$e['name']])) { - $properties[$e['name']][] = $e['@value']; + $this->document->walkProperties( + function ($e) use (&$properties) { + if (isset($properties[$e['name']])) { + if (is_array($properties[$e['name']])) { + $properties[$e['name']][] = $e['@value']; + } else { + $properties[$e['name']] = array($properties[$e['name']], $e['@value']); + } } else { - $properties[$e['name']] = array($properties[$e['name']], $e['@value']); + $properties[$e['name']] = $e['@value']; } - } else { - $properties[$e['name']] = $e['@value']; } - }); - + ); return $properties; } diff --git a/Bpi/Sdk/Item/Node.php b/Bpi/Sdk/Item/Node.php index ba1e5ce..0eabcc2 100644 --- a/Bpi/Sdk/Item/Node.php +++ b/Bpi/Sdk/Item/Node.php @@ -1,20 +1,26 @@ getProperties() as $key => $val) - { - if (strpos($key, 'asset') !== FALSE) - { + foreach ($this->getProperties() as $key => $val) { + if (strpos($key, 'asset') !== false) { $result[$key] = $val; } } @@ -22,16 +28,25 @@ public function getAssets() return $result; } + /** + * Syndicate node from web service. + */ public function syndicate() { // @todo implementation } + /** + * Push node to web service. + */ public function push() { // @todo implementation } + /** + * Mark node as deleted on web service. + */ public function delete() { // @todo implementation diff --git a/Bpi/Sdk/Link.php b/Bpi/Sdk/Link.php index 909764e..616d5db 100644 --- a/Bpi/Sdk/Link.php +++ b/Bpi/Sdk/Link.php @@ -1,17 +1,25 @@ crawler = $crawler; $this->testConsistency(); } - + /** - * Try crawler for consistency of data - * - * @throws Exception\InvalidHypermedia + * Try crawler for consistency of data. + * + * @throws Exception\UndefinedHypermedia * - * @returns bool + * @return bool */ protected function testConsistency() { @@ -35,16 +43,15 @@ protected function testConsistency() $this->crawler->attr('href'); $this->crawler->attr('rel'); } catch (\InvalidArgumentException $e) { - throw $e; - throw new Exception\UndefinedHypermedia(); - return false; + throw $e; } return true; } /** - * + * Call request method. + * * @param \Bpi\Sdk\Document $document */ public function follow(Document $document) @@ -53,7 +60,7 @@ public function follow(Document $document) } /** - * Perform HTTP GET for given URI + * Perform HTTP GET for given URI. * * @param \Bpi\Sdk\Document $document */ @@ -63,7 +70,7 @@ public function get(Document $document) } /** - * Perform HTTP POST for given URI + * Perform HTTP POST for given URI. * * @param \Bpi\Sdk\Document $document */ @@ -73,7 +80,7 @@ public function post(Document $document) } /** - * Perform HTTP DELETE for given URI + * Perform HTTP DELETE for given URI. * * @param \Bpi\Sdk\Document $document */ @@ -83,7 +90,7 @@ public function delete(Document $document) } /** - * Perform HTTP PUT for given URI + * Perform HTTP PUT for given URI. * * @param \Bpi\Sdk\Document $document */ @@ -93,19 +100,19 @@ public function put(Document $document) } /** - * + * Convert properties to array. + * * @return array properties */ public function toArray() { $properties = array(); - foreach($this->crawler as $node) - { - foreach ($node->attributes as $attr_name => $attr) - { + foreach ($this->crawler as $node) { + foreach ($node->attributes as $attr_name => $attr) { $properties[$attr_name] = $attr->value; } } + return $properties; } } diff --git a/Bpi/Sdk/NodeList.php b/Bpi/Sdk/NodeList.php index 8849fc2..d1410a4 100644 --- a/Bpi/Sdk/NodeList.php +++ b/Bpi/Sdk/NodeList.php @@ -1,102 +1,107 @@ document = clone $document; $this->document->reduceItemsByAttr('type', 'entity'); $self = $this; $document->firstItem('type', 'collection') - ->walkProperties(function($property) use ($self) { - $self->$property['name'] = $property['@value']; - }); - } - catch (Exception\EmptyList $e) - { + ->walkProperties( + function ($property) use ($self) { + $self->$property['name'] = $property['@value']; + } + ); + } catch (Exception\EmptyList $e) { $this->document->clear(); } } /** - * Iterator interface implementation + * Iterator interface implementation. * * @group Iterator */ - function rewind() + public function rewind() { $this->document->rewind(); } /** - * Returns same instance but with internal pointer to current item in collection + * Returns same instance but with internal pointer to current item in collection. * * @group Iterator - * @return \Bpi\Sdk\Document will return same instance + * + * @return \Bpi\Sdk\Item\Node will return same instance */ - function current() + public function current() { - return new \Bpi\Sdk\Item\Node($this->document->current()); + return new Node($this->document->current()); } /** - * Key of current iteration position + * Key of current iteration position. * * @group Iterator */ - function key() + public function key() { return $this->document->key(); } /** - * Iterate to next item + * Iterate to next item. * * @group Iterator */ - function next() + public function next() { $this->document->next(); } /** - * Checks if is ready for iteration + * Checks if is ready for iteration. * * @group Iterator - * @return boolean + * + * @return bool */ - function valid() + public function valid() { return $this->document->valid(); } /** + * Count documents. * - * @return integer + * @return int */ - function count() + public function count() { return $this->document->count(); } diff --git a/Bpi/Sdk/Query.php b/Bpi/Sdk/Query.php index edb01d6..23f82e1 100644 --- a/Bpi/Sdk/Query.php +++ b/Bpi/Sdk/Query.php @@ -1,18 +1,22 @@ crawler->filter('param'); } catch (\InvalidArgumentException $e) { throw new Exception\UndefinedHypermedia('Query has no href attribute or parameters inside'); - return false; } return true; } /** - * + * Validate parameters added to query. + * * @param array $params + * * @throws Exception\InvalidQueryParameter */ protected function validate(array $params) { - foreach ($params as $user_param => $value) - { + foreach ($params as $user_param => $value) { $param = $this->crawler->filter("param[name='{$user_param}']"); - if ($param->count() <= 0) - { + if ($param->count() <= 0) { throw new Exception\InvalidQueryParameter(sprintf('The API has no such query parameter [%s] on page [%s]', $user_param, $this->crawler->attr('href'))); } - if ($param->attr('type') == 'multiple' && !is_array($value)) - { + if ($param->attr('type') == 'multiple' && !is_array($value)) { throw new Exception\InvalidQueryParameter(sprintf('The API has declared a multiple value query parameter [%s], array expected', $user_param)); } - if (is_array($value) && $param->attr('type') != 'multiple') - { + if (is_array($value) && $param->attr('type') != 'multiple') { throw new Exception\InvalidQueryParameter(sprintf('The API has declared query parameter [%s] as single value, array was given', $user_param)); } } } - + /** - * Transform query to array - * + * Transform query to array. + * * @return array */ public function toArray() { $result = array(); - foreach($this->crawler as $node) - { - foreach ($node->attributes as $attr_name => $attr) - { + foreach ($this->crawler as $node) { + foreach ($node->attributes as $attr_name => $attr) { $result[$attr_name] = $attr->value; } } - - foreach ($this->crawler->filter('param') as $node) - { - foreach ($node->attributes as $attr_name => $attr) - { + + foreach ($this->crawler->filter('param') as $node) { + foreach ($node->attributes as $attr_name => $attr) { $result['params'][$attr_name] = $attr->value; } } - + return $result; } /** + * Prepare URI for WS request. * * @param array $params + * * @return string URI */ protected function buildURI(array $params) { $query_separator = parse_url($this->crawler->attr('href'), PHP_URL_QUERY) === null ? '?' : '&'; - return $this->crawler->attr('href') . $query_separator . http_build_query($params, '', '&'); + + return $this->crawler->attr('href').$query_separator.http_build_query($params, '', '&'); } /** - * + * Send request to WS with prepared query. + * * @param \Bpi\Sdk\Document $document - * @param array $params multidimensional arrays as well + * @param array $params multidimensional arrays as well */ public function send(Document $document, array $params) { diff --git a/Bpi/Sdk/ResponseStatus.php b/Bpi/Sdk/ResponseStatus.php index 331f4f8..0c1b345 100644 --- a/Bpi/Sdk/ResponseStatus.php +++ b/Bpi/Sdk/ResponseStatus.php @@ -1,47 +1,88 @@ status = (string) $status_code; - if ($this->status <= 0) - throw new \InvalidArgumentException('Incorrect HTTP status code [' . $status_code . ']'); + if ($this->status <= 0) { + throw new \InvalidArgumentException('Incorrect HTTP status code ['.$status_code.']'); + } } + /** + * Convert current status to string. + * + * @return string with current status + */ public function __toString() { return (string) $this->status; } + /** + * Return status code of finished request. + * + * @return string current status code + */ public function getCode() { return $this->status; } + /** + * Check if request was successful. + * + * @return bool if status successful + */ public function isSuccess() { return $this->status[0] == 2; } + /** + * Check if error code is client error. + * + * @return bool if status code is client error + */ public function isClientError() { return $this->status[0] == 4; } + /** + * Check if error code is server error. + * + * @return bool if status code is server error + */ public function isServerError() { return $this->status[0] == 5; } + /** + * Check if error response. + * + * @return bool if status code is error + */ public function isError() { return $this->isClientError() || $this->isServerError(); diff --git a/Bpi/Sdk/Template.php b/Bpi/Sdk/Template.php index e0b7931..0c2db02 100644 --- a/Bpi/Sdk/Template.php +++ b/Bpi/Sdk/Template.php @@ -1,24 +1,27 @@ crawler->attr('href'); $this->crawler->filter('param'); } catch (\InvalidArgumentException $e) { throw new Exception\UndefinedHypermedia(); - return false; } return true; @@ -51,19 +52,20 @@ protected function testConsistency() /** * Iterate over fields and prepare flat array with data. * - * @return array + * @return array of data */ protected function render() { $data = array(); - foreach($this->fields as $field) - { + foreach ($this->fields as $field) { $field->assignToList($data); } + return $data; } /** + * Send post request to WS. * * @param \Bpi\Sdk\Document $document */ @@ -76,12 +78,12 @@ public function post(Document $document) * Walk for each field in template. * * @param callback $callback + * * @return \Bpi\Sdk\Template */ public function eachField($callback) { - foreach ($this->crawler->filter('field') as $node) - { + foreach ($this->crawler->filter('field') as $node) { $this->fields[] = $field = new Template\Field($node); $callback($field); } diff --git a/Bpi/Sdk/Template/Field.php b/Bpi/Sdk/Template/Field.php index efaf50a..1c57e9a 100644 --- a/Bpi/Sdk/Template/Field.php +++ b/Bpi/Sdk/Template/Field.php @@ -1,10 +1,13 @@ reduceItemsByAttr(mt_rand(), 'node'); + $doc->reduceItemsByAttr('node', mt_rand()); $this->fail('Exception expected trying reduce items by non existing attribute'); } catch (Exception\EmptyList $e) { $this->assertTrue(true); diff --git a/composer.json b/composer.json index c6b4aa7..7c948a7 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,7 @@ ], "require": { "php": ">=5.3.3", - "doctrine/common": "2.3.0", - "fabpot/goutte": "v1.0.1" + "fabpot/goutte": "~1.0" }, "autoload": { "psr-0": { "Bpi\\Sdk": "." } diff --git a/composer.lock b/composer.lock index 9cb2ff3..647dc15 100644 --- a/composer.lock +++ b/composer.lock @@ -1,102 +1,38 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" ], - "hash": "77929a51afeb1f8effeaa7bb2599d390", + "hash": "db7248ebf602bb17915c700c79f719ec", "packages": [ - { - "name": "doctrine/common", - "version": "2.3.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/common", - "reference": "2.3.0" - }, - "dist": { - "type": "zip", - "url": "https://github.com/doctrine/common/zipball/2.3.0", - "reference": "2.3.0", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "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/" - }, - { - "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" - ], - "time": "2012-09-19 22:55:18" - }, { "name": "fabpot/goutte", - "version": "v1.0.1", + "version": "v1.0.7", "source": { "type": "git", - "url": "https://github.com/fabpot/Goutte.git", - "reference": "v1.0.1" + "url": "https://github.com/FriendsOfPHP/Goutte.git", + "reference": "794b196e76bdd37b5155cdecbad311f0a3b07625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Goutte/zipball/v1.0.1", - "reference": "v1.0.1", + "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/794b196e76bdd37b5155cdecbad311f0a3b07625", + "reference": "794b196e76bdd37b5155cdecbad311f0a3b07625", "shasum": "" }, "require": { "ext-curl": "*", - "guzzle/guzzle": ">=3.0, <3.4", + "guzzle/http": "~3.1", "php": ">=5.3.0", - "symfony/browser-kit": ">=2.1,<3.0", - "symfony/css-selector": ">=2.1,<3.0", - "symfony/dom-crawler": ">=2.1,<3.0", - "symfony/finder": ">=2.1,<3.0", - "symfony/process": ">=2.1,<3.0" + "symfony/browser-kit": "~2.1", + "symfony/css-selector": "~2.1", + "symfony/dom-crawler": "~2.1", + "symfony/finder": "~2.1", + "symfony/process": "~2.1" + }, + "require-dev": { + "guzzle/plugin-history": "~3.1", + "guzzle/plugin-mock": "~3.1" }, "type": "application", "extra": { @@ -124,7 +60,7 @@ "keywords": [ "scraper" ], - "time": "2013-03-08 08:00:58" + "time": "2014-10-09 15:52:51" }, { "name": "guzzle/guzzle", @@ -221,34 +157,35 @@ }, { "name": "symfony/browser-kit", - "version": "v2.2.1", + "version": "v2.6.6", "target-dir": "Symfony/Component/BrowserKit", "source": { "type": "git", "url": "https://github.com/symfony/BrowserKit.git", - "reference": "v2.2.1" + "reference": "f21189b0eccbe56528515858ca1d5089a741692f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/f21189b0eccbe56528515858ca1d5089a741692f", + "reference": "f21189b0eccbe56528515858ca1d5089a741692f", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/dom-crawler": ">=2.0,<3.0" + "symfony/dom-crawler": "~2.0,>=2.0.5" }, "require-dev": { - "symfony/css-selector": ">=2.0,<3.0", - "symfony/process": ">=2.0,<3.0" + "symfony/css-selector": "~2.0,>=2.0.5", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.0,>=2.0.5" }, "suggest": { - "symfony/process": "2.2.*" + "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -261,41 +198,44 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony BrowserKit Component", "homepage": "http://symfony.com", - "time": "2013-03-15 10:14:31" + "time": "2015-03-30 15:54:10" }, { "name": "symfony/css-selector", - "version": "v2.2.1", + "version": "v2.6.6", "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", "url": "https://github.com/symfony/CssSelector.git", - "reference": "v2.2.1" + "reference": "db2c48df9658423a8c168d89f7b971b73d3d74a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/db2c48df9658423a8c168d89f7b971b73d3d74a4", + "reference": "db2c48df9658423a8c168d89f7b971b73d3d74a4", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -308,47 +248,52 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony CssSelector Component", "homepage": "http://symfony.com", - "time": "2013-01-17 15:25:59" + "time": "2015-03-22 16:55:57" }, { "name": "symfony/dom-crawler", - "version": "v2.2.1", + "version": "v2.6.6", "target-dir": "Symfony/Component/DomCrawler", "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler.git", - "reference": "v2.2.1" + "reference": "8897ebf39c7dfb752a5494fa301845a3fbb9e53d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/8897ebf39c7dfb752a5494fa301845a3fbb9e53d", + "reference": "8897ebf39c7dfb752a5494fa301845a3fbb9e53d", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/css-selector": ">=2.0,<3.0" + "symfony/css-selector": "~2.3", + "symfony/phpunit-bridge": "~2.7" }, "suggest": { - "symfony/css-selector": "2.2.*" + "symfony/css-selector": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -361,48 +306,53 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony DomCrawler Component", "homepage": "http://symfony.com", - "time": "2013-04-01 08:05:23" + "time": "2015-03-30 15:54:10" }, { "name": "symfony/event-dispatcher", - "version": "v2.2.1", + "version": "v2.6.6", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.1" + "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284", + "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/dependency-injection": ">=2.0,<3.0" + "psr/log": "~1.0", + "symfony/config": "~2.0,>=2.0.5", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", + "symfony/stopwatch": "~2.3" }, "suggest": { - "symfony/dependency-injection": "2.2.*", - "symfony/http-kernel": "2.2.*" + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -415,41 +365,44 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-02-11 11:26:43" + "time": "2015-03-13 17:37:22" }, { "name": "symfony/finder", - "version": "v2.2.1", + "version": "v2.6.6", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "v2.2.1" + "reference": "5dbe2e73a580618f5b4880fda93406eed25de251" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Finder/zipball/5dbe2e73a580618f5b4880fda93406eed25de251", + "reference": "5dbe2e73a580618f5b4880fda93406eed25de251", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -462,41 +415,44 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2013-04-01 07:51:50" + "time": "2015-03-30 15:54:10" }, { "name": "symfony/process", - "version": "v2.2.1", + "version": "v2.6.6", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.2.1" + "reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Process/zipball/a8bebaec1a9dc6cde53e0250e32917579b0be552", + "reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -509,34 +465,28 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2013-03-23 07:49:54" + "time": "2015-03-30 15:54:10" } ], - "packages-dev": [ - - ], - "aliases": [ - - ], + "packages-dev": [], + "aliases": [], "minimum-stability": "stable", - "stability-flags": [ - - ], + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, "platform": { "php": ">=5.3.3" }, - "platform-dev": [ - - ] + "platform-dev": [] } diff --git a/vendor/autoload.php b/vendor/autoload.php index 00359ee..e22d07f 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -1,6 +1,6 @@ prefixes; + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; } public function getFallbackDirs() { - return $this->fallbackDirs; + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; } public function getClassMap() @@ -75,61 +98,135 @@ public function addClassMap(array $classMap) } /** - * Registers a set of classes, merging with any others previously set. + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The classes prefix - * @param array|string $paths The location(s) of the classes - * @param bool $prepend Prepend the location(s) + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories */ public function add($prefix, $paths, $prepend = false) { if (!$prefix) { if ($prepend) { - $this->fallbackDirs = array_merge( + $this->fallbackDirsPsr0 = array_merge( (array) $paths, - $this->fallbackDirs + $this->fallbackDirsPsr0 ); } else { - $this->fallbackDirs = array_merge( - $this->fallbackDirs, + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, (array) $paths ); } return; } - if (!isset($this->prefixes[$prefix])) { - $this->prefixes[$prefix] = (array) $paths; + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; return; } if ($prepend) { - $this->prefixes[$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix] = array_merge( (array) $paths, - $this->prefixes[$prefix] + $this->prefixesPsr0[$first][$prefix] ); } else { - $this->prefixes[$prefix] = array_merge( - $this->prefixes[$prefix], + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], (array) $paths ); } } /** - * Registers a set of classes, replacing any others previously set. + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-0 base directories + * @param bool $prepend Whether to prepend the directories * - * @param string $prefix The classes prefix - * @param array|string $paths The location(s) of the classes + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories */ public function set($prefix, $paths) { if (!$prefix) { - $this->fallbackDirs = (array) $paths; + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } - return; + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; } - $this->prefixes[$prefix] = (array) $paths; } /** @@ -153,6 +250,27 @@ public function getUseIncludePath() return $this->useIncludePath; } + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + /** * Registers this instance as an autoloader. * @@ -180,7 +298,7 @@ public function unregister() public function loadClass($class) { if ($file = $this->findFile($class)) { - include $file; + includeFile($file); return true; } @@ -195,46 +313,101 @@ public function loadClass($class) */ public function findFile($class) { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 if ('\\' == $class[0]) { $class = substr($class, 1); } + // class map lookup if (isset($this->classMap[$class])) { return $this->classMap[$class]; } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup if (false !== $pos = strrpos($class, '\\')) { // namespaced class name - $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR; - $className = substr($class, $pos + 1); + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); } else { // PEAR-like class name - $classPath = null; - $className = $class; + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; } - $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; - - foreach ($this->prefixes as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { - return $dir . DIRECTORY_SEPARATOR . $classPath; + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } } } } } - foreach ($this->fallbackDirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { - return $dir . DIRECTORY_SEPARATOR . $classPath; + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; } } - if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) { + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { return $file; } - - return $this->classMap[$class] = false; } } + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index af4ad58..7a91153 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -1,6 +1,6 @@ $vendorDir . '/symfony/process', - 'Symfony\\Component\\Finder\\' => $vendorDir . '/symfony/finder', - 'Symfony\\Component\\EventDispatcher\\' => $vendorDir . '/symfony/event-dispatcher', - 'Symfony\\Component\\DomCrawler\\' => $vendorDir . '/symfony/dom-crawler', - 'Symfony\\Component\\CssSelector\\' => $vendorDir . '/symfony/css-selector', - 'Symfony\\Component\\BrowserKit\\' => $vendorDir . '/symfony/browser-kit', - 'Guzzle\\Tests' => $vendorDir . '/guzzle/guzzle/tests', - 'Guzzle' => $vendorDir . '/guzzle/guzzle/src', - 'Goutte' => $vendorDir . '/fabpot/goutte', - 'Doctrine\\Common' => $vendorDir . '/doctrine/common/lib', - 'Bpi\\Sdk' => $baseDir . '/', + 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'), + 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'), + 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), + 'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'), + 'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'), + 'Symfony\\Component\\BrowserKit\\' => array($vendorDir . '/symfony/browser-kit'), + 'Guzzle\\Tests' => array($vendorDir . '/guzzle/guzzle/tests'), + 'Guzzle' => array($vendorDir . '/guzzle/guzzle/src'), + 'Goutte' => array($vendorDir . '/fabpot/goutte'), + 'Bpi\\Sdk' => array($baseDir . '/'), ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000..b265c64 --- /dev/null +++ b/vendor/composer/autoload_psr4.php @@ -0,0 +1,9 @@ + $path) { - $loader->add($namespace, $path); + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); } $classMap = require __DIR__ . '/autoload_classmap.php'; @@ -41,3 +43,8 @@ public static function getLoader() return $loader; } } + +function composerRequire1c5719d25ed4cf7c2fdb9c3eb1362f0b($file) +{ + require $file; +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index d025891..0153da5 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,131 +1,4 @@ [ - { - "name": "doctrine/common", - "version": "2.3.0", - "version_normalized": "2.3.0.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/common", - "reference": "2.3.0" - }, - "dist": { - "type": "zip", - "url": "https://github.com/doctrine/common/zipball/2.3.0", - "reference": "2.3.0", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "time": "2012-09-19 22:55:18", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.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/" - }, - { - "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": "symfony/event-dispatcher", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", - "target-dir": "Symfony/Component/EventDispatcher", - "source": { - "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.1", - "reference": "v2.2.1", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/dependency-injection": ">=2.0,<3.0" - }, - "suggest": { - "symfony/dependency-injection": "2.2.*", - "symfony/http-kernel": "2.2.*" - }, - "time": "2013-02-11 11:26:43", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com" - }, { "name": "guzzle/guzzle", "version": "v3.3.1", @@ -221,30 +94,94 @@ "web service" ] }, + { + "name": "symfony/event-dispatcher", + "version": "v2.6.6", + "version_normalized": "2.6.6.0", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284", + "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0,>=2.0.5", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", + "symfony/stopwatch": "~2.3" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "time": "2015-03-13 17:37:22", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com" + }, { "name": "symfony/process", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.6.6", + "version_normalized": "2.6.6.0", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.2.1" + "reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Process/zipball/a8bebaec1a9dc6cde53e0250e32917579b0be552", + "reference": "a8bebaec1a9dc6cde53e0250e32917579b0be552", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-03-23 07:49:54", + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "time": "2015-03-30 15:54:10", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "installation-source": "dist", @@ -258,13 +195,13 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Process Component", @@ -272,28 +209,31 @@ }, { "name": "symfony/finder", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.6.6", + "version_normalized": "2.6.6.0", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "v2.2.1" + "reference": "5dbe2e73a580618f5b4880fda93406eed25de251" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Finder/zipball/5dbe2e73a580618f5b4880fda93406eed25de251", + "reference": "5dbe2e73a580618f5b4880fda93406eed25de251", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-04-01 07:51:50", + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "time": "2015-03-30 15:54:10", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "installation-source": "dist", @@ -307,13 +247,13 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Finder Component", @@ -321,34 +261,35 @@ }, { "name": "symfony/dom-crawler", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.6.6", + "version_normalized": "2.6.6.0", "target-dir": "Symfony/Component/DomCrawler", "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler.git", - "reference": "v2.2.1" + "reference": "8897ebf39c7dfb752a5494fa301845a3fbb9e53d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/8897ebf39c7dfb752a5494fa301845a3fbb9e53d", + "reference": "8897ebf39c7dfb752a5494fa301845a3fbb9e53d", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/css-selector": ">=2.0,<3.0" + "symfony/css-selector": "~2.3", + "symfony/phpunit-bridge": "~2.7" }, "suggest": { - "symfony/css-selector": "2.2.*" + "symfony/css-selector": "" }, - "time": "2013-04-01 08:05:23", + "time": "2015-03-30 15:54:10", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "installation-source": "dist", @@ -362,13 +303,13 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony DomCrawler Component", @@ -376,28 +317,31 @@ }, { "name": "symfony/css-selector", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.6.6", + "version_normalized": "2.6.6.0", "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", "url": "https://github.com/symfony/CssSelector.git", - "reference": "v2.2.1" + "reference": "db2c48df9658423a8c168d89f7b971b73d3d74a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/db2c48df9658423a8c168d89f7b971b73d3d74a4", + "reference": "db2c48df9658423a8c168d89f7b971b73d3d74a4", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2013-01-17 15:25:59", + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "time": "2015-03-22 16:55:57", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "installation-source": "dist", @@ -411,13 +355,17 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony CssSelector Component", @@ -425,36 +373,37 @@ }, { "name": "symfony/browser-kit", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", + "version": "v2.6.6", + "version_normalized": "2.6.6.0", "target-dir": "Symfony/Component/BrowserKit", "source": { "type": "git", "url": "https://github.com/symfony/BrowserKit.git", - "reference": "v2.2.1" + "reference": "f21189b0eccbe56528515858ca1d5089a741692f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/f21189b0eccbe56528515858ca1d5089a741692f", + "reference": "f21189b0eccbe56528515858ca1d5089a741692f", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/dom-crawler": ">=2.0,<3.0" + "symfony/dom-crawler": "~2.0,>=2.0.5" }, "require-dev": { - "symfony/css-selector": ">=2.0,<3.0", - "symfony/process": ">=2.0,<3.0" + "symfony/css-selector": "~2.0,>=2.0.5", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.0,>=2.0.5" }, "suggest": { - "symfony/process": "2.2.*" + "symfony/process": "" }, - "time": "2013-03-15 10:14:31", + "time": "2015-03-30 15:54:10", "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } }, "installation-source": "dist", @@ -468,13 +417,13 @@ "MIT" ], "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony BrowserKit Component", @@ -482,30 +431,34 @@ }, { "name": "fabpot/goutte", - "version": "v1.0.1", - "version_normalized": "1.0.1.0", + "version": "v1.0.7", + "version_normalized": "1.0.7.0", "source": { "type": "git", - "url": "https://github.com/fabpot/Goutte.git", - "reference": "v1.0.1" + "url": "https://github.com/FriendsOfPHP/Goutte.git", + "reference": "794b196e76bdd37b5155cdecbad311f0a3b07625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Goutte/zipball/v1.0.1", - "reference": "v1.0.1", + "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/794b196e76bdd37b5155cdecbad311f0a3b07625", + "reference": "794b196e76bdd37b5155cdecbad311f0a3b07625", "shasum": "" }, "require": { "ext-curl": "*", - "guzzle/guzzle": ">=3.0, <3.4", + "guzzle/http": "~3.1", "php": ">=5.3.0", - "symfony/browser-kit": ">=2.1,<3.0", - "symfony/css-selector": ">=2.1,<3.0", - "symfony/dom-crawler": ">=2.1,<3.0", - "symfony/finder": ">=2.1,<3.0", - "symfony/process": ">=2.1,<3.0" + "symfony/browser-kit": "~2.1", + "symfony/css-selector": "~2.1", + "symfony/dom-crawler": "~2.1", + "symfony/finder": "~2.1", + "symfony/process": "~2.1" + }, + "require-dev": { + "guzzle/plugin-history": "~3.1", + "guzzle/plugin-mock": "~3.1" }, - "time": "2013-03-08 08:00:58", + "time": "2014-10-09 15:52:51", "type": "application", "extra": { "branch-alias": { diff --git a/vendor/doctrine/common/.gitignore b/vendor/doctrine/common/.gitignore deleted file mode 100644 index fb5e79d..0000000 --- a/vendor/doctrine/common/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -build/ -logs/ -reports/ -dist/ diff --git a/vendor/doctrine/common/.gitmodules b/vendor/doctrine/common/.gitmodules deleted file mode 100644 index 51f0843..0000000 --- a/vendor/doctrine/common/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lib/vendor/doctrine-build-common"] - path = lib/vendor/doctrine-build-common - url = git://github.com/doctrine/doctrine-build-common.git diff --git a/vendor/doctrine/common/.travis.yml b/vendor/doctrine/common/.travis.yml deleted file mode 100644 index fc05056..0000000 --- a/vendor/doctrine/common/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: php - -env: - - OPCODE_CACHE=apc - -php: - - 5.3 - - 5.4 - -before_script: php ./bin/travis-setup.php $OPCODE_CACHE \ No newline at end of file diff --git a/vendor/doctrine/common/LICENSE b/vendor/doctrine/common/LICENSE deleted file mode 100644 index 4a91f0b..0000000 --- a/vendor/doctrine/common/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2006-2012 Doctrine Project - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/doctrine/common/README.md b/vendor/doctrine/common/README.md deleted file mode 100644 index c63f762..0000000 --- a/vendor/doctrine/common/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Doctrine Common - -[![Build Status](https://secure.travis-ci.org/doctrine/common.png)](http://travis-ci.org/doctrine/common) - -The Doctrine Common project is a library that provides extensions to core PHP functionality. - -## More resources: - -* [Website](http://www.doctrine-project.org) -* [Documentation](http://www.doctrine-project.org/projects/common/current/docs/en) -* [Issue Tracker](http://www.doctrine-project.org/jira/browse/DCOM) -* [Downloads](http://github.com/doctrine/common/downloads) diff --git a/vendor/doctrine/common/UPGRADE_TO_2_1 b/vendor/doctrine/common/UPGRADE_TO_2_1 deleted file mode 100644 index 891a2e5..0000000 --- a/vendor/doctrine/common/UPGRADE_TO_2_1 +++ /dev/null @@ -1,39 +0,0 @@ -This document details all the possible changes that you should investigate when updating -your project from Doctrine Common 2.0.x to 2.1 - -## AnnotationReader changes - -The annotation reader was heavily refactored between 2.0 and 2.1-RC1. In theory the operation of the new reader should be backwards compatible, but it has to be setup differently to work that way: - - $reader = new \Doctrine\Common\Annotations\AnnotationReader(); - $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); - // new code necessary starting here - $reader->setIgnoreNotImportedAnnotations(true); - $reader->setEnableParsePhpImports(false); - $reader = new \Doctrine\Common\Annotations\CachedReader( - new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() - ); - -## Annotation Base class or @Annotation - -Beginning after 2.1-RC2 you have to either extend ``Doctrine\Common\Annotations\Annotation`` or add @Annotation to your annotations class-level docblock, otherwise the class will simply be ignored. - -## Removed methods on AnnotationReader - -* AnnotationReader::setAutoloadAnnotations() -* AnnotationReader::getAutoloadAnnotations() -* AnnotationReader::isAutoloadAnnotations() - -## AnnotationRegistry - -Autoloading through the PHP autoloader is removed from the 2.1 AnnotationReader. Instead you have to use the global AnnotationRegistry for loading purposes: - - \Doctrine\Common\Annotations\AnnotationRegistry::registerFile($fileWithAnnotations); - \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($namespace, $dirs = null); - \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespaces($namespaces); - \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader($callable); - -The $callable for registering a loader accepts a class as first and only parameter and must try to silently autoload it. On success true has to be returned. -The registerAutoloadNamespace function registers a PSR-0 compatible silent autoloader for all classes with the given namespace in the given directories. -If null is passed as directory the include path will be used. - diff --git a/vendor/doctrine/common/UPGRADE_TO_2_2 b/vendor/doctrine/common/UPGRADE_TO_2_2 deleted file mode 100644 index 1d93a13..0000000 --- a/vendor/doctrine/common/UPGRADE_TO_2_2 +++ /dev/null @@ -1,61 +0,0 @@ -This document details all the possible changes that you should investigate when -updating your project from Doctrine Common 2.1 to 2.2: - -## Annotation Changes - -- AnnotationReader::setIgnoreNotImportedAnnotations has been removed, you need to - add ignore annotation names which are supposed to be ignored via - AnnotationReader::addGlobalIgnoredName - -- AnnotationReader::setAutoloadAnnotations was deprecated by the AnnotationRegistry - in 2.1 and has been removed in 2.2 - -- AnnotationReader::setEnableParsePhpImports was added to ease transition to the new - annotation mechanism in 2.1 and is removed in 2.2 - -- AnnotationReader::isParsePhpImportsEnabled is removed (see above) - -- AnnotationReader::setDefaultAnnotationNamespace was deprecated in favor of explicit - configuration in 2.1 and will be removed in 2.2 (for isolated projects where you - have full-control over _all_ available annotations, we offer a dedicated reader - class ``SimpleAnnotationReader``) - -- AnnotationReader::setAnnotationCreationFunction was deprecated in 2.1 and will be - removed in 2.2. We only offer two creation mechanisms which cannot be changed - anymore to allow the same reader instance to work with all annotations regardless - of which library they are coming from. - -- AnnotationReader::setAnnotationNamespaceAlias was deprecated in 2.1 and will be - removed in 2.2 (see setDefaultAnnotationNamespace) - -- If you use a class as annotation which has not the @Annotation marker in it's - class block, we will now throw an exception instead of silently ignoring it. You - can however still achieve the previous behavior using the @IgnoreAnnotation, or - AnnotationReader::addGlobalIgnoredName (the exception message will contain detailed - instructions when you run into this problem). - -## Cache Changes - -- Renamed old AbstractCache to CacheProvider - -- Dropped the support to the following functions of all cache providers: - - - CacheProvider::deleteByWildcard - - - CacheProvider::deleteByRegEx - - - CacheProvider::deleteByPrefix - - - CacheProvider::deleteBySuffix - -- CacheProvider::deleteAll will not remove ALL entries, it will only mark them as invalid - -- CacheProvider::flushAll will remove ALL entries, namespaced or not - -- Added support to MemcachedCache - -- Added support to WincacheCache - -## ClassLoader Changes - -- ClassLoader::fileExistsInIncludePath() no longer exists. Use the native stream_resolve_include_path() PHP function \ No newline at end of file diff --git a/vendor/doctrine/common/bin/travis-setup.php b/vendor/doctrine/common/bin/travis-setup.php deleted file mode 100644 index e9c355a..0000000 --- a/vendor/doctrine/common/bin/travis-setup.php +++ /dev/null @@ -1,141 +0,0 @@ -. - */ - -/** - * Install PHP extensions required for testing by Travis CI. - * - * @author Victor Berchet - * @since 2.2 - */ -$installer = new PhpExtensions(); - -if (isset($argv[1]) && 'APC' === strtoupper($argv[1])) { - $installer->install('apc'); -} else { - $installer->install('xcache'); -} - -$installer->install('memcache'); -$installer->install('memcached'); - -class PhpExtensions -{ - protected $extensions; - protected $phpVersion; - protected $iniPath; - - public function __construct() - { - $this->phpVersion = phpversion(); - $this->iniPath = php_ini_loaded_file(); - $this->extensions = array( - 'memcache' => array( - 'url' => 'http://pecl.php.net/get/memcache-2.2.6.tgz', - 'php_version' => array(), - 'cfg' => array('--enable-memcache'), - 'ini' => array('extension=memcache.so'), - ), - 'memcached' => array( - 'url' => 'http://pecl.php.net/get/memcached-1.0.2.tgz', - 'php_version' => array( - // memcached 1.0.2 does not build on PHP 5.4 - array('<', '5.4'), - ), - 'cfg' => array(), - 'ini' => array('extension=memcached.so'), - ), - 'apc' => array( - 'url' => 'http://pecl.php.net/get/APC-3.1.9.tgz', - 'php_version' => array( - // apc 3.1.9 causes a segfault on PHP 5.4 - array('<', '5.4'), - ), - 'cfg' => array(), - 'ini' => array( - 'extension=apc.so', - 'apc.enabled=1', - 'apc.enable_cli=1' - ), - ), - 'xcache' => array( - 'url' => 'http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz', - 'php_version' => array( - // xcache does not build with Travis CI (as of 2012-01-09) - array('<', '5'), - ), - 'cfg' => array('--enable-xcache'), - 'ini' => array( - 'extension=xcache.so', - 'xcache.cacher=false', - 'xcache.admin.enable_auth=0', - 'xcache.var_size=1M', - ), - ), - ); - } - - public function install($name) - { - if (array_key_exists($name, $this->extensions)) { - $extension = $this->extensions[$name]; - - - echo "== extension: $name ==\n"; - - foreach ($extension['php_version'] as $version) { - if (!version_compare($this->phpVersion, $version[1], $version[0])) { - printf( - "=> not installed, requires a PHP version %s %s (%s installed)\n", - $version[0], - $version[1], - $this->phpVersion - ); - - return; - } - } - - $this->system(sprintf("wget %s > /dev/null 2>&1", $extension['url'])); - $file = basename($extension['url']); - $this->system(sprintf("tar -xzf %s > /dev/null 2>&1", $file)); - $folder = basename($file, ".tgz"); - $folder = basename($folder, ".tar.gz"); - $this->system(sprintf( - 'sh -c "cd %s && phpize && ./configure %s && make && sudo make install" > /dev/null 2>&1', - $folder, - implode(' ', $extension['cfg']) - )); - foreach ($extension['ini'] as $ini) { - $this->system(sprintf("echo %s >> %s", $ini, $this->iniPath)); - } - printf("=> installed (%s)\n", $folder); - } - } - - private function system($cmd) - { - $ret = 0; - system($cmd, $ret); - if (0 !== $ret) { - printf("=> Command '%s' failed !", $cmd); - - exit($ret); - } - } -} diff --git a/vendor/doctrine/common/build.properties b/vendor/doctrine/common/build.properties deleted file mode 100644 index ff311a4..0000000 --- a/vendor/doctrine/common/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -# Project Name -project.name=DoctrineCommon - -# Version class and file -project.version_class = Doctrine\Common\Version -project.version_file = lib/Doctrine/Common/Version.php diff --git a/vendor/doctrine/common/build.xml b/vendor/doctrine/common/build.xml deleted file mode 100644 index 71a9a50..0000000 --- a/vendor/doctrine/common/build.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DoctrineCommon - Doctrine Common PHP Extensions - pear.doctrine-project.org - The Doctrine Common package contains shared code between the other packages. - - - - - LGPL - - - - - - - - - - - diff --git a/vendor/doctrine/common/composer.json b/vendor/doctrine/common/composer.json deleted file mode 100644 index c87258d..0000000 --- a/vendor/doctrine/common/composer.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "doctrine/common", - "type": "library", - "description": "Common Library for Doctrine projects", - "keywords": ["collections", "spl", "eventmanager", "annotations", "persistence"], - "homepage": "http://www.doctrine-project.org", - "license": "MIT", - "authors": [ - {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, - {"name": "Roman Borschel", "email": "roman@code-factory.org"}, - {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, - {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, - {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} - ], - "require": { - "php": ">=5.3.2" - }, - "autoload": { - "psr-0": { "Doctrine\\Common": "lib/" } - }, - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation.php deleted file mode 100644 index 6a1390a..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation.php +++ /dev/null @@ -1,79 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -/** - * Annotations class - * - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -class Annotation -{ - /** - * Value property. Common among all derived classes. - * - * @var string - */ - public $value; - - /** - * Constructor - * - * @param array $data Key-value for properties to be defined in this class - */ - public final function __construct(array $data) - { - foreach ($data as $key => $value) { - $this->$key = $value; - } - } - - /** - * Error handler for unknown property accessor in Annotation class. - * - * @param string $name Unknown property name - * - * @throws \BadMethodCallException - */ - public function __get($name) - { - throw new \BadMethodCallException( - sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this)) - ); - } - - /** - * Error handler for unknown property mutator in Annotation class. - * - * @param string $name Unkown property name - * @param mixed $value Property value - * - * @throws \BadMethodCallException - */ - public function __set($name, $value) - { - throw new \BadMethodCallException( - sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this)) - ); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attribute.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attribute.php deleted file mode 100644 index dbef6df..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attribute.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations\Annotation; - -/** - * Annotation that can be used to signal to the parser - * to check the attribute type during the parsing process. - * - * @author Fabio B. Silva - * - * @Annotation - */ -final class Attribute -{ - /** - * @var string - */ - public $name; - - /** - * @var string - */ - public $type; - - /** - * @var boolean - */ - public $required = false; -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attributes.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attributes.php deleted file mode 100644 index 53134e3..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Attributes.php +++ /dev/null @@ -1,37 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations\Annotation; - -/** - * Annotation that can be used to signal to the parser - * to check the types of all declared attributes during the parsing process. - * - * @author Fabio B. Silva - * - * @Annotation - */ -final class Attributes -{ - /** - * @var array - */ - public $value; -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php deleted file mode 100644 index a84a4f5..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php +++ /dev/null @@ -1,54 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations\Annotation; - -/** - * Annotation that can be used to signal to the parser to ignore specific - * annotations during the parsing process. - * - * @Annotation - * @author Johannes M. Schmitt - */ -final class IgnoreAnnotation -{ - /** - * @var array - */ - public $names; - - /** - * Constructor - * - * @param array $values - * - * @throws \RuntimeException - */ - public function __construct(array $values) - { - if (is_string($values['value'])) { - $values['value'] = array($values['value']); - } - if (!is_array($values['value'])) { - throw new \RuntimeException(sprintf('@IgnoreAnnotation expects either a string name, or an array of strings, but got %s.', json_encode($values['value']))); - } - - $this->names = $values['value']; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Required.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Required.php deleted file mode 100644 index d67f960..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Required.php +++ /dev/null @@ -1,33 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations\Annotation; - -/** - * Annotation that can be used to signal to the parser - * to check if that attribute is required during the parsing process. - * - * @author Fabio B. Silva - * - * @Annotation - */ -final class Required -{ -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Target.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Target.php deleted file mode 100644 index 64655ef..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Target.php +++ /dev/null @@ -1,107 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations\Annotation; - -/** - * Annotation that can be used to signal to the parser - * to check the annotation target during the parsing process. - * - * @author Fabio B. Silva - * - * @Annotation - */ -final class Target -{ - const TARGET_CLASS = 1; - const TARGET_METHOD = 2; - const TARGET_PROPERTY = 4; - const TARGET_ANNOTATION = 8; - const TARGET_ALL = 15; - - /** - * @var array - */ - private static $map = array( - 'ALL' => self::TARGET_ALL, - 'CLASS' => self::TARGET_CLASS, - 'METHOD' => self::TARGET_METHOD, - 'PROPERTY' => self::TARGET_PROPERTY, - 'ANNOTATION' => self::TARGET_ANNOTATION, - ); - - /** - * @var array - */ - public $value; - - /** - * Targets as bitmask. - * - * @var integer - */ - public $targets; - - /** - * Literal target declaration. - * - * @var integer - */ - public $literal; - - /** - * Annotation construct - * - * @param array $values - * - * @throws \InvalidArgumentException - */ - public function __construct(array $values) - { - if (!isset($values['value'])){ - $values['value'] = null; - } - if (is_string($values['value'])){ - $values['value'] = array($values['value']); - } - if (!is_array($values['value'])){ - throw new \InvalidArgumentException( - sprintf('@Target expects either a string value, or an array of strings, "%s" given.', - is_object($values['value']) ? get_class($values['value']) : gettype($values['value']) - ) - ); - } - - $bitmask = 0; - foreach ($values['value'] as $literal) { - if(!isset(self::$map[$literal])){ - throw new \InvalidArgumentException( - sprintf('Invalid Target "%s". Available targets: [%s]', - $literal, implode(', ', array_keys(self::$map))) - ); - } - $bitmask += self::$map[$literal]; - } - - $this->targets = $bitmask; - $this->value = $values['value']; - $this->literal = implode(', ', $this->value); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php deleted file mode 100644 index 109beeb..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php +++ /dev/null @@ -1,127 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -/** - * Description of AnnotationException - * - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -class AnnotationException extends \Exception -{ - /** - * Creates a new AnnotationException describing a Syntax error. - * - * @param string $message Exception message - * @return AnnotationException - */ - public static function syntaxError($message) - { - return new self('[Syntax Error] ' . $message); - } - - /** - * Creates a new AnnotationException describing a Semantical error. - * - * @param string $message Exception message - * @return AnnotationException - */ - public static function semanticalError($message) - { - return new self('[Semantical Error] ' . $message); - } - - /** - * Creates a new AnnotationException describing a constant semantical error. - * - * @since 2.3 - * @param string $identifier - * @param string $context - * @return AnnotationException - */ - public static function semanticalErrorConstants($identifier, $context = null) - { - return self::semanticalError(sprintf( - "Couldn't find constant %s%s", $identifier, - $context ? ", $context." : "." - )); - } - - /** - * Creates a new AnnotationException describing an error which occurred during - * the creation of the annotation. - * - * @since 2.2 - * @param string $message - * @return AnnotationException - */ - public static function creationError($message) - { - return new self('[Creation Error] ' . $message); - } - - /** - * Creates a new AnnotationException describing an type error of an attribute. - * - * @since 2.2 - * @param string $attributeName - * @param string $annotationName - * @param string $context - * @param string $expected - * @param mixed $actual - * @return AnnotationException - */ - public static function typeError($attributeName, $annotationName, $context, $expected, $actual) - { - return new self(sprintf( - '[Type Error] Attribute "%s" of @%s declared on %s expects %s, but got %s.', - $attributeName, - $annotationName, - $context, - $expected, - is_object($actual) ? 'an instance of '.get_class($actual) : gettype($actual) - )); - } - - /** - * Creates a new AnnotationException describing an required error of an attribute. - * - * @since 2.2 - * @param string $attributeName - * @param string $annotationName - * @param string $context - * @param string $expected - * @return AnnotationException - */ - public static function requiredError($attributeName, $annotationName, $context, $expected) - { - return new self(sprintf( - '[Type Error] Attribute "%s" of @%s declared on %s expects %s. This value should not be null.', - $attributeName, - $annotationName, - $context, - $expected - )); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php deleted file mode 100644 index 286e7d0..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php +++ /dev/null @@ -1,310 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; -use Doctrine\Common\Annotations\Annotation\Target; -use Closure; -use ReflectionClass; -use ReflectionMethod; -use ReflectionProperty; - -/** - * A reader for docblock annotations. - * - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Johannes M. Schmitt - */ -class AnnotationReader implements Reader -{ - /** - * Global map for imports. - * - * @var array - */ - private static $globalImports = array( - 'ignoreannotation' => 'Doctrine\Common\Annotations\Annotation\IgnoreAnnotation', - ); - - /** - * A list with annotations that are not causing exceptions when not resolved to an annotation class. - * - * The names are case sensitive. - * - * @var array - */ - private static $globalIgnoredNames = array( - 'access'=> true, 'author'=> true, 'copyright'=> true, 'deprecated'=> true, - 'example'=> true, 'ignore'=> true, 'internal'=> true, 'link'=> true, 'see'=> true, - 'since'=> true, 'tutorial'=> true, 'version'=> true, 'package'=> true, - 'subpackage'=> true, 'name'=> true, 'global'=> true, 'param'=> true, - 'return'=> true, 'staticvar'=> true, 'category'=> true, 'staticVar'=> true, - 'static'=> true, 'var'=> true, 'throws'=> true, 'inheritdoc'=> true, - 'inheritDoc'=> true, 'license'=> true, 'todo'=> true, - 'deprec'=> true, 'property' => true, 'method' => true, - 'abstract'=> true, 'exception'=> true, 'magic' => true, 'api' => true, - 'final'=> true, 'filesource'=> true, 'throw' => true, 'uses' => true, - 'usedby'=> true, 'private' => true, 'Annotation' => true, 'override' => true, - 'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true, - 'Required' => true, 'Attribute' => true, 'Attributes' => true, - 'Target' => true, 'SuppressWarnings' => true, - 'ingroup' => true, 'code' => true, 'endcode' => true, - 'package_version' => true, - ); - - /** - * Add a new annotation to the globally ignored annotation names with regard to exception handling. - * - * @param string $name - */ - static public function addGlobalIgnoredName($name) - { - self::$globalIgnoredNames[$name] = true; - } - - /** - * Annotations Parser - * - * @var \Doctrine\Common\Annotations\DocParser - */ - private $parser; - - /** - * Annotations Parser used to collect parsing metadata - * - * @var \Doctrine\Common\Annotations\DocParser - */ - private $preParser; - - /** - * PHP Parser used to collect imports. - * - * @var \Doctrine\Common\Annotations\PhpParser - */ - private $phpParser; - - /** - * In-memory cache mechanism to store imported annotations per class. - * - * @var array - */ - private $imports = array(); - - /** - * In-memory cache mechanism to store ignored annotations per class. - * - * @var array - */ - private $ignoredAnnotationNames = array(); - - /** - * Constructor. - * - * Initializes a new AnnotationReader. - */ - public function __construct() - { - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php'); - - $this->parser = new DocParser; - - $this->preParser = new DocParser; - $this->preParser->setImports(self::$globalImports); - $this->preParser->setIgnoreNotImportedAnnotations(true); - - $this->phpParser = new PhpParser; - } - - /** - * Gets the annotations applied to a class. - * - * @param ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * @return array An array of Annotations. - */ - public function getClassAnnotations(ReflectionClass $class) - { - $this->parser->setTarget(Target::TARGET_CLASS); - $this->parser->setImports($this->getImports($class)); - $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); - - return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName()); - } - - /** - * Gets a class annotation. - * - * @param ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. - */ - public function getClassAnnotation(ReflectionClass $class, $annotationName) - { - $annotations = $this->getClassAnnotations($class); - - foreach ($annotations as $annotation) { - if ($annotation instanceof $annotationName) { - return $annotation; - } - } - - return null; - } - - /** - * Gets the annotations applied to a property. - * - * @param ReflectionProperty $property The ReflectionProperty of the property - * from which the annotations should be read. - * @return array An array of Annotations. - */ - public function getPropertyAnnotations(ReflectionProperty $property) - { - $class = $property->getDeclaringClass(); - $context = 'property ' . $class->getName() . "::\$" . $property->getName(); - $this->parser->setTarget(Target::TARGET_PROPERTY); - $this->parser->setImports($this->getImports($class)); - $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); - - return $this->parser->parse($property->getDocComment(), $context); - } - - /** - * Gets a property annotation. - * - * @param ReflectionProperty $property - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. - */ - public function getPropertyAnnotation(ReflectionProperty $property, $annotationName) - { - $annotations = $this->getPropertyAnnotations($property); - - foreach ($annotations as $annotation) { - if ($annotation instanceof $annotationName) { - return $annotation; - } - } - - return null; - } - - /** - * Gets the annotations applied to a method. - * - * @param \ReflectionMethod $method The ReflectionMethod of the method from which - * the annotations should be read. - * - * @return array An array of Annotations. - */ - public function getMethodAnnotations(ReflectionMethod $method) - { - $class = $method->getDeclaringClass(); - $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; - $this->parser->setTarget(Target::TARGET_METHOD); - $this->parser->setImports($this->getImports($class)); - $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); - - return $this->parser->parse($method->getDocComment(), $context); - } - - /** - * Gets a method annotation. - * - * @param ReflectionMethod $method - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. - */ - public function getMethodAnnotation(ReflectionMethod $method, $annotationName) - { - $annotations = $this->getMethodAnnotations($method); - - foreach ($annotations as $annotation) { - if ($annotation instanceof $annotationName) { - return $annotation; - } - } - - return null; - } - - /** - * Returns the ignored annotations for the given class. - * - * @param ReflectionClass $class - * @return array - */ - private function getIgnoredAnnotationNames(ReflectionClass $class) - { - if (isset($this->ignoredAnnotationNames[$name = $class->getName()])) { - return $this->ignoredAnnotationNames[$name]; - } - $this->collectParsingMetadata($class); - - return $this->ignoredAnnotationNames[$name]; - } - - /** - * Retrieve imports - * - * @param \ReflectionClass $class - * @return array - */ - private function getImports(ReflectionClass $class) - { - if (isset($this->imports[$name = $class->getName()])) { - return $this->imports[$name]; - } - $this->collectParsingMetadata($class); - - return $this->imports[$name]; - } - - /** - * Collects parsing metadata for a given class - * - * @param ReflectionClass $class - */ - private function collectParsingMetadata(ReflectionClass $class) - { - $ignoredAnnotationNames = self::$globalIgnoredNames; - - $annotations = $this->preParser->parse($class->getDocComment(), 'class '.$class->name); - foreach ($annotations as $annotation) { - if ($annotation instanceof IgnoreAnnotation) { - foreach ($annotation->names AS $annot) { - $ignoredAnnotationNames[$annot] = true; - } - } - } - - $name = $class->getName(); - $this->imports[$name] = array_merge( - self::$globalImports, - $this->phpParser->parseClass($class), - array('__NAMESPACE__' => $class->getNamespaceName()) - ); - $this->ignoredAnnotationNames[$name] = $ignoredAnnotationNames; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php deleted file mode 100644 index dfa846a..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php +++ /dev/null @@ -1,139 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -/** - * AnnotationRegistry - */ -final class AnnotationRegistry -{ - /** - * A map of namespaces to use for autoloading purposes based on a PSR-0 convention. - * - * Contains the namespace as key and an array of directories as value. If the value is NULL - * the include path is used for checking for the corresponding file. - * - * This autoloading mechanism does not utilize the PHP autoloading but implements autoloading on its own. - * - * @var array - */ - static private $autoloadNamespaces = array(); - - /** - * A map of autoloader callables. - * - * @var array - */ - static private $loaders = array(); - - static public function reset() - { - self::$autoloadNamespaces = array(); - self::$loaders = array(); - } - - /** - * Register file - * - * @param string $file - */ - static public function registerFile($file) - { - require_once $file; - } - - /** - * Add a namespace with one or many directories to look for files or null for the include path. - * - * Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. - * - * @param string $namespace - * @param string|array|null $dirs - */ - static public function registerAutoloadNamespace($namespace, $dirs = null) - { - self::$autoloadNamespaces[$namespace] = $dirs; - } - - /** - * Register multiple namespaces - * - * Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. - * - * @param array $namespaces - */ - static public function registerAutoloadNamespaces(array $namespaces) - { - self::$autoloadNamespaces = array_merge(self::$autoloadNamespaces, $namespaces); - } - - /** - * Register an autoloading callable for annotations, much like spl_autoload_register(). - * - * NOTE: These class loaders HAVE to be silent when a class was not found! - * IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class. - * - * @param callable $callable - * - * @throws \InvalidArgumentException - */ - static public function registerLoader($callable) - { - if (!is_callable($callable)) { - throw new \InvalidArgumentException("A callable is expected in AnnotationRegistry::registerLoader()."); - } - self::$loaders[] = $callable; - } - - /** - * Autoload an annotation class silently. - * - * @param string $class - * @return boolean - */ - static public function loadAnnotationClass($class) - { - foreach (self::$autoloadNamespaces AS $namespace => $dirs) { - if (strpos($class, $namespace) === 0) { - $file = str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php"; - if ($dirs === null) { - if ($path = stream_resolve_include_path($file)) { - require $path; - return true; - } - } else { - foreach((array)$dirs AS $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $file)) { - require $dir . DIRECTORY_SEPARATOR . $file; - return true; - } - } - } - } - } - - foreach (self::$loaders AS $loader) { - if (call_user_func($loader, $class) === true) { - return true; - } - } - return false; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php deleted file mode 100644 index e377e3b..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php +++ /dev/null @@ -1,250 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -use Doctrine\Common\Cache\Cache; - -/** - * A cache aware annotation reader. - * - * @author Johannes M. Schmitt - * @author Benjamin Eberlei - */ -final class CachedReader implements Reader -{ - /** - * @var string - */ - private static $CACHE_SALT = '@[Annot]'; - - /** - * @var Reader - */ - private $delegate; - - /** - * @var Cache - */ - private $cache; - - /** - * @var boolean - */ - private $debug; - - /** - * @var array - */ - private $loadedAnnotations; - - /** - * Constructor - * - * @param Reader $reader - * @param Cache $cache - * @param bool $debug - */ - public function __construct(Reader $reader, Cache $cache, $debug = false) - { - $this->delegate = $reader; - $this->cache = $cache; - $this->debug = (Boolean) $debug; - } - - /** - * Get annotations for class - * - * @param \ReflectionClass $class - * @return array - */ - public function getClassAnnotations(\ReflectionClass $class) - { - $cacheKey = $class->getName(); - - if (isset($this->loadedAnnotations[$cacheKey])) { - return $this->loadedAnnotations[$cacheKey]; - } - - if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) { - $annots = $this->delegate->getClassAnnotations($class); - $this->saveToCache($cacheKey, $annots); - } - - return $this->loadedAnnotations[$cacheKey] = $annots; - } - - /** - * Get selected annotation for class - * - * @param \ReflectionClass $class - * @param string $annotationName - * @return null - */ - public function getClassAnnotation(\ReflectionClass $class, $annotationName) - { - foreach ($this->getClassAnnotations($class) as $annot) { - if ($annot instanceof $annotationName) { - return $annot; - } - } - - return null; - } - - /** - * Get annotations for property - * - * @param \ReflectionProperty $property - * @return array - */ - public function getPropertyAnnotations(\ReflectionProperty $property) - { - $class = $property->getDeclaringClass(); - $cacheKey = $class->getName().'$'.$property->getName(); - - if (isset($this->loadedAnnotations[$cacheKey])) { - return $this->loadedAnnotations[$cacheKey]; - } - - if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) { - $annots = $this->delegate->getPropertyAnnotations($property); - $this->saveToCache($cacheKey, $annots); - } - - return $this->loadedAnnotations[$cacheKey] = $annots; - } - - /** - * Get selected annotation for property - * - * @param \ReflectionProperty $property - * @param string $annotationName - * @return null - */ - public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) - { - foreach ($this->getPropertyAnnotations($property) as $annot) { - if ($annot instanceof $annotationName) { - return $annot; - } - } - - return null; - } - - /** - * Get method annotations - * - * @param \ReflectionMethod $method - * @return array - */ - public function getMethodAnnotations(\ReflectionMethod $method) - { - $class = $method->getDeclaringClass(); - $cacheKey = $class->getName().'#'.$method->getName(); - - if (isset($this->loadedAnnotations[$cacheKey])) { - return $this->loadedAnnotations[$cacheKey]; - } - - if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) { - $annots = $this->delegate->getMethodAnnotations($method); - $this->saveToCache($cacheKey, $annots); - } - - return $this->loadedAnnotations[$cacheKey] = $annots; - } - - /** - * Get selected method annotation - * - * @param \ReflectionMethod $method - * @param string $annotationName - * @return null - */ - public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) - { - foreach ($this->getMethodAnnotations($method) as $annot) { - if ($annot instanceof $annotationName) { - return $annot; - } - } - - return null; - } - - /** - * Clear loaded annotations - */ - public function clearLoadedAnnotations() - { - $this->loadedAnnotations = array(); - } - - /** - * Fetches a value from the cache. - * - * @param string $rawCacheKey The cache key. - * @param \ReflectionClass $class The related class. - * @return mixed|boolean The cached value or false when the value is not in cache. - */ - private function fetchFromCache($rawCacheKey, \ReflectionClass $class) - { - $cacheKey = $rawCacheKey . self::$CACHE_SALT; - if (($data = $this->cache->fetch($cacheKey)) !== false) { - if (!$this->debug || $this->isCacheFresh($cacheKey, $class)) { - return $data; - } - } - - return false; - } - - /** - * Saves a value to the cache - * - * @param string $rawCacheKey The cache key. - * @param mixed $value The value. - */ - private function saveToCache($rawCacheKey, $value) - { - $cacheKey = $rawCacheKey . self::$CACHE_SALT; - $this->cache->save($cacheKey, $value); - if ($this->debug) { - $this->cache->save('[C]'.$cacheKey, time()); - } - } - - /** - * Check if cache is fresh - * - * @param string $cacheKey - * @param \ReflectionClass $class - * @return bool - */ - private function isCacheFresh($cacheKey, \ReflectionClass $class) - { - if (false === $filename = $class->getFilename()) { - return true; - } - - return $this->cache->fetch('[C]'.$cacheKey) >= filemtime($filename); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php deleted file mode 100644 index c9a6f7a..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocLexer.php +++ /dev/null @@ -1,132 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -use Doctrine\Common\Lexer; - -/** - * Simple lexer for docblock annotations. - * - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Johannes M. Schmitt - */ -final class DocLexer extends Lexer -{ - const T_NONE = 1; - const T_INTEGER = 2; - const T_STRING = 3; - const T_FLOAT = 4; - - // All tokens that are also identifiers should be >= 100 - const T_IDENTIFIER = 100; - const T_AT = 101; - const T_CLOSE_CURLY_BRACES = 102; - const T_CLOSE_PARENTHESIS = 103; - const T_COMMA = 104; - const T_EQUALS = 105; - const T_FALSE = 106; - const T_NAMESPACE_SEPARATOR = 107; - const T_OPEN_CURLY_BRACES = 108; - const T_OPEN_PARENTHESIS = 109; - const T_TRUE = 110; - const T_NULL = 111; - const T_COLON = 112; - - protected $noCase = array( - '@' => self::T_AT, - ',' => self::T_COMMA, - '(' => self::T_OPEN_PARENTHESIS, - ')' => self::T_CLOSE_PARENTHESIS, - '{' => self::T_OPEN_CURLY_BRACES, - '}' => self::T_CLOSE_CURLY_BRACES, - '=' => self::T_EQUALS, - ':' => self::T_COLON, - '\\' => self::T_NAMESPACE_SEPARATOR - ); - - protected $withCase = array( - 'true' => self::T_TRUE, - 'false' => self::T_FALSE, - 'null' => self::T_NULL - ); - - /** - * {@inheritdoc} - */ - protected function getCatchablePatterns() - { - return array( - '[a-z_\\\][a-z0-9_\:\\\]*[a-z]{1}', - '(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?', - '"(?:[^"]|"")*"', - ); - } - - /** - * {@inheritdoc} - */ - protected function getNonCatchablePatterns() - { - return array('\s+', '\*+', '(.)'); - } - - /** - * {@inheritdoc} - * - * @param string $value - * - * @return int - */ - protected function getType(&$value) - { - $type = self::T_NONE; - - if ($value[0] === '"') { - $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2)); - - return self::T_STRING; - } - - if (isset($this->noCase[$value])) { - return $this->noCase[$value]; - } - - if ($value[0] === '_' || $value[0] === '\\' || ctype_alpha($value[0])) { - return self::T_IDENTIFIER; - } - - $lowerValue = strtolower($value); - - if (isset($this->withCase[$lowerValue])) { - return $this->withCase[$lowerValue]; - } - - // Checking numeric value - if (is_numeric($value)) { - return (strpos($value, '.') !== false || stripos($value, 'e') !== false) - ? self::T_FLOAT : self::T_INTEGER; - } - - return $type; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php deleted file mode 100644 index de31e0b..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php +++ /dev/null @@ -1,988 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -use Closure; -use ReflectionClass; -use Doctrine\Common\Annotations\Annotation\Target; -use Doctrine\Common\Annotations\Annotation\Attribute; -use Doctrine\Common\Annotations\Annotation\Attributes; - -/** - * A parser for docblock annotations. - * - * It is strongly discouraged to change the default annotation parsing process. - * - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Johannes M. Schmitt - * @author Fabio B. Silva - */ -final class DocParser -{ - /** - * An array of all valid tokens for a class name. - * - * @var array - */ - private static $classIdentifiers = array(DocLexer::T_IDENTIFIER, DocLexer::T_TRUE, DocLexer::T_FALSE, DocLexer::T_NULL); - - /** - * The lexer. - * - * @var \Doctrine\Common\Annotations\DocLexer - */ - private $lexer; - - /** - * Current target context - * - * @var string - */ - private $target; - - /** - * Doc Parser used to collect annotation target - * - * @var \Doctrine\Common\Annotations\DocParser - */ - private static $metadataParser; - - /** - * Flag to control if the current annotation is nested or not. - * - * @var boolean - */ - private $isNestedAnnotation = false; - - /** - * Hashmap containing all use-statements that are to be used when parsing - * the given doc block. - * - * @var array - */ - private $imports = array(); - - /** - * This hashmap is used internally to cache results of class_exists() - * look-ups. - * - * @var array - */ - private $classExists = array(); - - /** - * Whether annotations that have not been imported should be ignored. - * - * @var boolean - */ - private $ignoreNotImportedAnnotations = false; - - /** - * An array of default namespaces if operating in simple mode. - * - * @var array - */ - private $namespaces = array(); - - /** - * A list with annotations that are not causing exceptions when not resolved to an annotation class. - * - * The names must be the raw names as used in the class, not the fully qualified - * class names. - * - * @var array - */ - private $ignoredAnnotationNames = array(); - - /** - * @var string - */ - private $context = ''; - - /** - * Hash-map for caching annotation metadata - * @var array - */ - private static $annotationMetadata = array( - 'Doctrine\Common\Annotations\Annotation\Target' => array( - 'is_annotation' => true, - 'has_constructor' => true, - 'properties' => array(), - 'targets_literal' => 'ANNOTATION_CLASS', - 'targets' => Target::TARGET_CLASS, - 'default_property' => 'value', - 'attribute_types' => array( - 'value' => array( - 'required' => false, - 'type' =>'array', - 'array_type'=>'string', - 'value' =>'array' - ) - ), - ), - 'Doctrine\Common\Annotations\Annotation\Attribute' => array( - 'is_annotation' => true, - 'has_constructor' => false, - 'targets_literal' => 'ANNOTATION_ANNOTATION', - 'targets' => Target::TARGET_ANNOTATION, - 'default_property' => 'name', - 'properties' => array( - 'name' => 'name', - 'type' => 'type', - 'required' => 'required' - ), - 'attribute_types' => array( - 'value' => array( - 'required' => true, - 'type' =>'string', - 'value' =>'string' - ), - 'type' => array( - 'required' =>true, - 'type' =>'string', - 'value' =>'string' - ), - 'required' => array( - 'required' =>false, - 'type' =>'boolean', - 'value' =>'boolean' - ) - ), - ), - 'Doctrine\Common\Annotations\Annotation\Attributes' => array( - 'is_annotation' => true, - 'has_constructor' => false, - 'targets_literal' => 'ANNOTATION_CLASS', - 'targets' => Target::TARGET_CLASS, - 'default_property' => 'value', - 'properties' => array( - 'value' => 'value' - ), - 'attribute_types' => array( - 'value' => array( - 'type' =>'array', - 'required' =>true, - 'array_type'=>'Doctrine\Common\Annotations\Annotation\Attribute', - 'value' =>'array' - ) - ), - ), - ); - - /** - * Hash-map for handle types declaration - * - * @var array - */ - private static $typeMap = array( - 'float' => 'double', - 'bool' => 'boolean', - // allow uppercase Boolean in honor of George Boole - 'Boolean' => 'boolean', - 'int' => 'integer', - ); - - /** - * Constructs a new DocParser. - */ - public function __construct() - { - $this->lexer = new DocLexer; - } - - /** - * Sets the annotation names that are ignored during the parsing process. - * - * The names are supposed to be the raw names as used in the class, not the - * fully qualified class names. - * - * @param array $names - */ - public function setIgnoredAnnotationNames(array $names) - { - $this->ignoredAnnotationNames = $names; - } - - /** - * Sets ignore on not-imported annotations - * - * @param $bool - */ - public function setIgnoreNotImportedAnnotations($bool) - { - $this->ignoreNotImportedAnnotations = (Boolean) $bool; - } - - /** - * Sets the default namespaces. - * - * @param array $namespace - * - * @throws \RuntimeException - */ - public function addNamespace($namespace) - { - if ($this->imports) { - throw new \RuntimeException('You must either use addNamespace(), or setImports(), but not both.'); - } - $this->namespaces[] = $namespace; - } - - /** - * Sets the imports - * - * @param array $imports - * @throws \RuntimeException - */ - public function setImports(array $imports) - { - if ($this->namespaces) { - throw new \RuntimeException('You must either use addNamespace(), or setImports(), but not both.'); - } - $this->imports = $imports; - } - - /** - * Sets current target context as bitmask. - * - * @param integer $target - */ - public function setTarget($target) - { - $this->target = $target; - } - - /** - * Parses the given docblock string for annotations. - * - * @param string $input The docblock string to parse. - * @param string $context The parsing context. - * @return array Array of annotations. If no annotations are found, an empty array is returned. - */ - public function parse($input, $context = '') - { - if (false === $pos = strpos($input, '@')) { - return array(); - } - - // also parse whatever character is before the @ - if ($pos > 0) { - $pos -= 1; - } - - $this->context = $context; - $this->lexer->setInput(trim(substr($input, $pos), '* /')); - $this->lexer->moveNext(); - - return $this->Annotations(); - } - - /** - * Attempts to match the given token with the current lookahead token. - * If they match, updates the lookahead token; otherwise raises a syntax error. - * - * @param int $token type of Token. - * @return bool True if tokens match; false otherwise. - */ - private function match($token) - { - if ( ! $this->lexer->isNextToken($token) ) { - $this->syntaxError($this->lexer->getLiteral($token)); - } - - return $this->lexer->moveNext(); - } - - /** - * Attempts to match the current lookahead token with any of the given tokens. - * - * If any of them matches, this method updates the lookahead token; otherwise - * a syntax error is raised. - * - * @param array $tokens - * @return bool - */ - private function matchAny(array $tokens) - { - if ( ! $this->lexer->isNextTokenAny($tokens)) { - $this->syntaxError(implode(' or ', array_map(array($this->lexer, 'getLiteral'), $tokens))); - } - - return $this->lexer->moveNext(); - } - - /** - * Generates a new syntax error. - * - * @param string $expected Expected string. - * @param array $token Optional token. - * - * @throws AnnotationException - */ - private function syntaxError($expected, $token = null) - { - if ($token === null) { - $token = $this->lexer->lookahead; - } - - $message = "Expected {$expected}, got "; - - if ($this->lexer->lookahead === null) { - $message .= 'end of string'; - } else { - $message .= "'{$token['value']}' at position {$token['position']}"; - } - - if (strlen($this->context)) { - $message .= ' in ' . $this->context; - } - - $message .= '.'; - - throw AnnotationException::syntaxError($message); - } - - /** - * Attempt to check if a class exists or not. This never goes through the PHP autoloading mechanism - * but uses the {@link AnnotationRegistry} to load classes. - * - * @param string $fqcn - * @return boolean - */ - private function classExists($fqcn) - { - if (isset($this->classExists[$fqcn])) { - return $this->classExists[$fqcn]; - } - - // first check if the class already exists, maybe loaded through another AnnotationReader - if (class_exists($fqcn, false)) { - return $this->classExists[$fqcn] = true; - } - - // final check, does this class exist? - return $this->classExists[$fqcn] = AnnotationRegistry::loadAnnotationClass($fqcn); - } - - /** - * Collects parsing metadata for a given annotation class - * - * @param string $name The annotation name - */ - private function collectAnnotationMetadata($name) - { - if (self::$metadataParser == null){ - self::$metadataParser = new self(); - self::$metadataParser->setTarget(Target::TARGET_CLASS); - self::$metadataParser->setIgnoreNotImportedAnnotations(true); - self::$metadataParser->setImports(array( - 'target' => 'Doctrine\Common\Annotations\Annotation\Target', - 'attribute' => 'Doctrine\Common\Annotations\Annotation\Attribute', - 'attributes' => 'Doctrine\Common\Annotations\Annotation\Attributes' - )); - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Target.php'); - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attribute.php'); - AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attributes.php'); - } - - $class = new \ReflectionClass($name); - $docComment = $class->getDocComment(); - - // Sets default values for annotation metadata - $metadata = array( - 'default_property' => null, - 'has_constructor' => (null !== $constructor = $class->getConstructor()) && $constructor->getNumberOfParameters() > 0, - 'properties' => array(), - 'property_types' => array(), - 'attribute_types' => array(), - 'targets_literal' => null, - 'targets' => Target::TARGET_ALL, - 'is_annotation' => false !== strpos($docComment, '@Annotation'), - ); - - // verify that the class is really meant to be an annotation - if ($metadata['is_annotation']) { - foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { - if ($annotation instanceof Target) { - $metadata['targets'] = $annotation->targets; - $metadata['targets_literal'] = $annotation->literal; - - } elseif ($annotation instanceof Attributes) { - foreach ($annotation->value as $attrib) { - // handle internal type declaration - $type = isset(self::$typeMap[$attrib->type]) ? self::$typeMap[$attrib->type] : $attrib->type; - - // handle the case if the property type is mixed - if ('mixed' !== $type) { - // Checks if the property has array - if (false !== $pos = strpos($type, '<')) { - $arrayType = substr($type, $pos+1, -1); - $type = 'array'; - - if (isset(self::$typeMap[$arrayType])) { - $arrayType = self::$typeMap[$arrayType]; - } - - $metadata['attribute_types'][$attrib->name]['array_type'] = $arrayType; - } - - $metadata['attribute_types'][$attrib->name]['type'] = $type; - $metadata['attribute_types'][$attrib->name]['value'] = $attrib->type; - $metadata['attribute_types'][$attrib->name]['required'] = $attrib->required; - } - } - } - } - - // if not has a constructor will inject values into public properties - if (false === $metadata['has_constructor']) { - // collect all public properties - foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { - $metadata['properties'][$property->name] = $property->name; - - // checks if the property has @var annotation - if ((false !== $propertyComment = $property->getDocComment()) - && false !== strpos($propertyComment, '@var') - && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) { - // literal type declaration - $value = $matches[1]; - - // handle internal type declaration - $type = isset(self::$typeMap[$value]) ? self::$typeMap[$value] : $value; - - // handle the case if the property type is mixed - if ('mixed' !== $type) { - // Checks if the property has @var array annotation - if (false !== $pos = strpos($type, '<')) { - $arrayType = substr($type, $pos+1, -1); - $type = 'array'; - - if (isset(self::$typeMap[$arrayType])) { - $arrayType = self::$typeMap[$arrayType]; - } - - $metadata['attribute_types'][$property->name]['array_type'] = $arrayType; - } - - $metadata['attribute_types'][$property->name]['type'] = $type; - $metadata['attribute_types'][$property->name]['value'] = $value; - $metadata['attribute_types'][$property->name]['required'] = false !== strpos($propertyComment, '@Required'); - } - } - } - - // choose the first property as default property - $metadata['default_property'] = reset($metadata['properties']); - } - } - - self::$annotationMetadata[$name] = $metadata; - } - - /** - * Annotations ::= Annotation {[ "*" ]* [Annotation]}* - * - * @return array - */ - private function Annotations() - { - $annotations = array(); - - while (null !== $this->lexer->lookahead) { - if (DocLexer::T_AT !== $this->lexer->lookahead['type']) { - $this->lexer->moveNext(); - continue; - } - - // make sure the @ is preceded by non-catchable pattern - if (null !== $this->lexer->token && $this->lexer->lookahead['position'] === $this->lexer->token['position'] + strlen($this->lexer->token['value'])) { - $this->lexer->moveNext(); - continue; - } - - // make sure the @ is followed by either a namespace separator, or - // an identifier token - if ((null === $peek = $this->lexer->glimpse()) - || (DocLexer::T_NAMESPACE_SEPARATOR !== $peek['type'] && !in_array($peek['type'], self::$classIdentifiers, true)) - || $peek['position'] !== $this->lexer->lookahead['position'] + 1) { - $this->lexer->moveNext(); - continue; - } - - $this->isNestedAnnotation = false; - if (false !== $annot = $this->Annotation()) { - $annotations[] = $annot; - } - } - - return $annotations; - } - - /** - * Annotation ::= "@" AnnotationName ["(" [Values] ")"] - * AnnotationName ::= QualifiedName | SimpleName - * QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName - * NameSpacePart ::= identifier | null | false | true - * SimpleName ::= identifier | null | false | true - * - * @throws AnnotationException - * @return mixed False if it is not a valid annotation. - */ - private function Annotation() - { - $this->match(DocLexer::T_AT); - - // check if we have an annotation - $name = $this->Identifier(); - - // only process names which are not fully qualified, yet - // fully qualified names must start with a \ - $originalName = $name; - if ('\\' !== $name[0]) { - $alias = (false === $pos = strpos($name, '\\'))? $name : substr($name, 0, $pos); - - $found = false; - if ($this->namespaces) { - foreach ($this->namespaces as $namespace) { - if ($this->classExists($namespace.'\\'.$name)) { - $name = $namespace.'\\'.$name; - $found = true; - break; - } - } - } elseif (isset($this->imports[$loweredAlias = strtolower($alias)])) { - if (false !== $pos) { - $name = $this->imports[$loweredAlias].substr($name, $pos); - } else { - $name = $this->imports[$loweredAlias]; - } - $found = true; - } elseif (isset($this->imports['__NAMESPACE__']) && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name)) { - $name = $this->imports['__NAMESPACE__'].'\\'.$name; - $found = true; - } elseif ($this->classExists($name)) { - $found = true; - } - - if (!$found) { - if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$name])) { - return false; - } - - throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s was never imported. Did you maybe forget to add a "use" statement for this annotation?', $name, $this->context)); - } - } - - if (!$this->classExists($name)) { - throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); - } - - // at this point, $name contains the fully qualified class name of the - // annotation, and it is also guaranteed that this class exists, and - // that it is loaded - - - // collects the metadata annotation only if there is not yet - if (!isset(self::$annotationMetadata[$name])) { - $this->collectAnnotationMetadata($name); - } - - // verify that the class is really meant to be an annotation and not just any ordinary class - if (self::$annotationMetadata[$name]['is_annotation'] === false) { - if (isset($this->ignoredAnnotationNames[$originalName])) { - return false; - } - - throw AnnotationException::semanticalError(sprintf('The class "%s" 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 "%s". If it is indeed no annotation, then you need to add @IgnoreAnnotation("%s") to the _class_ doc comment of %s.', $name, $name, $originalName, $this->context)); - } - - //if target is nested annotation - $target = $this->isNestedAnnotation ? Target::TARGET_ANNOTATION : $this->target; - - // Next will be nested - $this->isNestedAnnotation = true; - - //if annotation does not support current target - if (0 === (self::$annotationMetadata[$name]['targets'] & $target) && $target) { - throw AnnotationException::semanticalError( - sprintf('Annotation @%s is not allowed to be declared on %s. You may only use this annotation on these code elements: %s.', - $originalName, $this->context, self::$annotationMetadata[$name]['targets_literal']) - ); - } - - $values = array(); - if ($this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { - $this->match(DocLexer::T_OPEN_PARENTHESIS); - - if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { - $values = $this->Values(); - } - - $this->match(DocLexer::T_CLOSE_PARENTHESIS); - } - - // checks all declared attributes - foreach (self::$annotationMetadata[$name]['attribute_types'] as $property => $type) { - if ($property === self::$annotationMetadata[$name]['default_property'] - && !isset($values[$property]) && isset($values['value'])) { - $property = 'value'; - } - - // handle a not given attribute or null value - if (!isset($values[$property])) { - if ($type['required']) { - throw AnnotationException::requiredError($property, $originalName, $this->context, 'a(n) '.$type['value']); - } - - continue; - } - - if ($type['type'] === 'array') { - // handle the case of a single value - if (!is_array($values[$property])) { - $values[$property] = array($values[$property]); - } - - // checks if the attribute has array type declaration, such as "array" - if (isset($type['array_type'])) { - foreach ($values[$property] as $item) { - if (gettype($item) !== $type['array_type'] && !$item instanceof $type['array_type']) { - throw AnnotationException::typeError($property, $originalName, $this->context, 'either a(n) '.$type['array_type'].', or an array of '.$type['array_type'].'s', $item); - } - } - } - } elseif (gettype($values[$property]) !== $type['type'] && !$values[$property] instanceof $type['type']) { - throw AnnotationException::typeError($property, $originalName, $this->context, 'a(n) '.$type['value'], $values[$property]); - } - } - - // check if the annotation expects values via the constructor, - // or directly injected into public properties - if (self::$annotationMetadata[$name]['has_constructor'] === true) { - return new $name($values); - } - - $instance = new $name(); - foreach ($values as $property => $value) { - if (!isset(self::$annotationMetadata[$name]['properties'][$property])) { - if ('value' !== $property) { - throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not have a property named "%s". Available properties: %s', $originalName, $this->context, $property, implode(', ', self::$annotationMetadata[$name]['properties']))); - } - - // handle the case if the property has no annotations - if (!$property = self::$annotationMetadata[$name]['default_property']) { - throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not accept any values, but got %s.', $originalName, $this->context, json_encode($values))); - } - } - - $instance->{$property} = $value; - } - - return $instance; - } - - /** - * Values ::= Array | Value {"," Value}* - * - * @return array - */ - private function Values() - { - $values = array(); - - // Handle the case of a single array as value, i.e. @Foo({....}) - if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) { - $values['value'] = $this->Value(); - return $values; - } - - $values[] = $this->Value(); - - while ($this->lexer->isNextToken(DocLexer::T_COMMA)) { - $this->match(DocLexer::T_COMMA); - $token = $this->lexer->lookahead; - $value = $this->Value(); - - if ( ! is_object($value) && ! is_array($value)) { - $this->syntaxError('Value', $token); - } - - $values[] = $value; - } - - foreach ($values as $k => $value) { - if (is_object($value) && $value instanceof \stdClass) { - $values[$value->name] = $value->value; - } else if ( ! isset($values['value'])){ - $values['value'] = $value; - } else { - if ( ! is_array($values['value'])) { - $values['value'] = array($values['value']); - } - - $values['value'][] = $value; - } - - unset($values[$k]); - } - - return $values; - } - - /** - * Constant ::= integer | string | float | boolean - * - * @throws AnnotationException - * @return mixed - */ - private function Constant() - { - $identifier = $this->Identifier(); - - if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { - - list($className, $const) = explode('::', $identifier); - $alias = (false === $pos = strpos($className, '\\'))? $className : substr($className, 0, $pos); - - $found = false; - switch (true) { - case !empty ($this->namespaces): - foreach ($this->namespaces as $ns) { - if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { - $className = $ns.'\\'.$className; - $found = true; - break; - } - } - break; - - case isset($this->imports[$loweredAlias = strtolower($alias)]): - $found = true; - if (false !== $pos) { - $className = $this->imports[$loweredAlias].substr($className, $pos); - } else { - $className = $this->imports[$loweredAlias]; - } - break; - - default: - if(isset($this->imports['__NAMESPACE__'])) { - $ns = $this->imports['__NAMESPACE__']; - if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { - $className = $ns.'\\'.$className; - $found = true; - } - } - break; - } - - if ($found) { - $identifier = $className . '::' . $const; - } - } - - if (!defined($identifier)) { - throw AnnotationException::semanticalErrorConstants($identifier, $this->context); - } - - return constant($identifier); - } - - /** - * Identifier ::= string - * - * @return string - */ - private function Identifier() - { - // check if we have an annotation - if ($this->lexer->isNextTokenAny(self::$classIdentifiers)) { - $this->lexer->moveNext(); - $className = $this->lexer->token['value']; - } else { - $this->syntaxError('namespace separator or identifier'); - } - - while ($this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value'])) - && $this->lexer->isNextToken(DocLexer::T_NAMESPACE_SEPARATOR)) { - - $this->match(DocLexer::T_NAMESPACE_SEPARATOR); - $this->matchAny(self::$classIdentifiers); - $className .= '\\' . $this->lexer->token['value']; - } - - return $className; - } - - /** - * Value ::= PlainValue | FieldAssignment - * - * @return mixed - */ - private function Value() - { - $peek = $this->lexer->glimpse(); - - if (DocLexer::T_EQUALS === $peek['type']) { - return $this->FieldAssignment(); - } - - return $this->PlainValue(); - } - - /** - * PlainValue ::= integer | string | float | boolean | Array | Annotation - * - * @return mixed - */ - private function PlainValue() - { - if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) { - return $this->Arrayx(); - } - - if ($this->lexer->isNextToken(DocLexer::T_AT)) { - return $this->Annotation(); - } - - if ($this->lexer->isNextToken(DocLexer::T_IDENTIFIER)) { - return $this->Constant(); - } - - switch ($this->lexer->lookahead['type']) { - case DocLexer::T_STRING: - $this->match(DocLexer::T_STRING); - return $this->lexer->token['value']; - - case DocLexer::T_INTEGER: - $this->match(DocLexer::T_INTEGER); - return (int)$this->lexer->token['value']; - - case DocLexer::T_FLOAT: - $this->match(DocLexer::T_FLOAT); - return (float)$this->lexer->token['value']; - - case DocLexer::T_TRUE: - $this->match(DocLexer::T_TRUE); - return true; - - case DocLexer::T_FALSE: - $this->match(DocLexer::T_FALSE); - return false; - - case DocLexer::T_NULL: - $this->match(DocLexer::T_NULL); - return null; - - default: - $this->syntaxError('PlainValue'); - } - } - - /** - * FieldAssignment ::= FieldName "=" PlainValue - * FieldName ::= identifier - * - * @return array - */ - private function FieldAssignment() - { - $this->match(DocLexer::T_IDENTIFIER); - $fieldName = $this->lexer->token['value']; - - $this->match(DocLexer::T_EQUALS); - - $item = new \stdClass(); - $item->name = $fieldName; - $item->value = $this->PlainValue(); - - return $item; - } - - /** - * Array ::= "{" ArrayEntry {"," ArrayEntry}* [","] "}" - * - * @return array - */ - private function Arrayx() - { - $array = $values = array(); - - $this->match(DocLexer::T_OPEN_CURLY_BRACES); - $values[] = $this->ArrayEntry(); - - while ($this->lexer->isNextToken(DocLexer::T_COMMA)) { - $this->match(DocLexer::T_COMMA); - - // optional trailing comma - if ($this->lexer->isNextToken(DocLexer::T_CLOSE_CURLY_BRACES)) { - break; - } - - $values[] = $this->ArrayEntry(); - } - - $this->match(DocLexer::T_CLOSE_CURLY_BRACES); - - foreach ($values as $value) { - list ($key, $val) = $value; - - if ($key !== null) { - $array[$key] = $val; - } else { - $array[] = $val; - } - } - - return $array; - } - - /** - * ArrayEntry ::= Value | KeyValuePair - * KeyValuePair ::= Key ("=" | ":") PlainValue | Constant - * Key ::= string | integer | Constant - * - * @return array - */ - private function ArrayEntry() - { - $peek = $this->lexer->glimpse(); - - if (DocLexer::T_EQUALS === $peek['type'] - || DocLexer::T_COLON === $peek['type']) { - - if ($this->lexer->isNextToken(DocLexer::T_IDENTIFIER)) { - $key = $this->Constant(); - } else { - $this->matchAny(array(DocLexer::T_INTEGER, DocLexer::T_STRING)); - $key = $this->lexer->token['value']; - } - - $this->matchAny(array(DocLexer::T_EQUALS, DocLexer::T_COLON)); - - return array($key, $this->PlainValue()); - } - - return array(null, $this->Value()); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/FileCacheReader.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/FileCacheReader.php deleted file mode 100644 index 3934861..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/FileCacheReader.php +++ /dev/null @@ -1,258 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - - -/** - * File cache reader for annotations. - * - * @author Johannes M. Schmitt - * @author Benjamin Eberlei - */ -class FileCacheReader implements Reader -{ - /** - * @var Reader - */ - private $reader; - - /** - * @var string - */ - private $dir; - - /** - * @var bool - */ - private $debug; - - /** - * @var array - */ - private $loadedAnnotations = array(); - - /** - * Constructor - * - * @param Reader $reader - * @param string $cacheDir - * @param bool $debug - * - * @throws \InvalidArgumentException - */ - public function __construct(Reader $reader, $cacheDir, $debug = false) - { - $this->reader = $reader; - if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true)) { - throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $cacheDir)); - } - if (!is_writable($cacheDir)) { - 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.', $cacheDir)); - } - - $this->dir = rtrim($cacheDir, '\\/'); - $this->debug = $debug; - } - - /** - * Retrieve annotations for class - * - * @param \ReflectionClass $class - * @return array - */ - public function getClassAnnotations(\ReflectionClass $class) - { - $key = $class->getName(); - - if (isset($this->loadedAnnotations[$key])) { - return $this->loadedAnnotations[$key]; - } - - $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; - if (!file_exists($path)) { - $annot = $this->reader->getClassAnnotations($class); - $this->saveCacheFile($path, $annot); - return $this->loadedAnnotations[$key] = $annot; - } - - if ($this->debug - && (false !== $filename = $class->getFilename()) - && filemtime($path) < filemtime($filename)) { - @unlink($path); - - $annot = $this->reader->getClassAnnotations($class); - $this->saveCacheFile($path, $annot); - return $this->loadedAnnotations[$key] = $annot; - } - - return $this->loadedAnnotations[$key] = include $path; - } - - /** - * Get annotations for property - * - * @param \ReflectionProperty $property - * @return array - */ - public function getPropertyAnnotations(\ReflectionProperty $property) - { - $class = $property->getDeclaringClass(); - $key = $class->getName().'$'.$property->getName(); - - if (isset($this->loadedAnnotations[$key])) { - return $this->loadedAnnotations[$key]; - } - - $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; - if (!file_exists($path)) { - $annot = $this->reader->getPropertyAnnotations($property); - $this->saveCacheFile($path, $annot); - return $this->loadedAnnotations[$key] = $annot; - } - - if ($this->debug - && (false !== $filename = $class->getFilename()) - && filemtime($path) < filemtime($filename)) { - unlink($path); - - $annot = $this->reader->getPropertyAnnotations($property); - $this->saveCacheFile($path, $annot); - return $this->loadedAnnotations[$key] = $annot; - } - - return $this->loadedAnnotations[$key] = include $path; - } - - /** - * Retrieve annotations for method - * - * @param \ReflectionMethod $method - * @return array - */ - public function getMethodAnnotations(\ReflectionMethod $method) - { - $class = $method->getDeclaringClass(); - $key = $class->getName().'#'.$method->getName(); - - if (isset($this->loadedAnnotations[$key])) { - return $this->loadedAnnotations[$key]; - } - - $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; - if (!file_exists($path)) { - $annot = $this->reader->getMethodAnnotations($method); - $this->saveCacheFile($path, $annot); - return $this->loadedAnnotations[$key] = $annot; - } - - if ($this->debug - && (false !== $filename = $class->getFilename()) - && filemtime($path) < filemtime($filename)) { - unlink($path); - - $annot = $this->reader->getMethodAnnotations($method); - $this->saveCacheFile($path, $annot); - return $this->loadedAnnotations[$key] = $annot; - } - - return $this->loadedAnnotations[$key] = include $path; - } - - /** - * Save cache file - * - * @param string $path - * @param mixed $data - */ - private function saveCacheFile($path, $data) - { - file_put_contents($path, 'getClassAnnotations($class); - - foreach ($annotations as $annotation) { - if ($annotation instanceof $annotationName) { - return $annotation; - } - } - - return null; - } - - /** - * Gets a method annotation. - * - * @param \ReflectionMethod $method - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. - */ - public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) - { - $annotations = $this->getMethodAnnotations($method); - - foreach ($annotations as $annotation) { - if ($annotation instanceof $annotationName) { - return $annotation; - } - } - - return null; - } - - /** - * Gets a property annotation. - * - * @param \ReflectionProperty $property - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. - */ - public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) - { - $annotations = $this->getPropertyAnnotations($property); - - foreach ($annotations as $annotation) { - if ($annotation instanceof $annotationName) { - return $annotation; - } - } - - return null; - } - - /** - * Clear stores annotations - */ - public function clearLoadedAnnotations() - { - $this->loadedAnnotations = array(); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/IndexedReader.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/IndexedReader.php deleted file mode 100644 index 2dfdd4d..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/IndexedReader.php +++ /dev/null @@ -1,141 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -use Doctrine\Common\Annotations\Reader; - -/** - * Allows the reader to be used in-place of Doctrine's reader. - * - * @author Johannes M. Schmitt - */ -class IndexedReader implements Reader -{ - /** - * @var Reader - */ - private $delegate; - - /** - * Constructor - * - * @param Reader $reader - */ - public function __construct(Reader $reader) - { - $this->delegate = $reader; - } - - /** - * Get Annotations for class - * - * @param \ReflectionClass $class - * @return array - */ - public function getClassAnnotations(\ReflectionClass $class) - { - $annotations = array(); - foreach ($this->delegate->getClassAnnotations($class) as $annot) { - $annotations[get_class($annot)] = $annot; - } - - return $annotations; - } - - /** - * Get selected annotation for class - * - * @param \ReflectionClass $class - * @param string $annotation - * @return mixed - */ - public function getClassAnnotation(\ReflectionClass $class, $annotation) - { - return $this->delegate->getClassAnnotation($class, $annotation); - } - - /** - * Get Annotations for method - * - * @param \ReflectionMethod $method - * @return array - */ - public function getMethodAnnotations(\ReflectionMethod $method) - { - $annotations = array(); - foreach ($this->delegate->getMethodAnnotations($method) as $annot) { - $annotations[get_class($annot)] = $annot; - } - - return $annotations; - } - - /** - * Get selected annotation for method - * - * @param \ReflectionMethod $method - * @param string $annotation - * @return mixed - */ - public function getMethodAnnotation(\ReflectionMethod $method, $annotation) - { - return $this->delegate->getMethodAnnotation($method, $annotation); - } - - /** - * Get annotations for property - * - * @param \ReflectionProperty $property - * @return array - */ - public function getPropertyAnnotations(\ReflectionProperty $property) - { - $annotations = array(); - foreach ($this->delegate->getPropertyAnnotations($property) as $annot) { - $annotations[get_class($annot)] = $annot; - } - - return $annotations; - } - - /** - * Get selected annotation for property - * - * @param \ReflectionProperty $property - * @param string $annotation - * @return mixed - */ - public function getPropertyAnnotation(\ReflectionProperty $property, $annotation) - { - return $this->delegate->getPropertyAnnotation($property, $annotation); - } - - /** - * Proxy all methods to the delegate. - * - * @param string $method - * @param array $args - * @return mixed - */ - public function __call($method, $args) - { - return call_user_func_array(array($this->delegate, $method), $args); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/PhpParser.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/PhpParser.php deleted file mode 100644 index c09dd51..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/PhpParser.php +++ /dev/null @@ -1,80 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -use SplFileObject; - -/** - * Parses a file for namespaces/use/class declarations. - * - * @author Fabien Potencier - * @author Christian Kaps - */ -final class PhpParser -{ - /** - * Parses a class. - * - * @param \ReflectionClass $class A ReflectionClass object. - * @return array A list with use statements in the form (Alias => FQN). - */ - public function parseClass(\ReflectionClass $class) - { - if (method_exists($class, 'getUseStatements')) { - return $class->getUseStatements(); - } - - if (false === $filename = $class->getFilename()) { - return array(); - } - - $content = $this->getFileContent($filename, $class->getStartLine()); - $namespace = str_replace('\\', '\\\\', $class->getNamespaceName()); - $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content); - $tokenizer = new TokenParser('parseUseStatements($class->getNamespaceName()); - - return $statements; - } - - /** - * Get the content of the file right up to the given line number. - * - * @param string $filename The name of the file to load. - * @param int $lineNumber The number of lines to read from file. - * @return string The content of the file. - */ - private function getFileContent($filename, $lineNumber) - { - $content = ''; - $lineCnt = 0; - $file = new SplFileObject($filename); - while (!$file->eof()) { - if ($lineCnt++ == $lineNumber) { - break; - } - - $content .= $file->fgets(); - } - - return $content; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Reader.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Reader.php deleted file mode 100644 index 6a01cb4..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Reader.php +++ /dev/null @@ -1,67 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -/** - * Interface for annotation readers. - * - * @author Johannes M. Schmitt - */ -interface Reader -{ - /** - * @param \ReflectionClass $class - * @return mixed - */ - function getClassAnnotations(\ReflectionClass $class); - - /** - * @param \ReflectionClass $class - * @param string $annotationName - * @return mixed - */ - function getClassAnnotation(\ReflectionClass $class, $annotationName); - - /** - * @param \ReflectionMethod $method - * @return mixed - */ - function getMethodAnnotations(\ReflectionMethod $method); - - /** - * @param \ReflectionMethod $method - * @param string $annotationName - * @return mixed - */ - function getMethodAnnotation(\ReflectionMethod $method, $annotationName); - - /** - * @param \ReflectionProperty $property - * @return mixed - */ - function getPropertyAnnotations(\ReflectionProperty $property); - - /** - * @param \ReflectionProperty $property - * @param string $annotationName - * @return mixed - */ - function getPropertyAnnotation(\ReflectionProperty $property, $annotationName); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php deleted file mode 100644 index 4210d90..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php +++ /dev/null @@ -1,157 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -use Doctrine\Common\Annotations\Annotation\Target; - -/** - * Simple Annotation Reader. - * - * This annotation reader is intended to be used in projects where you have - * full-control over all annotations that are available. - * - * @since 2.2 - * @author Johannes M. Schmitt - * @author Fabio B. Silva - */ -class SimpleAnnotationReader implements Reader -{ - /** - * @var DocParser - */ - private $parser; - - /** - * Constructor. - * - * Initializes a new SimpleAnnotationReader. - */ - public function __construct() - { - $this->parser = new DocParser(); - $this->parser->setIgnoreNotImportedAnnotations(true); - } - - /** - * Adds a namespace in which we will look for annotations. - * - * @param string $namespace - */ - public function addNamespace($namespace) - { - $this->parser->addNamespace($namespace); - } - - /** - * Gets the annotations applied to a class. - * - * @param \ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * - * @return array An array of Annotations. - */ - public function getClassAnnotations(\ReflectionClass $class) - { - return $this->parser->parse($class->getDocComment(), 'class '.$class->getName()); - } - - /** - * Gets the annotations applied to a method. - * - * @param \ReflectionMethod $method The ReflectionMethod of the method from which - * the annotations should be read. - * - * @return array An array of Annotations. - */ - public function getMethodAnnotations(\ReflectionMethod $method) - { - return $this->parser->parse($method->getDocComment(), 'method '.$method->getDeclaringClass()->name.'::'.$method->getName().'()'); - } - - /** - * Gets the annotations applied to a property. - * - * @param \ReflectionProperty $property The ReflectionProperty of the property - * from which the annotations should be read. - * - * @return array An array of Annotations. - */ - public function getPropertyAnnotations(\ReflectionProperty $property) - { - return $this->parser->parse($property->getDocComment(), 'property '.$property->getDeclaringClass()->name.'::$'.$property->getName()); - } - - /** - * Gets a class annotation. - * - * @param \ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * @param string $annotationName The name of the annotation. - * - * @return mixed The Annotation or NULL, if the requested annotation does not exist. - */ - public function getClassAnnotation(\ReflectionClass $class, $annotationName) - { - foreach ($this->getClassAnnotations($class) as $annot) { - if ($annot instanceof $annotationName) { - return $annot; - } - } - - return null; - } - - /** - * Gets a method annotation. - * - * @param \ReflectionMethod $method - * @param string $annotationName The name of the annotation. - * - * @return mixed The Annotation or NULL, if the requested annotation does not exist. - */ - public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) - { - foreach ($this->getMethodAnnotations($method) as $annot) { - if ($annot instanceof $annotationName) { - return $annot; - } - } - - return null; - } - - /** - * Gets a property annotation. - * - * @param \ReflectionProperty $property - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. - */ - public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) - { - foreach ($this->getPropertyAnnotations($property) as $annot) { - if ($annot instanceof $annotationName) { - return $annot; - } - } - - return null; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/TokenParser.php b/vendor/doctrine/common/lib/Doctrine/Common/Annotations/TokenParser.php deleted file mode 100644 index a1ef115..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Annotations/TokenParser.php +++ /dev/null @@ -1,175 +0,0 @@ -. - */ - -namespace Doctrine\Common\Annotations; - -/** - * Parses a file for namespaces/use/class declarations. - * - * @author Fabien Potencier - * @author Christian Kaps - */ -class TokenParser -{ - /** - * The token list. - * - * @var array - */ - private $tokens; - - /** - * The number of tokens. - * - * @var int - */ - private $numTokens = 0; - - /** - * The current array pointer. - * - * @var int - */ - private $pointer = 0; - - public function __construct($contents) - { - $this->tokens = token_get_all($contents); - $this->numTokens = count($this->tokens); - $this->pointer = 0; - } - - /** - * Gets the next non whitespace and non comment token. - * - * @param $docCommentIsComment - * If TRUE then a doc comment is considered a comment and skipped. - * If FALSE then only whitespace and normal comments are skipped. - * - * @return array The token if exists, null otherwise. - */ - public function next($docCommentIsComment = TRUE) - { - for ($i = $this->pointer; $i < $this->numTokens; $i++) { - $this->pointer++; - if ($this->tokens[$i][0] === T_WHITESPACE || - $this->tokens[$i][0] === T_COMMENT || - ($docCommentIsComment && $this->tokens[$i][0] === T_DOC_COMMENT)) { - - continue; - } - - return $this->tokens[$i]; - } - - return null; - } - - /** - * Parse a single use statement. - * - * @return array A list with all found class names for a use statement. - */ - public function parseUseStatement() - { - $class = ''; - $alias = ''; - $statements = array(); - $explicitAlias = false; - while (($token = $this->next())) { - $isNameToken = $token[0] === T_STRING || $token[0] === T_NS_SEPARATOR; - if (!$explicitAlias && $isNameToken) { - $class .= $token[1]; - $alias = $token[1]; - } else if ($explicitAlias && $isNameToken) { - $alias .= $token[1]; - } else if ($token[0] === T_AS) { - $explicitAlias = true; - $alias = ''; - } else if ($token === ',') { - $statements[strtolower($alias)] = $class; - $class = ''; - $alias = ''; - $explicitAlias = false; - } else if ($token === ';') { - $statements[strtolower($alias)] = $class; - break; - } else { - break; - } - } - - return $statements; - } - - /** - * Get all use statements. - * - * @param string $namespaceName The namespace name of the reflected class. - * @return array A list with all found use statements. - */ - public function parseUseStatements($namespaceName) - { - $statements = array(); - while (($token = $this->next())) { - if ($token[0] === T_USE) { - $statements = array_merge($statements, $this->parseUseStatement()); - continue; - } - if ($token[0] !== T_NAMESPACE || $this->parseNamespace() != $namespaceName) { - continue; - } - - // Get fresh array for new namespace. This is to prevent the parser to collect the use statements - // for a previous namespace with the same name. This is the case if a namespace is defined twice - // or if a namespace with the same name is commented out. - $statements = array(); - } - - return $statements; - } - - /** - * Get the namespace. - * - * @return string The found namespace. - */ - public function parseNamespace() - { - $name = ''; - while (($token = $this->next()) && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) { - $name .= $token[1]; - } - - return $name; - } - - /** - * Get the class name. - * - * @return string The foundclass name. - */ - public function parseClass() - { - // Namespaces and class names are tokenized the same: T_STRINGs - // separated by T_NS_SEPARATOR so we can use one function to provide - // both. - return $this->parseNamespace(); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ApcCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/ApcCache.php deleted file mode 100644 index 2d0cd23..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ApcCache.php +++ /dev/null @@ -1,93 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * APC cache provider. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie - */ -class ApcCache extends CacheProvider -{ - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - return apc_fetch($id); - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - return apc_exists($id); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - return (bool) apc_store($id, $data, (int) $lifeTime); - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - return apc_delete($id); - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - return apc_clear_cache() && apc_clear_cache('user'); - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - $info = apc_cache_info(); - $sma = apc_sma_info(); - - return array( - Cache::STATS_HITS => $info['num_hits'], - Cache::STATS_MISSES => $info['num_misses'], - Cache::STATS_UPTIME => $info['start_time'], - Cache::STATS_MEMORY_USAGE => $info['mem_size'], - Cache::STATS_MEMORY_AVAILIABLE => $sma['avail_mem'], - ); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ArrayCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/ArrayCache.php deleted file mode 100644 index a7a70aa..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ArrayCache.php +++ /dev/null @@ -1,96 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * Array cache driver. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie - */ -class ArrayCache extends CacheProvider -{ - /** - * @var array $data - */ - private $data = array(); - - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - return (isset($this->data[$id])) ? $this->data[$id] : false; - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - return isset($this->data[$id]); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - $this->data[$id] = $data; - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - unset($this->data[$id]); - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - $this->data = array(); - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - return null; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/Cache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/Cache.php deleted file mode 100644 index 5493562..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/Cache.php +++ /dev/null @@ -1,102 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * Interface for cache drivers. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Fabio B. Silva - */ -interface Cache -{ - const STATS_HITS = 'hits'; - const STATS_MISSES = 'misses'; - const STATS_UPTIME = 'uptime'; - const STATS_MEMORY_USAGE = 'memory_usage'; - const STATS_MEMORY_AVAILIABLE = 'memory_available'; - - /** - * Fetches an entry from the cache. - * - * @param string $id cache id The id of the cache entry to fetch. - * @return mixed The cached data or FALSE, if no cache entry exists for the given id. - */ - function fetch($id); - - /** - * Test if an entry exists in the cache. - * - * @param string $id cache id The cache id of the entry to check for. - * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise. - */ - function contains($id); - - /** - * Puts data into the cache. - * - * @param string $id The cache id. - * @param mixed $data The cache entry/data. - * @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime). - * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. - */ - function save($id, $data, $lifeTime = 0); - - /** - * Deletes a cache entry. - * - * @param string $id cache id - * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. - */ - function delete($id); - - /** - * Retrieves cached information from data store - * - * The server's statistics array has the following values: - * - * - hits - * Number of keys that have been requested and found present. - * - * - misses - * Number of items that have been requested and not found. - * - * - uptime - * Time that the server is running. - * - * - memory_usage - * Memory used by this server to store items. - * - * - memory_available - * Memory allowed to use for storage. - * - * @since 2.2 - * @var array Associative array with server's statistics if available, NULL otherwise. - */ - function getStats(); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/CacheProvider.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/CacheProvider.php deleted file mode 100644 index 4221a62..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/CacheProvider.php +++ /dev/null @@ -1,231 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * Base class for cache provider implementations. - * - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Fabio B. Silva - */ -abstract class CacheProvider implements Cache -{ - const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]'; - - /** - * @var string The namespace to prefix all cache ids with - */ - private $namespace = ''; - - /** - * @var string The namespace version - */ - private $namespaceVersion; - - /** - * Set the namespace to prefix all cache ids with. - * - * @param string $namespace - * @return void - */ - public function setNamespace($namespace) - { - $this->namespace = (string) $namespace; - } - - /** - * Retrieve the namespace that prefixes all cache ids. - * - * @return string - */ - public function getNamespace() - { - return $this->namespace; - } - - /** - * {@inheritdoc} - */ - public function fetch($id) - { - return $this->doFetch($this->getNamespacedId($id)); - } - - /** - * {@inheritdoc} - */ - public function contains($id) - { - return $this->doContains($this->getNamespacedId($id)); - } - - /** - * {@inheritdoc} - */ - public function save($id, $data, $lifeTime = 0) - { - return $this->doSave($this->getNamespacedId($id), $data, $lifeTime); - } - - /** - * {@inheritdoc} - */ - public function delete($id) - { - return $this->doDelete($this->getNamespacedId($id)); - } - - /** - * {@inheritdoc} - */ - public function getStats() - { - return $this->doGetStats(); - } - - /** - * Deletes all cache entries. - * - * @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise. - */ - public function flushAll() - { - return $this->doFlush(); - } - - /** - * Delete all cache entries. - * - * @return boolean TRUE if the cache entries were successfully deleted, FALSE otherwise. - */ - public function deleteAll() - { - $namespaceCacheKey = $this->getNamespaceCacheKey(); - $namespaceVersion = $this->getNamespaceVersion() + 1; - - $this->namespaceVersion = $namespaceVersion; - - return $this->doSave($namespaceCacheKey, $namespaceVersion); - } - - /** - * Prefix the passed id with the configured namespace value - * - * @param string $id The id to namespace - * @return string $id The namespaced id - */ - private function getNamespacedId($id) - { - $namespaceVersion = $this->getNamespaceVersion(); - - return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion); - } - - /** - * Namespace cache key - * - * @return string $namespaceCacheKey - */ - private function getNamespaceCacheKey() - { - return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace); - } - - /** - * Namespace version - * - * @return string $namespaceVersion - */ - private function getNamespaceVersion() - { - if (null !== $this->namespaceVersion) { - return $this->namespaceVersion; - } - - $namespaceCacheKey = $this->getNamespaceCacheKey(); - $namespaceVersion = $this->doFetch($namespaceCacheKey); - - if (false === $namespaceVersion) { - $namespaceVersion = 1; - - $this->doSave($namespaceCacheKey, $namespaceVersion); - } - - $this->namespaceVersion = $namespaceVersion; - - return $this->namespaceVersion; - } - - /** - * Fetches an entry from the cache. - * - * @param string $id cache id The id of the cache entry to fetch. - * @return string The cached data or FALSE, if no cache entry exists for the given id. - */ - abstract protected function doFetch($id); - - /** - * Test if an entry exists in the cache. - * - * @param string $id cache id The cache id of the entry to check for. - * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise. - */ - abstract protected function doContains($id); - - /** - * Puts data into the cache. - * - * @param string $id The cache id. - * @param string $data The cache entry/data. - * @param bool|int $lifeTime The lifetime. If != false, sets a specific lifetime for this - * cache entry (null => infinite lifeTime). - * - * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. - */ - abstract protected function doSave($id, $data, $lifeTime = false); - - /** - * Deletes a cache entry. - * - * @param string $id cache id - * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. - */ - abstract protected function doDelete($id); - - /** - * Deletes all cache entries. - * - * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. - */ - abstract protected function doFlush(); - - /** - * Retrieves cached information from data store - * - * @since 2.2 - * @return array An associative array with server's statistics if available, NULL otherwise. - */ - abstract protected function doGetStats(); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php deleted file mode 100644 index da650b4..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/FileCache.php +++ /dev/null @@ -1,132 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * Base file cache driver. - * - * @since 2.3 - * @author Fabio B. Silva - */ -abstract class FileCache extends CacheProvider -{ - /** - * @var string Cache directory. - */ - protected $directory; - - /** - * @var string Cache file extension. - */ - protected $extension; - - /** - * Constructor - * - * @param string $directory Cache directory. - * @param string $directory Cache file extension. - * - * @throws \InvalidArgumentException - */ - public function __construct($directory, $extension = null) - { - if ( ! is_dir($directory) && ! @mkdir($directory, 0777, true)) { - throw new \InvalidArgumentException(sprintf( - 'The directory "%s" does not exist and could not be created.', - $directory - )); - } - - if ( ! is_writable($directory)) { - throw new \InvalidArgumentException(sprintf( - 'The directory "%s" is not writable.', - $directory - )); - } - - $this->directory = realpath($directory); - $this->extension = $extension ?: $this->extension; - } - - /** - * Gets the cache directory. - * - * @return string - */ - public function getDirectory() - { - return $this->directory; - } - - /** - * Gets the cache file extension. - * - * @return string - */ - public function getExtension() - { - return $this->extension; - } - - /** - * @return string - */ - protected function getFilename($id) - { - $path = implode(str_split(md5($id), 12), DIRECTORY_SEPARATOR); - $path = $this->directory . DIRECTORY_SEPARATOR . $path; - - return $path . DIRECTORY_SEPARATOR . $id . $this->extension; - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - return @unlink($this->getFilename($id)); - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - $pattern = '/^.+\\' . $this->extension . '$/i'; - $iterator = new \RecursiveDirectoryIterator($this->directory); - $iterator = new \RecursiveIteratorIterator($iterator); - $iterator = new \RegexIterator($iterator, $pattern); - - foreach ($iterator as $name => $file) { - @unlink($name); - } - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - return null; - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/FilesystemCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/FilesystemCache.php deleted file mode 100644 index a27a717..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/FilesystemCache.php +++ /dev/null @@ -1,114 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * Filesystem cache driver. - * - * @since 2.3 - * @author Fabio B. Silva - */ -class FilesystemCache extends FileCache -{ - const EXTENSION = '.doctrinecache.data'; - - /** - * {@inheritdoc} - */ - protected $extension = self::EXTENSION; - - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - $data = ''; - $lifetime = -1; - $filename = $this->getFilename($id); - - if ( ! file_exists($filename)) { - return false; - } - - $resource = fopen($filename, "r"); - - if (false !== ($line = fgets($resource))) { - $lifetime = (integer) $line; - } - - if ($lifetime !== 0 && $lifetime < time()) { - fclose($resource); - - return false; - } - - while (false !== ($line = fgets($resource))) { - $data .= $line; - } - - fclose($resource); - - return unserialize($data); - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - $lifetime = -1; - $filename = $this->getFilename($id); - - if ( ! file_exists($filename)) { - return false; - } - - $resource = fopen($filename, "r"); - - if (false !== ($line = fgets($resource))) { - $lifetime = (integer) $line; - } - - fclose($resource); - - return $lifetime === 0 || $lifetime > time(); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - if ($lifeTime > 0) { - $lifeTime = time() + $lifeTime; - } - - $data = serialize($data); - $filename = $this->getFilename($id); - $filepath = pathinfo($filename, PATHINFO_DIRNAME); - - if ( ! is_dir($filepath)) { - mkdir($filepath, 0777, true); - } - - return file_put_contents($filename, $lifeTime . PHP_EOL . $data); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcacheCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcacheCache.php deleted file mode 100644 index 5687b96..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcacheCache.php +++ /dev/null @@ -1,121 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -use \Memcache; - -/** - * Memcache cache provider. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie - */ -class MemcacheCache extends CacheProvider -{ - /** - * @var Memcache - */ - private $memcache; - - /** - * Sets the memcache instance to use. - * - * @param Memcache $memcache - */ - public function setMemcache(Memcache $memcache) - { - $this->memcache = $memcache; - } - - /** - * Gets the memcache instance used by the cache. - * - * @return Memcache - */ - public function getMemcache() - { - return $this->memcache; - } - - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - return $this->memcache->get($id); - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - return (bool) $this->memcache->get($id); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - if ($lifeTime > 30 * 24 * 3600) { - $lifeTime = time() + $lifeTime; - } - return $this->memcache->set($id, $data, 0, (int) $lifeTime); - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - return $this->memcache->delete($id); - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - return $this->memcache->flush(); - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - $stats = $this->memcache->getStats(); - return array( - Cache::STATS_HITS => $stats['get_hits'], - Cache::STATS_MISSES => $stats['get_misses'], - Cache::STATS_UPTIME => $stats['uptime'], - Cache::STATS_MEMORY_USAGE => $stats['bytes'], - Cache::STATS_MEMORY_AVAILIABLE => $stats['limit_maxbytes'], - ); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcachedCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcachedCache.php deleted file mode 100644 index 75f1345..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/MemcachedCache.php +++ /dev/null @@ -1,124 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -use \Memcached; - -/** - * Memcached cache provider. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie - */ -class MemcachedCache extends CacheProvider -{ - /** - * @var Memcached - */ - private $memcached; - - /** - * Sets the memcache instance to use. - * - * @param Memcached $memcached - */ - public function setMemcached(Memcached $memcached) - { - $this->memcached = $memcached; - } - - /** - * Gets the memcached instance used by the cache. - * - * @return Memcached - */ - public function getMemcached() - { - return $this->memcached; - } - - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - return $this->memcached->get($id); - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - return (false !== $this->memcached->get($id)); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - if ($lifeTime > 30 * 24 * 3600) { - $lifeTime = time() + $lifeTime; - } - return $this->memcached->set($id, $data, (int) $lifeTime); - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - return $this->memcached->delete($id); - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - return $this->memcached->flush(); - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - $stats = $this->memcached->getStats(); - $servers = $this->memcached->getServerList(); - $key = $servers[0]['host'] . ':' . $servers[0]['port']; - $stats = $stats[$key]; - return array( - Cache::STATS_HITS => $stats['get_hits'], - Cache::STATS_MISSES => $stats['get_misses'], - Cache::STATS_UPTIME => $stats['uptime'], - Cache::STATS_MEMORY_USAGE => $stats['bytes'], - Cache::STATS_MEMORY_AVAILIABLE => $stats['limit_maxbytes'], - ); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/PhpFileCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/PhpFileCache.php deleted file mode 100644 index 0971cd9..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/PhpFileCache.php +++ /dev/null @@ -1,108 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * Php file cache driver. - * - * @since 2.3 - * @author Fabio B. Silva - */ -class PhpFileCache extends FileCache -{ - const EXTENSION = '.doctrinecache.php'; - - /** - * {@inheritdoc} - */ - protected $extension = self::EXTENSION; - - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - $filename = $this->getFilename($id); - - if ( ! file_exists($filename)) { - return false; - } - - $value = include $filename; - - if ($value['lifetime'] !== 0 && $value['lifetime'] < time()) { - return false; - } - - return $value['data']; - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - $filename = $this->getFilename($id); - - if ( ! file_exists($filename)) { - return false; - } - - $value = include $filename; - - return $value['lifetime'] === 0 || $value['lifetime'] > time(); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - if ($lifeTime > 0) { - $lifeTime = time() + $lifeTime; - } - - if (is_object($data) && ! method_exists($data, '__set_state')) { - throw new \InvalidArgumentException( - "Invalid argument given, PhpFileCache only allows objects that implement __set_state() " . - "and fully support var_export(). You can use the FilesystemCache to save arbitrary object " . - "graphs using serialize()/deserialize()." - ); - } - - $filename = $this->getFilename($id); - $filepath = pathinfo($filename, PATHINFO_DIRNAME); - - if ( ! is_dir($filepath)) { - mkdir($filepath, 0777, true); - } - - $value = array( - 'lifetime' => $lifeTime, - 'data' => $data - ); - - $value = var_export($value, true); - $code = sprintf('. - */ - -namespace Doctrine\Common\Cache; - -use Redis; - -/** - * Redis cache provider. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Osman Ungur - */ -class RedisCache extends CacheProvider -{ - /** - * @var Redis - */ - private $redis; - - /** - * Sets the redis instance to use. - * - * @param Redis $redis - */ - public function setRedis(Redis $redis) - { - $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); - $this->redis = $redis; - } - - /** - * Gets the redis instance used by the cache. - * - * @return Redis - */ - public function getRedis() - { - return $this->redis; - } - - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - return $this->redis->get($id); - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - return $this->redis->exists($id); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - $result = $this->redis->set($id, $data); - if ($lifeTime > 0) { - $this->redis->expire($id, $lifeTime); - } - return $result; - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - return $this->redis->delete($id); - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - return $this->redis->flushDB(); - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - $info = $this->redis->info(); - return array( - Cache::STATS_HITS => false, - Cache::STATS_MISSES => false, - Cache::STATS_UPTIME => $info['uptime_in_seconds'], - Cache::STATS_MEMORY_USAGE => $info['used_memory'], - Cache::STATS_MEMORY_AVAILIABLE => false - ); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/WinCacheCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/WinCacheCache.php deleted file mode 100644 index 777d0fd..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/WinCacheCache.php +++ /dev/null @@ -1,93 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * WinCache cache provider. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie - */ -class WinCacheCache extends CacheProvider -{ - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - return wincache_ucache_get($id); - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - return wincache_ucache_exists($id); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - return (bool) wincache_ucache_set($id, $data, (int) $lifeTime); - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - return wincache_ucache_delete($id); - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - return wincache_ucache_clear(); - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - $info = wincache_ucache_info(); - $meminfo = wincache_ucache_meminfo(); - - return array( - Cache::STATS_HITS => $info['total_hit_count'], - Cache::STATS_MISSES => $info['total_miss_count'], - Cache::STATS_UPTIME => $info['total_cache_uptime'], - Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'], - Cache::STATS_MEMORY_AVAILIABLE => $meminfo['memory_free'], - ); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/XcacheCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/XcacheCache.php deleted file mode 100644 index 8733e26..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/XcacheCache.php +++ /dev/null @@ -1,110 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * Xcache cache driver. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie - */ -class XcacheCache extends CacheProvider -{ - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - return $this->doContains($id) ? unserialize(xcache_get($id)) : false; - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - return xcache_isset($id); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - return xcache_set($id, serialize($data), (int) $lifeTime); - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - return xcache_unset($id); - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - $this->checkAuthorization(); - - xcache_clear_cache(XC_TYPE_VAR, 0); - - return true; - } - - /** - * Checks that xcache.admin.enable_auth is Off - * - * @throws \BadMethodCallException When xcache.admin.enable_auth is On - * @return void - */ - protected function checkAuthorization() - { - if (ini_get('xcache.admin.enable_auth')) { - throw new \BadMethodCallException('To use all features of \Doctrine\Common\Cache\XcacheCache, you must set "xcache.admin.enable_auth" to "Off" in your php.ini.'); - } - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - $this->checkAuthorization(); - - $info = xcache_info(XC_TYPE_VAR, 0); - return array( - Cache::STATS_HITS => $info['hits'], - Cache::STATS_MISSES => $info['misses'], - Cache::STATS_UPTIME => null, - Cache::STATS_MEMORY_USAGE => $info['size'], - Cache::STATS_MEMORY_AVAILIABLE => $info['avail'], - ); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php b/vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php deleted file mode 100644 index fc90bc6..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Cache/ZendDataCache.php +++ /dev/null @@ -1,84 +0,0 @@ -. - */ - -namespace Doctrine\Common\Cache; - -/** - * Zend Data Cache cache driver. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Ralph Schindler - * @author Guilherme Blanco - */ -class ZendDataCache extends CacheProvider -{ - /** - * {@inheritdoc} - */ - protected function doFetch($id) - { - return zend_shm_cache_fetch($id); - } - - /** - * {@inheritdoc} - */ - protected function doContains($id) - { - return (false !== zend_shm_cache_fetch($id)); - } - - /** - * {@inheritdoc} - */ - protected function doSave($id, $data, $lifeTime = 0) - { - return zend_shm_cache_store($id, $data, $lifeTime); - } - - /** - * {@inheritdoc} - */ - protected function doDelete($id) - { - return zend_shm_cache_delete($id); - } - - /** - * {@inheritdoc} - */ - protected function doFlush() - { - $namespace = $this->getNamespace(); - if (empty($namespace)) { - return zend_shm_cache_clear(); - } - return zend_shm_cache_clear($namespace); - } - - /** - * {@inheritdoc} - */ - protected function doGetStats() - { - return null; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php b/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php deleted file mode 100644 index 45024e1..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php +++ /dev/null @@ -1,263 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * A ClassLoader is an autoloader for class files that can be - * installed on the SPL autoload stack. It is a class loader that either loads only classes - * of a specific namespace or all namespaces and it is suitable for working together - * with other autoloaders in the SPL autoload stack. - * - * If no include path is configured through the constructor or {@link setIncludePath}, a ClassLoader - * relies on the PHP include_path. - * - * @author Roman Borschel - * @since 2.0 - */ -class ClassLoader -{ - /** - * @var string PHP file extension - */ - protected $fileExtension = '.php'; - - /** - * @var string Current namespace - */ - protected $namespace; - - /** - * @var string Current include path - */ - protected $includePath; - - /** - * @var string PHP namespace separator - */ - protected $namespaceSeparator = '\\'; - - /** - * Creates a new ClassLoader that loads classes of the - * specified namespace from the specified include path. - * - * If no include path is given, the ClassLoader relies on the PHP include_path. - * If neither a namespace nor an include path is given, the ClassLoader will - * be responsible for loading all classes, thereby relying on the PHP include_path. - * - * @param string $ns The namespace of the classes to load. - * @param string $includePath The base include path to use. - */ - public function __construct($ns = null, $includePath = null) - { - $this->namespace = $ns; - $this->includePath = $includePath; - } - - /** - * Sets the namespace separator used by classes in the namespace of this ClassLoader. - * - * @param string $sep The separator to use. - */ - public function setNamespaceSeparator($sep) - { - $this->namespaceSeparator = $sep; - } - - /** - * Gets the namespace separator used by classes in the namespace of this ClassLoader. - * - * @return string - */ - public function getNamespaceSeparator() - { - return $this->namespaceSeparator; - } - - /** - * Sets the base include path for all class files in the namespace of this ClassLoader. - * - * @param string $includePath - */ - public function setIncludePath($includePath) - { - $this->includePath = $includePath; - } - - /** - * Gets the base include path for all class files in the namespace of this ClassLoader. - * - * @return string - */ - public function getIncludePath() - { - return $this->includePath; - } - - /** - * Sets the file extension of class files in the namespace of this ClassLoader. - * - * @param string $fileExtension - */ - public function setFileExtension($fileExtension) - { - $this->fileExtension = $fileExtension; - } - - /** - * Gets the file extension of class files in the namespace of this ClassLoader. - * - * @return string - */ - public function getFileExtension() - { - return $this->fileExtension; - } - - /** - * Registers this ClassLoader on the SPL autoload stack. - */ - public function register() - { - spl_autoload_register(array($this, 'loadClass')); - } - - /** - * Removes this ClassLoader from the SPL autoload stack. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $className The name of the class to load. - - * @return boolean TRUE if the class has been successfully loaded, FALSE otherwise. - */ - public function loadClass($className) - { - if ($this->namespace !== null && strpos($className, $this->namespace.$this->namespaceSeparator) !== 0) { - return false; - } - - require ($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '') - . str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) - . $this->fileExtension; - - return true; - } - - /** - * Asks this ClassLoader whether it can potentially load the class (file) with - * the given name. - * - * @param string $className The fully-qualified name of the class. - * @return boolean TRUE if this ClassLoader can load the class, FALSE otherwise. - */ - public function canLoadClass($className) - { - if ($this->namespace !== null && strpos($className, $this->namespace.$this->namespaceSeparator) !== 0) { - return false; - } - - $file = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) . $this->fileExtension; - - if ($this->includePath !== null) { - return file_exists($this->includePath . DIRECTORY_SEPARATOR . $file); - } - - return (false !== stream_resolve_include_path($file)); - } - - /** - * Checks whether a class with a given name exists. A class "exists" if it is either - * already defined in the current request or if there is an autoloader on the SPL - * autoload stack that is a) responsible for the class in question and b) is able to - * load a class file in which the class definition resides. - * - * If the class is not already defined, each autoloader in the SPL autoload stack - * is asked whether it is able to tell if the class exists. If the autoloader is - * a ClassLoader, {@link canLoadClass} is used, otherwise the autoload - * function of the autoloader is invoked and expected to return a value that - * evaluates to TRUE if the class (file) exists. As soon as one autoloader reports - * that the class exists, TRUE is returned. - * - * Note that, depending on what kinds of autoloaders are installed on the SPL - * autoload stack, the class (file) might already be loaded as a result of checking - * for its existence. This is not the case with a ClassLoader, who separates - * these responsibilities. - * - * @param string $className The fully-qualified name of the class. - * @return boolean TRUE if the class exists as per the definition given above, FALSE otherwise. - */ - public static function classExists($className) - { - if (class_exists($className, false) || interface_exists($className, false)) { - return true; - } - - foreach (spl_autoload_functions() as $loader) { - if (is_array($loader)) { // array(???, ???) - if (is_object($loader[0])) { - if ($loader[0] instanceof ClassLoader) { // array($obj, 'methodName') - if ($loader[0]->canLoadClass($className)) { - return true; - } - } else if ($loader[0]->{$loader[1]}($className)) { - return true; - } - } else if ($loader[0]::$loader[1]($className)) { // array('ClassName', 'methodName') - return true; - } - } else if ($loader instanceof \Closure) { // function($className) {..} - if ($loader($className)) { - return true; - } - } else if (is_string($loader) && $loader($className)) { // "MyClass::loadClass" - return true; - } - } - - return class_exists($className, false) || interface_exists($className, false); - } - - /** - * Gets the ClassLoader from the SPL autoload stack that is responsible - * for (and is able to load) the class with the given name. - * - * @param string $className The name of the class. - * @return ClassLoader The ClassLoader for the class or NULL if no such ClassLoader exists. - */ - public static function getClassLoader($className) - { - foreach (spl_autoload_functions() as $loader) { - if (is_array($loader) - && $loader[0] instanceof ClassLoader - && $loader[0]->canLoadClass($className) - ) { - return $loader[0]; - } - } - - return null; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/ArrayCollection.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/ArrayCollection.php deleted file mode 100644 index 7c2b13e..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/ArrayCollection.php +++ /dev/null @@ -1,500 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections; - -use Closure, ArrayIterator; -use Doctrine\Common\Collections\Expr\Expression; -use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor; - -/** - * An ArrayCollection is a Collection implementation that wraps a regular PHP array. - * - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -class ArrayCollection implements Collection, Selectable -{ - /** - * An array containing the entries of this collection. - * - * @var array - */ - private $_elements; - - /** - * Initializes a new ArrayCollection. - * - * @param array $elements - */ - public function __construct(array $elements = array()) - { - $this->_elements = $elements; - } - - /** - * Gets the PHP array representation of this collection. - * - * @return array The PHP array representation of this collection. - */ - public function toArray() - { - return $this->_elements; - } - - /** - * Sets the internal iterator to the first element in the collection and - * returns this element. - * - * @return mixed - */ - public function first() - { - return reset($this->_elements); - } - - /** - * Sets the internal iterator to the last element in the collection and - * returns this element. - * - * @return mixed - */ - public function last() - { - return end($this->_elements); - } - - /** - * Gets the current key/index at the current internal iterator position. - * - * @return mixed - */ - public function key() - { - return key($this->_elements); - } - - /** - * Moves the internal iterator position to the next element. - * - * @return mixed - */ - public function next() - { - return next($this->_elements); - } - - /** - * Gets the element of the collection at the current internal iterator position. - * - * @return mixed - */ - public function current() - { - return current($this->_elements); - } - - /** - * Removes an element with a specific key/index from the collection. - * - * @param mixed $key - * @return mixed The removed element or NULL, if no element exists for the given key. - */ - public function remove($key) - { - if (isset($this->_elements[$key])) { - $removed = $this->_elements[$key]; - unset($this->_elements[$key]); - - return $removed; - } - - return null; - } - - /** - * Removes the specified element from the collection, if it is found. - * - * @param mixed $element The element to remove. - * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. - */ - public function removeElement($element) - { - $key = array_search($element, $this->_elements, true); - - if ($key !== false) { - unset($this->_elements[$key]); - - return true; - } - - return false; - } - - /** - * ArrayAccess implementation of offsetExists() - * - * @see containsKey() - * - * @param mixed $offset - * @return bool - */ - public function offsetExists($offset) - { - return $this->containsKey($offset); - } - - /** - * ArrayAccess implementation of offsetGet() - * - * @see get() - * - * @param mixed $offset - * @return mixed - */ - public function offsetGet($offset) - { - return $this->get($offset); - } - - /** - * ArrayAccess implementation of offsetSet() - * - * @see add() - * @see set() - * - * @param mixed $offset - * @param mixed $value - * @return bool - */ - public function offsetSet($offset, $value) - { - if ( ! isset($offset)) { - return $this->add($value); - } - return $this->set($offset, $value); - } - - /** - * ArrayAccess implementation of offsetUnset() - * - * @see remove() - * - * @param mixed $offset - * @return mixed - */ - public function offsetUnset($offset) - { - return $this->remove($offset); - } - - /** - * Checks whether the collection contains a specific key/index. - * - * @param mixed $key The key to check for. - * @return boolean TRUE if the given key/index exists, FALSE otherwise. - */ - public function containsKey($key) - { - return isset($this->_elements[$key]); - } - - /** - * Checks whether the given element is contained in the collection. - * Only element values are compared, not keys. The comparison of two elements - * is strict, that means not only the value but also the type must match. - * For objects this means reference equality. - * - * @param mixed $element - * @return boolean TRUE if the given element is contained in the collection, - * FALSE otherwise. - */ - public function contains($element) - { - foreach ($this->_elements as $collectionElement) { - if ($element === $collectionElement) { - return true; - } - } - - return false; - } - - /** - * Tests for the existence of an element that satisfies the given predicate. - * - * @param Closure $p The predicate. - * @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise. - */ - public function exists(Closure $p) - { - foreach ($this->_elements as $key => $element) { - if ($p($key, $element)) { - return true; - } - } - return false; - } - - /** - * Searches for a given element and, if found, returns the corresponding key/index - * of that element. The comparison of two elements is strict, that means not - * only the value but also the type must match. - * For objects this means reference equality. - * - * @param mixed $element The element to search for. - * @return mixed The key/index of the element or FALSE if the element was not found. - */ - public function indexOf($element) - { - return array_search($element, $this->_elements, true); - } - - /** - * Gets the element with the given key/index. - * - * @param mixed $key The key. - * @return mixed The element or NULL, if no element exists for the given key. - */ - public function get($key) - { - if (isset($this->_elements[$key])) { - return $this->_elements[$key]; - } - return null; - } - - /** - * Gets all keys/indexes of the collection elements. - * - * @return array - */ - public function getKeys() - { - return array_keys($this->_elements); - } - - /** - * Gets all elements. - * - * @return array - */ - public function getValues() - { - return array_values($this->_elements); - } - - /** - * Returns the number of elements in the collection. - * - * Implementation of the Countable interface. - * - * @return integer The number of elements in the collection. - */ - public function count() - { - return count($this->_elements); - } - - /** - * Adds/sets an element in the collection at the index / with the specified key. - * - * When the collection is a Map this is like put(key,value)/add(key,value). - * When the collection is a List this is like add(position,value). - * - * @param mixed $key - * @param mixed $value - */ - public function set($key, $value) - { - $this->_elements[$key] = $value; - } - - /** - * Adds an element to the collection. - * - * @param mixed $value - * @return boolean Always TRUE. - */ - public function add($value) - { - $this->_elements[] = $value; - return true; - } - - /** - * Checks whether the collection is empty. - * - * Note: This is preferable over count() == 0. - * - * @return boolean TRUE if the collection is empty, FALSE otherwise. - */ - public function isEmpty() - { - return ! $this->_elements; - } - - /** - * Gets an iterator for iterating over the elements in the collection. - * - * @return ArrayIterator - */ - public function getIterator() - { - return new ArrayIterator($this->_elements); - } - - /** - * Applies the given function to each element in the collection and returns - * a new collection with the elements returned by the function. - * - * @param Closure $func - * @return Collection - */ - public function map(Closure $func) - { - return new static(array_map($func, $this->_elements)); - } - - /** - * Returns all the elements of this collection that satisfy the predicate p. - * The order of the elements is preserved. - * - * @param Closure $p The predicate used for filtering. - * @return Collection A collection with the results of the filter operation. - */ - public function filter(Closure $p) - { - return new static(array_filter($this->_elements, $p)); - } - - /** - * Applies the given predicate p to all elements of this collection, - * returning true, if the predicate yields true for all elements. - * - * @param Closure $p The predicate. - * @return boolean TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. - */ - public function forAll(Closure $p) - { - foreach ($this->_elements as $key => $element) { - if ( ! $p($key, $element)) { - return false; - } - } - - return true; - } - - /** - * Partitions this collection in two collections according to a predicate. - * Keys are preserved in the resulting collections. - * - * @param Closure $p The predicate on which to partition. - * @return array An array with two elements. The first element contains the collection - * of elements where the predicate returned TRUE, the second element - * contains the collection of elements where the predicate returned FALSE. - */ - public function partition(Closure $p) - { - $coll1 = $coll2 = array(); - foreach ($this->_elements as $key => $element) { - if ($p($key, $element)) { - $coll1[$key] = $element; - } else { - $coll2[$key] = $element; - } - } - return array(new static($coll1), new static($coll2)); - } - - /** - * Returns a string representation of this object. - * - * @return string - */ - public function __toString() - { - return __CLASS__ . '@' . spl_object_hash($this); - } - - /** - * Clears the collection. - */ - public function clear() - { - $this->_elements = array(); - } - - /** - * Extract a slice of $length elements starting at position $offset from the Collection. - * - * If $length is null it returns all elements from $offset to the end of the Collection. - * Keys have to be preserved by this method. Calling this method will only return the - * selected slice and NOT change the elements contained in the collection slice is called on. - * - * @param int $offset - * @param int $length - * @return array - */ - public function slice($offset, $length = null) - { - return array_slice($this->_elements, $offset, $length, true); - } - - /** - * Select all elements from a selectable that match the criteria and - * return a new collection containing these elements. - * - * @param Criteria $criteria - * @return Collection - */ - public function matching(Criteria $criteria) - { - $expr = $criteria->getWhereExpression(); - $filtered = $this->_elements; - - if ($expr) { - $visitor = new ClosureExpressionVisitor(); - $filter = $visitor->dispatch($expr); - $filtered = array_filter($filtered, $filter); - } - - if ($orderings = $criteria->getOrderings()) { - $next = null; - foreach (array_reverse($orderings) as $field => $ordering) { - $next = ClosureExpressionVisitor::sortByField($field, $ordering == 'DESC' ? -1 : 1, $next); - } - - usort($filtered, $next); - } - - $offset = $criteria->getFirstResult(); - $length = $criteria->getMaxResults(); - - if ($offset || $length) { - $filtered = array_slice($filtered, (int)$offset, $length); - } - - return new static($filtered); - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Collection.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Collection.php deleted file mode 100644 index 51eb9e7..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Collection.php +++ /dev/null @@ -1,243 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections; - -use Closure, Countable, IteratorAggregate, ArrayAccess; - -/** - * The missing (SPL) Collection/Array/OrderedMap interface. - * - * A Collection resembles the nature of a regular PHP array. That is, - * it is essentially an ordered map that can also be used - * like a list. - * - * A Collection has an internal iterator just like a PHP array. In addition, - * a Collection can be iterated with external iterators, which is preferrable. - * To use an external iterator simply use the foreach language construct to - * iterate over the collection (which calls {@link getIterator()} internally) or - * explicitly retrieve an iterator though {@link getIterator()} which can then be - * used to iterate over the collection. - * You can not rely on the internal iterator of the collection being at a certain - * position unless you explicitly positioned it before. Prefer iteration with - * external iterators. - * - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -interface Collection extends Countable, IteratorAggregate, ArrayAccess -{ - /** - * Adds an element at the end of the collection. - * - * @param mixed $element The element to add. - * @return boolean Always TRUE. - */ - function add($element); - - /** - * Clears the collection, removing all elements. - */ - function clear(); - - /** - * Checks whether an element is contained in the collection. - * This is an O(n) operation, where n is the size of the collection. - * - * @param mixed $element The element to search for. - * @return boolean TRUE if the collection contains the element, FALSE otherwise. - */ - function contains($element); - - /** - * Checks whether the collection is empty (contains no elements). - * - * @return boolean TRUE if the collection is empty, FALSE otherwise. - */ - function isEmpty(); - - /** - * Removes the element at the specified index from the collection. - * - * @param string|integer $key The kex/index of the element to remove. - * @return mixed The removed element or NULL, if the collection did not contain the element. - */ - function remove($key); - - /** - * Removes the specified element from the collection, if it is found. - * - * @param mixed $element The element to remove. - * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. - */ - function removeElement($element); - - /** - * Checks whether the collection contains an element with the specified key/index. - * - * @param string|integer $key The key/index to check for. - * @return boolean TRUE if the collection contains an element with the specified key/index, - * FALSE otherwise. - */ - function containsKey($key); - - /** - * Gets the element at the specified key/index. - * - * @param string|integer $key The key/index of the element to retrieve. - * @return mixed - */ - function get($key); - - /** - * Gets all keys/indices of the collection. - * - * @return array The keys/indices of the collection, in the order of the corresponding - * elements in the collection. - */ - function getKeys(); - - /** - * Gets all values of the collection. - * - * @return array The values of all elements in the collection, in the order they - * appear in the collection. - */ - function getValues(); - - /** - * Sets an element in the collection at the specified key/index. - * - * @param string|integer $key The key/index of the element to set. - * @param mixed $value The element to set. - */ - function set($key, $value); - - /** - * Gets a native PHP array representation of the collection. - * - * @return array - */ - function toArray(); - - /** - * Sets the internal iterator to the first element in the collection and - * returns this element. - * - * @return mixed - */ - function first(); - - /** - * Sets the internal iterator to the last element in the collection and - * returns this element. - * - * @return mixed - */ - function last(); - - /** - * Gets the key/index of the element at the current iterator position. - * - */ - function key(); - - /** - * Gets the element of the collection at the current iterator position. - * - */ - function current(); - - /** - * Moves the internal iterator position to the next element. - * - */ - function next(); - - /** - * Tests for the existence of an element that satisfies the given predicate. - * - * @param Closure $p The predicate. - * @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise. - */ - function exists(Closure $p); - - /** - * Returns all the elements of this collection that satisfy the predicate p. - * The order of the elements is preserved. - * - * @param Closure $p The predicate used for filtering. - * @return Collection A collection with the results of the filter operation. - */ - function filter(Closure $p); - - /** - * Applies the given predicate p to all elements of this collection, - * returning true, if the predicate yields true for all elements. - * - * @param Closure $p The predicate. - * @return boolean TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. - */ - function forAll(Closure $p); - - /** - * Applies the given function to each element in the collection and returns - * a new collection with the elements returned by the function. - * - * @param Closure $func - * @return Collection - */ - function map(Closure $func); - - /** - * Partitions this collection in two collections according to a predicate. - * Keys are preserved in the resulting collections. - * - * @param Closure $p The predicate on which to partition. - * @return array An array with two elements. The first element contains the collection - * of elements where the predicate returned TRUE, the second element - * contains the collection of elements where the predicate returned FALSE. - */ - function partition(Closure $p); - - /** - * Gets the index/key of a given element. The comparison of two elements is strict, - * that means not only the value but also the type must match. - * For objects this means reference equality. - * - * @param mixed $element The element to search for. - * @return mixed The key/index of the element or FALSE if the element was not found. - */ - function indexOf($element); - - /** - * Extract a slice of $length elements starting at position $offset from the Collection. - * - * If $length is null it returns all elements from $offset to the end of the Collection. - * Keys have to be preserved by this method. Calling this method will only return the - * selected slice and NOT change the elements contained in the collection slice is called on. - * - * @param int $offset - * @param int $length - * @return array - */ - function slice($offset, $length = null); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Criteria.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Criteria.php deleted file mode 100644 index 3b05549..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Criteria.php +++ /dev/null @@ -1,240 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections; - -use Doctrine\Common\Collections\Expr\Expression; -use Doctrine\Common\Collections\Expr\CompositeExpression; - -/** - * Criteria for filtering Selectable collections. - * - * @author Benjamin Eberlei - * @since 2.3 - */ -class Criteria -{ - /** - * @var string - */ - const ASC = 'ASC'; - - /** - * @var string - */ - const DESC = 'DESC'; - - /** - * @var \Doctrine\Common\Collections\ExpressionBuilder - */ - private static $expressionBuilder; - - /** - * @var \Doctrine\Common\Collections\Expr\Expression - */ - private $expression; - - /** - * @var array|null - */ - private $orderings; - - /** - * @var int - */ - private $firstResult; - - /** - * @var int - */ - private $maxResults; - - /** - * Creates an instance of the class. - * - * @return Criteria - */ - public static function create() - { - return new static(); - } - - /** - * Return the expression builder. - * - * @return \Doctrine\Common\Collections\ExpressionBuilder - */ - public static function expr() - { - if (self::$expressionBuilder === null) { - self::$expressionBuilder = new ExpressionBuilder(); - } - return self::$expressionBuilder; - } - - /** - * Construct new criteria - * - * @param Expression $expression - * @param array $orderings - * @param int $firstResult - * @param int $maxResults - */ - public function __construct(Expression $expression = null, array $orderings = null, $firstResult = null, $maxResults = null) - { - $this->expression = $expression; - $this->orderings = $orderings; - $this->firstResult = $firstResult; - $this->maxResults = $maxResults; - } - - /** - * Set the where expression to evaluate when this criteria is searched for. - * - * @param Expression - * @return Criteria - */ - public function where(Expression $expression) - { - $this->expression = $expression; - return $this; - } - - /** - * Append the where expression to evaluate when this criteria is searched for - * using an AND with previous expression. - * - * @param Expression - * @return Criteria - */ - public function andWhere(Expression $expression) - { - if ($this->expression === null) { - return $this->where($expression); - } - - $this->expression = new CompositeExpression(CompositeExpression::TYPE_AND, array( - $this->expression, $expression - )); - - return $this; - } - - /** - * Append the where expression to evaluate when this criteria is searched for - * using an OR with previous expression. - * - * @param Expression - * @return Criteria - */ - public function orWhere(Expression $expression) - { - if ($this->expression === null) { - return $this->where($expression); - } - - $this->expression = new CompositeExpression(CompositeExpression::TYPE_OR, array( - $this->expression, $expression - )); - - return $this; - } - - /** - * Get the expression attached to this criteria. - * - * @return Expression|null - */ - public function getWhereExpression() - { - return $this->expression; - } - - /** - * Get current orderings of this Criteria - * - * @return array - */ - public function getOrderings() - { - return $this->orderings; - } - - /** - * Set the ordering of the result of this criteria. - * - * Keys are field and values are the order, being either ASC or DESC. - * - * @see Criteria::ASC - * @see Criteria::DESC - * - * @param array - * @return Criteria - */ - public function orderBy(array $orderings) - { - $this->orderings = $orderings; - return $this; - } - - /** - * Get current first result option of the critera. - * - * @return firstResult. - */ - public function getFirstResult() - { - return $this->firstResult; - } - - /** - * Set number of first result that this criteria should return. - * - * @param firstResult the value to set. - * @return Criteria - */ - public function setFirstResult($firstResult) - { - $this->firstResult = $firstResult; - return $this; - } - - /** - * Get maxResults. - * - * @return maxResults. - */ - public function getMaxResults() - { - return $this->maxResults; - } - - /** - * Set maxResults. - * - * @param maxResults the value to set. - * @return Criteria - */ - public function setMaxResults($maxResults) - { - $this->maxResults = $maxResults; - return $this; - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php deleted file mode 100644 index 06ccb04..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php +++ /dev/null @@ -1,195 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections\Expr; - -/** - * Walks an expression graph and turns it into a PHP closure. - * - * This closure can be used with {@Collection#filter()} and is used internally - * by {@ArrayCollection#select()}. - * - * @author Benjamin Eberlei - * @since 2.3 - */ -class ClosureExpressionVisitor extends ExpressionVisitor -{ - /** - * Access the field of a given object. This field has to be public directly - * or indirectly (through an accessor get* or a magic method, __get, __call). - * - * is*() is not supported. - * - * @return mixed - */ - static public function getObjectFieldValue($object, $field) - { - $accessor = "get" . $field; - - if (method_exists($object, $accessor) || method_exists($object, '__call')) { - return $object->$accessor(); - } - - if ($object instanceof \ArrayAccess) { - return $object[$field]; - } - - return $object->$field; - } - - /** - * Helper for sorting arrays of objects based on multiple fields + - * orientations. - * - * @param string $name - * @param int $orientation - * @param Closure $next - * @return Closure - */ - static public function sortByField($name, $orientation = 1, \Closure $next = null) - { - if (!$next) { - $next = function() { - return 0; - }; - } - - return function ($a, $b) use ($name, $next, $orientation) { - $aValue = ClosureExpressionVisitor::getObjectFieldValue($a, $name); - $bValue = ClosureExpressionVisitor::getObjectFieldValue($b, $name); - - if ($aValue === $bValue) { - return $next($a, $b); - } - - return (($aValue > $bValue) ? 1 : -1) * $orientation; - }; - } - - /** - * {@inheritDoc} - */ - public function walkComparison(Comparison $comparison) - { - $field = $comparison->getField(); - $value = $comparison->getValue()->getValue(); // shortcut for walkValue() - - switch ($comparison->getOperator()) { - case Comparison::EQ: - case Comparison::IS: - return function ($object) use ($field, $value) { - return ClosureExpressionVisitor::getObjectFieldValue($object, $field) === $value; - }; - - case Comparison::NEQ: - return function ($object) use ($field, $value) { - return ClosureExpressionVisitor::getObjectFieldValue($object, $field) !== $value; - }; - - case Comparison::LT: - return function ($object) use ($field, $value) { - return ClosureExpressionVisitor::getObjectFieldValue($object, $field) < $value; - }; - - case Comparison::LTE: - return function ($object) use ($field, $value) { - return ClosureExpressionVisitor::getObjectFieldValue($object, $field) <= $value; - }; - - case Comparison::GT: - return function ($object) use ($field, $value) { - return ClosureExpressionVisitor::getObjectFieldValue($object, $field) > $value; - }; - - case Comparison::GTE: - return function ($object) use ($field, $value) { - return ClosureExpressionVisitor::getObjectFieldValue($object, $field) >= $value; - }; - - case Comparison::IN: - return function ($object) use ($field, $value) { - return in_array(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value); - }; - - case Comparison::NIN: - return function ($object) use ($field, $value) { - return ! in_array(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value); - }; - - default: - throw new \RuntimeException("Unknown comparison operator: " . $comparison->getOperator()); - } - } - - /** - * {@inheritDoc} - */ - public function walkValue(Value $value) - { - return $value->getValue(); - } - - /** - * {@inheritDoc} - */ - public function walkCompositeExpression(CompositeExpression $expr) - { - $expressionList = array(); - - foreach ($expr->getExpressionList() as $child) { - $expressionList[] = $this->dispatch($child); - } - - switch($expr->getType()) { - case CompositeExpression::TYPE_AND: - return $this->andExpressions($expressionList); - - case CompositeExpression::TYPE_OR: - return $this->orExpressions($expressionList); - - default: - throw new \RuntimeException("Unknown composite " . $expr->getType()); - } - } - - private function andExpressions($expressions) - { - return function ($object) use ($expressions) { - foreach ($expressions as $expression) { - if ( ! $expression($object)) { - return false; - } - } - return true; - }; - } - - private function orExpressions($expressions) - { - return function ($object) use ($expressions) { - foreach ($expressions as $expression) { - if ($expression($object)) { - return true; - } - } - return false; - }; - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Comparison.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Comparison.php deleted file mode 100644 index 29cfcff..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Comparison.php +++ /dev/null @@ -1,75 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections\Expr; - -/** - * Comparison of a field with a value by the given operator. - * - * @author Benjamin Eberlei - * @since 2.3 - */ -class Comparison implements Expression -{ - const EQ = '='; - const NEQ = '<>'; - const LT = '<'; - const LTE = '<='; - const GT = '>'; - const GTE = '>='; - const IS = 'IS'; - const IN = 'IN'; - const NIN = 'NIN'; - - private $field; - private $op; - private $value; - - public function __construct($field, $operator, $value) - { - if ( ! ($value instanceof Value)) { - $value = new Value($value); - } - - $this->field = $field; - $this->op = $operator; - $this->value = $value; - } - - public function getField() - { - return $this->field; - } - - public function getValue() - { - return $this->value; - } - - public function getOperator() - { - return $this->op; - } - - public function visit(ExpressionVisitor $visitor) - { - return $visitor->walkComparison($this); - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php deleted file mode 100644 index fe917cf..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections\Expr; - -/** - * Expression of Expressions combined by AND or OR operation. - * - * @author Benjamin Eberlei - * @since 2.3 - */ -class CompositeExpression implements Expression -{ - const TYPE_AND = 'AND'; - const TYPE_OR = 'OR'; - - private $type; - private $expressions = array(); - - public function __construct($type, array $expressions) - { - $this->type = $type; - - foreach ($expressions as $expr) { - if ($expr instanceof Value) { - throw new \RuntimeException("Values are not supported expressions as children of and/or expressions."); - } - if ( ! ($expr instanceof Expression)) { - throw new \RuntimeException("No expression given to CompositeExpression."); - } - - $this->expressions[] = $expr; - } - } - - /** - * Return the list of expressions nested in this composite. - * - * @return Expression[] - */ - public function getExpressionList() - { - return $this->expressions; - } - - public function getType() - { - return $this->type; - } - - public function visit(ExpressionVisitor $visitor) - { - return $visitor->walkCompositeExpression($this); - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Expression.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Expression.php deleted file mode 100644 index b0762ad..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Expression.php +++ /dev/null @@ -1,31 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections\Expr; - -/** - * Expression for the {@link Selectable} interface. - * - * @author Benjamin Eberlei - */ -interface Expression -{ - public function visit(ExpressionVisitor $visitor); -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php deleted file mode 100644 index 5e69b98..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/ExpressionVisitor.php +++ /dev/null @@ -1,81 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections\Expr; - -/** - * An Expression visitor walks a graph of expressions and turns them into a - * query for the underlying implementation. - * - * @author Benjamin Eberlei - */ -abstract class ExpressionVisitor -{ - /** - * Convert a comparison expression into the target query language output - * - * @param Comparison $comparison - * - * @return mixed - */ - abstract public function walkComparison(Comparison $comparison); - - /** - * Convert a value expression into the target query language part. - * - * @param Value $value - * - * @return mixed - */ - abstract public function walkValue(Value $value); - - /** - * Convert a composite expression into the target query language output - * - * @param CompositeExpression $expr - * - * @return mixed - */ - abstract public function walkCompositeExpression(CompositeExpression $expr); - - /** - * Dispatch walking an expression to the appropriate handler. - * - * @param Expression - * - * @return mixed - */ - public function dispatch(Expression $expr) - { - switch (true) { - case ($expr instanceof Comparison): - return $this->walkComparison($expr); - - case ($expr instanceof Value): - return $this->walkValue($expr); - - case ($expr instanceof CompositeExpression): - return $this->walkCompositeExpression($expr); - - default: - throw new \RuntimeException("Unknown Expression " . get_class($expr)); - } - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Value.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Value.php deleted file mode 100644 index f0df11a..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Expr/Value.php +++ /dev/null @@ -1,41 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections\Expr; - -class Value implements Expression -{ - private $value; - - public function __construct($value) - { - $this->value = $value; - } - - public function getValue() - { - return $this->value; - } - - public function visit(ExpressionVisitor $visitor) - { - return $visitor->walkValue($this); - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/ExpressionBuilder.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/ExpressionBuilder.php deleted file mode 100644 index b53f0cd..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/ExpressionBuilder.php +++ /dev/null @@ -1,149 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections; - -use Doctrine\Common\Collections\Expr\Comparison; -use Doctrine\Common\Collections\Expr\CompositeExpression; -use Doctrine\Common\Collections\Expr\Value; - -/** - * Builder for Expressions in the {@link Selectable} interface. - * - * @author Benjamin Eberlei - * @since 2.3 - */ -class ExpressionBuilder -{ - /** - * @return CompositeExpression - */ - public function andX($x = null) - { - return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args()); - } - - /** - * @return CompositeExpression - */ - public function orX($x = null) - { - return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args()); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function eq($field, $value) - { - return new Comparison($field, Comparison::EQ, new Value($value)); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function gt($field, $value) - { - return new Comparison($field, Comparison::GT, new Value($value)); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function lt($field, $value) - { - return new Comparison($field, Comparison::LT, new Value($value)); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function gte($field, $value) - { - return new Comparison($field, Comparison::GTE, new Value($value)); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function lte($field, $value) - { - return new Comparison($field, Comparison::LTE, new Value($value)); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function neq($field, $value) - { - return new Comparison($field, Comparison::NEQ, new Value($value)); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function isNull($field) - { - return new Comparison($field, Comparison::IS, new Value(null)); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function in($field, array $values) - { - return new Comparison($field, Comparison::IN, new Value($values)); - } - - /** - * @param string $field - * @param mixed $value - * - * @return Comparison - */ - public function notIn($field, array $values) - { - return new Comparison($field, Comparison::NIN, new Value($values)); - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Selectable.php b/vendor/doctrine/common/lib/Doctrine/Common/Collections/Selectable.php deleted file mode 100644 index 675d6ea..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Collections/Selectable.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -namespace Doctrine\Common\Collections; - -/** - * Interface for collections that allow efficient filtering with an expression API. - * - * Goal of this interface is a backend independent method to fetch elements - * from a collections. {@link Expression} is crafted in a way that you can - * implement queries from both in-memory and database-backed collections. - * - * For database backed collections this allows very efficient access by - * utilizing the query APIs, for example SQL in the ORM. Applications using - * this API can implement efficient database access without having to ask the - * EntityManager or Repositories. - * - * @author Benjamin Eberlei - * @since 2.3 - */ -interface Selectable -{ - /** - * Select all elements from a selectable that match the expression and - * return a new collection containing these elements. - * - * @param Criteria $criteria - * @return Collection - */ - function matching(Criteria $criteria); -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/CommonException.php b/vendor/doctrine/common/lib/Doctrine/Common/CommonException.php deleted file mode 100644 index 6db7675..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/CommonException.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * Base exception class for package Doctrine\Common - * @author heinrich - * - */ -class CommonException extends \Exception { -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Comparable.php b/vendor/doctrine/common/lib/Doctrine/Common/Comparable.php deleted file mode 100644 index 20d065e..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Comparable.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - - -namespace Doctrine\Common; - -/** - * Comparable interface that allows to compare two value objects to each other for similarity. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - */ -interface Comparable -{ - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantical equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other - * - * @return int - */ - public function compareTo($other); -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/EventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/EventArgs.php deleted file mode 100644 index a87eee8..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/EventArgs.php +++ /dev/null @@ -1,67 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * EventArgs is the base class for classes containing event data. - * - * This class contains no event data. It is used by events that do not pass state - * information to an event handler when an event is raised. The single empty EventArgs - * instance can be obtained through {@link getEmptyInstance}. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision: 3938 $ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -class EventArgs -{ - /** - * @var EventArgs Single instance of EventArgs - */ - private static $_emptyEventArgsInstance; - - /** - * Gets the single, empty and immutable EventArgs instance. - * - * This instance will be used when events are dispatched without any parameter, - * like this: EventManager::dispatchEvent('eventname'); - * - * The benefit from this is that only one empty instance is instantiated and shared - * (otherwise there would be instances for every dispatched in the abovementioned form) - * - * @see EventManager::dispatchEvent - * @link http://msdn.microsoft.com/en-us/library/system.eventargs.aspx - * @return EventArgs - */ - public static function getEmptyInstance() - { - if ( ! self::$_emptyEventArgsInstance) { - self::$_emptyEventArgsInstance = new EventArgs; - } - - return self::$_emptyEventArgsInstance; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php b/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php deleted file mode 100644 index 25aac44..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php +++ /dev/null @@ -1,147 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * The EventManager is the central point of Doctrine's event listener system. - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision: 3938 $ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -class EventManager -{ - /** - * Map of registered listeners. - * => - * - * @var array - */ - private $_listeners = array(); - - /** - * Dispatches an event to all registered listeners. - * - * @param string $eventName The name of the event to dispatch. The name of the event is - * the name of the method that is invoked on listeners. - * @param EventArgs $eventArgs The event arguments to pass to the event handlers/listeners. - * If not supplied, the single empty EventArgs instance is used. - * @return boolean - */ - public function dispatchEvent($eventName, EventArgs $eventArgs = null) - { - if (isset($this->_listeners[$eventName])) { - $eventArgs = $eventArgs === null ? EventArgs::getEmptyInstance() : $eventArgs; - - foreach ($this->_listeners[$eventName] as $listener) { - $listener->$eventName($eventArgs); - } - } - } - - /** - * Gets the listeners of a specific event or all listeners. - * - * @param string $event The name of the event. - * @return array The event listeners for the specified event, or all event listeners. - */ - public function getListeners($event = null) - { - return $event ? $this->_listeners[$event] : $this->_listeners; - } - - /** - * Checks whether an event has any registered listeners. - * - * @param string $event - * @return boolean TRUE if the specified event has any listeners, FALSE otherwise. - */ - public function hasListeners($event) - { - return isset($this->_listeners[$event]) && $this->_listeners[$event]; - } - - /** - * Adds an event listener that listens on the specified events. - * - * @param string|array $events The event(s) to listen on. - * @param object $listener The listener object. - */ - public function addEventListener($events, $listener) - { - // Picks the hash code related to that listener - $hash = spl_object_hash($listener); - - foreach ((array) $events as $event) { - // Overrides listener if a previous one was associated already - // Prevents duplicate listeners on same event (same instance only) - $this->_listeners[$event][$hash] = $listener; - } - } - - /** - * Removes an event listener from the specified events. - * - * @param string|array $events - * @param object $listener - */ - public function removeEventListener($events, $listener) - { - // Picks the hash code related to that listener - $hash = spl_object_hash($listener); - - foreach ((array) $events as $event) { - // Check if actually have this listener associated - if (isset($this->_listeners[$event][$hash])) { - unset($this->_listeners[$event][$hash]); - } - } - } - - /** - * Adds an EventSubscriber. The subscriber is asked for all the events he is - * interested in and added as a listener for these events. - * - * @param \Doctrine\Common\EventSubscriber $subscriber The subscriber. - */ - public function addEventSubscriber(EventSubscriber $subscriber) - { - $this->addEventListener($subscriber->getSubscribedEvents(), $subscriber); - } - - /** - * Removes an EventSubscriber. The subscriber is asked for all the events it is - * interested in and removed as a listener for these events. - * - * @param \Doctrine\Common\EventSubscriber $subscriber The subscriber. - */ - public function removeEventSubscriber(EventSubscriber $subscriber) - { - $this->removeEventListener($subscriber->getSubscribedEvents(), $subscriber); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/EventSubscriber.php b/vendor/doctrine/common/lib/Doctrine/Common/EventSubscriber.php deleted file mode 100644 index 1458791..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/EventSubscriber.php +++ /dev/null @@ -1,45 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * An EventSubscriber knows himself what events he is interested in. - * If an EventSubscriber is added to an EventManager, the manager invokes - * {@link getSubscribedEvents} and registers the subscriber as a listener for all - * returned events. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -interface EventSubscriber -{ - /** - * Returns an array of events this subscriber wants to listen to. - * - * @return array - */ - function getSubscribedEvents(); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php b/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php deleted file mode 100644 index 8e2554c..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php +++ /dev/null @@ -1,266 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * Base class for writing simple lexers, i.e. for creating small DSLs. - * - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @todo Rename: AbstractLexer - */ -abstract class Lexer -{ - /** - * @var array Array of scanned tokens - */ - private $tokens = array(); - - /** - * @var integer Current lexer position in input string - */ - private $position = 0; - - /** - * @var integer Current peek of current lexer position - */ - private $peek = 0; - - /** - * @var array The next token in the input. - */ - public $lookahead; - - /** - * @var array The last matched/seen token. - */ - public $token; - - /** - * Sets the input data to be tokenized. - * - * The Lexer is immediately reset and the new input tokenized. - * Any unprocessed tokens from any previous input are lost. - * - * @param string $input The input to be tokenized. - */ - public function setInput($input) - { - $this->tokens = array(); - $this->reset(); - $this->scan($input); - } - - /** - * Resets the lexer. - */ - public function reset() - { - $this->lookahead = null; - $this->token = null; - $this->peek = 0; - $this->position = 0; - } - - /** - * Resets the peek pointer to 0. - */ - public function resetPeek() - { - $this->peek = 0; - } - - /** - * Resets the lexer position on the input to the given position. - * - * @param integer $position Position to place the lexical scanner - */ - public function resetPosition($position = 0) - { - $this->position = $position; - } - - /** - * Checks whether a given token matches the current lookahead. - * - * @param integer|string $token - * @return boolean - */ - public function isNextToken($token) - { - return null !== $this->lookahead && $this->lookahead['type'] === $token; - } - - /** - * Checks whether any of the given tokens matches the current lookahead - * - * @param array $tokens - * @return boolean - */ - public function isNextTokenAny(array $tokens) - { - return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true); - } - - /** - * Moves to the next token in the input string. - * - * A token is an associative array containing three items: - * - 'value' : the string value of the token in the input string - * - 'type' : the type of the token (identifier, numeric, string, input - * parameter, none) - * - 'position' : the position of the token in the input string - * - * @return array|null the next token; null if there is no more tokens left - */ - public function moveNext() - { - $this->peek = 0; - $this->token = $this->lookahead; - $this->lookahead = (isset($this->tokens[$this->position])) - ? $this->tokens[$this->position++] : null; - - return $this->lookahead !== null; - } - - /** - * Tells the lexer to skip input tokens until it sees a token with the given value. - * - * @param string $type The token type to skip until. - */ - public function skipUntil($type) - { - while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { - $this->moveNext(); - } - } - - /** - * Checks if given value is identical to the given token - * - * @param mixed $value - * @param integer $token - * @return boolean - */ - public function isA($value, $token) - { - return $this->getType($value) === $token; - } - - /** - * Moves the lookahead token forward. - * - * @return array | null The next token or NULL if there are no more tokens ahead. - */ - public function peek() - { - if (isset($this->tokens[$this->position + $this->peek])) { - return $this->tokens[$this->position + $this->peek++]; - } else { - return null; - } - } - - /** - * Peeks at the next token, returns it and immediately resets the peek. - * - * @return array|null The next token or NULL if there are no more tokens ahead. - */ - public function glimpse() - { - $peek = $this->peek(); - $this->peek = 0; - return $peek; - } - - /** - * Scans the input string for tokens. - * - * @param string $input a query string - */ - protected function scan($input) - { - static $regex; - - if ( ! isset($regex)) { - $regex = '/(' . implode(')|(', $this->getCatchablePatterns()) . ')|' - . implode('|', $this->getNonCatchablePatterns()) . '/i'; - } - - $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; - $matches = preg_split($regex, $input, -1, $flags); - - foreach ($matches as $match) { - // Must remain before 'value' assignment since it can change content - $type = $this->getType($match[0]); - - $this->tokens[] = array( - 'value' => $match[0], - 'type' => $type, - 'position' => $match[1], - ); - } - } - - /** - * Gets the literal for a given token. - * - * @param integer $token - * @return string - */ - public function getLiteral($token) - { - $className = get_class($this); - $reflClass = new \ReflectionClass($className); - $constants = $reflClass->getConstants(); - - foreach ($constants as $name => $value) { - if ($value === $token) { - return $className . '::' . $name; - } - } - - return $token; - } - - /** - * Lexical catchable patterns. - * - * @return array - */ - abstract protected function getCatchablePatterns(); - - /** - * Lexical non-catchable patterns. - * - * @return array - */ - abstract protected function getNonCatchablePatterns(); - - /** - * Retrieve token type. Also processes the token value if necessary. - * - * @param string $value - * @return integer - */ - abstract protected function getType(&$value); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/NotifyPropertyChanged.php b/vendor/doctrine/common/lib/Doctrine/Common/NotifyPropertyChanged.php deleted file mode 100644 index e32c0b9..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/NotifyPropertyChanged.php +++ /dev/null @@ -1,45 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * Contract for classes that provide the service of notifying listeners of - * changes to their properties. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision: 3938 $ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -interface NotifyPropertyChanged -{ - /** - * Adds a listener that wants to be notified about property changes. - * - * @param PropertyChangedListener $listener - */ - function addPropertyChangedListener(PropertyChangedListener $listener); -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php deleted file mode 100644 index 94fcd05..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php +++ /dev/null @@ -1,259 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence; - -use Doctrine\Common\Persistence\ManagerRegistry; - -/** - * Abstract implementation of the ManagerRegistry contract. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Fabien Potencier - * @author Benjamin Eberlei - * @author Lukas Kahwe Smith - */ -abstract class AbstractManagerRegistry implements ManagerRegistry -{ - /** - * @var string - */ - private $name; - - /** - * @var array - */ - private $connections; - - /** - * @var array - */ - private $managers; - - /** - * @var string - */ - private $defaultConnection; - - /** - * @var string - */ - private $defaultManager; - - /** - * @var string - */ - private $proxyInterfaceName; - - /** - * Constructor - * - * @param string $name - * @param array $connections - * @param array $managers - * @param string $defaultConnection - * @param string $defaultManager - * @param string $proxyInterfaceName - */ - public function __construct($name, array $connections, array $managers, $defaultConnection, $defaultManager, $proxyInterfaceName) - { - $this->name = $name; - $this->connections = $connections; - $this->managers = $managers; - $this->defaultConnection = $defaultConnection; - $this->defaultManager = $defaultManager; - $this->proxyInterfaceName = $proxyInterfaceName; - } - - /** - * Fetches/creates the given services - * - * A service in this context is connection or a manager instance - * - * @param string $name name of the service - * @return object instance of the given service - */ - abstract protected function getService($name); - - /** - * Resets the given services - * - * A service in this context is connection or a manager instance - * - * @param string $name name of the service - * @return void - */ - abstract protected function resetService($name); - - /** - * Get the name of the registry - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getConnection($name = null) - { - if (null === $name) { - $name = $this->defaultConnection; - } - - if (!isset($this->connections[$name])) { - throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->name, $name)); - } - - return $this->getService($this->connections[$name]); - } - - /** - * {@inheritdoc} - */ - public function getConnectionNames() - { - return $this->connections; - } - - /** - * {@inheritdoc} - */ - public function getConnections() - { - $connections = array(); - foreach ($this->connections as $name => $id) { - $connections[$name] = $this->getService($id); - } - - return $connections; - } - - /** - * {@inheritdoc} - */ - public function getDefaultConnectionName() - { - return $this->defaultConnection; - } - - /** - * {@inheritdoc} - */ - public function getDefaultManagerName() - { - return $this->defaultManager; - } - - /** - * {@inheritdoc} - * - * @throws \InvalidArgumentException - */ - public function getManager($name = null) - { - if (null === $name) { - $name = $this->defaultManager; - } - - if (!isset($this->managers[$name])) { - throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name)); - } - - return $this->getService($this->managers[$name]); - } - - /** - * {@inheritdoc} - */ - public function getManagerForClass($class) - { - // Check for namespace alias - if (strpos($class, ':') !== false) { - list($namespaceAlias, $simpleClassName) = explode(':', $class); - $class = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName; - } - - $proxyClass = new \ReflectionClass($class); - if ($proxyClass->implementsInterface($this->proxyInterfaceName)) { - $class = $proxyClass->getParentClass()->getName(); - } - - foreach ($this->managers as $id) { - $manager = $this->getService($id); - - if (!$manager->getMetadataFactory()->isTransient($class)) { - return $manager; - } - } - } - - /** - * {@inheritdoc} - */ - public function getManagerNames() - { - return $this->managers; - } - - /** - * {@inheritdoc} - */ - public function getManagers() - { - $dms = array(); - foreach ($this->managers as $name => $id) { - $dms[$name] = $this->getService($id); - } - - return $dms; - } - - /** - * {@inheritdoc} - */ - public function getRepository($persistentObjectName, $persistentManagerName = null) - { - return $this->getManager($persistentManagerName)->getRepository($persistentObjectName); - } - - /** - * {@inheritdoc} - */ - public function resetManager($name = null) - { - if (null === $name) { - $name = $this->defaultManager; - } - - if (!isset($this->managers[$name])) { - throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name)); - } - - // force the creation of a new document manager - // if the current one is closed - $this->resetService($this->managers[$name]); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php deleted file mode 100644 index 7d6f0cf..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php +++ /dev/null @@ -1,63 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence; - -/** - * Contract covering connection for a Doctrine persistence layer ManagerRegistry class to implement. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Fabien Potencier - * @author Benjamin Eberlei - * @author Lukas Kahwe Smith - */ -interface ConnectionRegistry -{ - /** - * Gets the default connection name. - * - * @return string The default connection name - */ - function getDefaultConnectionName(); - - /** - * Gets the named connection. - * - * @param string $name The connection name (null for the default one) - * - * @return object - */ - function getConnection($name = null); - - /** - * Gets an array of all registered connections - * - * @return array An array of Connection instances - */ - function getConnections(); - - /** - * Gets all connection names. - * - * @return array An array of connection names - */ - function getConnectionNames(); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php deleted file mode 100644 index 2fb7c47..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php +++ /dev/null @@ -1,77 +0,0 @@ -. -*/ - -namespace Doctrine\Common\Persistence\Event; - -use Doctrine\Common\EventArgs; -use Doctrine\Common\Persistence\ObjectManager; - -/** - * Lifecycle Events are triggered by the UnitOfWork during lifecycle transitions - * of entities. - * - * @link www.doctrine-project.org - * @since 2.2 - * @author Roman Borschel - * @author Benjamin Eberlei - */ -class LifecycleEventArgs extends EventArgs -{ - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var object - */ - private $entity; - - /** - * Constructor - * - * @param object $entity - * @param ObjectManager $objectManager - */ - public function __construct($entity, ObjectManager $objectManager) - { - $this->entity = $entity; - $this->objectManager = $objectManager; - } - - /** - * Retrieve associated Entity. - * - * @return object - */ - public function getEntity() - { - return $this->entity; - } - - /** - * Retrieve associated ObjectManager. - * - * @return ObjectManager - */ - public function getObjectManager() - { - return $this->objectManager; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php deleted file mode 100644 index c014d73..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php +++ /dev/null @@ -1,76 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Event; - -use Doctrine\Common\EventArgs; -use Doctrine\Common\Persistence\ObjectManager; -use Doctrine\Common\Persistence\Mapping\ClassMetadata; - -/** - * Class that holds event arguments for a loadMetadata event. - * - * @author Jonathan H. Wage - * @since 2.2 - */ -class LoadClassMetadataEventArgs extends EventArgs -{ - /** - * @var ClassMetadata - */ - private $classMetadata; - - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * Constructor. - * - * @param ClassMetadata $classMetadata - * @param ObjectManager $objectManager - */ - public function __construct(ClassMetadata $classMetadata, ObjectManager $objectManager) - { - $this->classMetadata = $classMetadata; - $this->objectManager = $objectManager; - } - - /** - * Retrieve associated ClassMetadata. - * - * @return ClassMetadata - */ - public function getClassMetadata() - { - return $this->classMetadata; - } - - /** - * Retrieve associated ObjectManager. - * - * @return ObjectManager - */ - public function getObjectManager() - { - return $this->objectManager; - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php deleted file mode 100644 index f139365..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php +++ /dev/null @@ -1,59 +0,0 @@ -. -*/ - -namespace Doctrine\Common\Persistence\Event; - -use Doctrine\Common\Persistence\ObjectManager; - -/** - * Provides event arguments for the preFlush event. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Roman Borschel - * @author Benjamin Eberlei - */ -class ManagerEventArgs extends \Doctrine\Common\EventArgs -{ - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * Constructor. - * - * @param ObjectManager $objectManager - */ - public function __construct(ObjectManager $objectManager) - { - $this->objectManager = $objectManager; - } - - /** - * Retrieve associated ObjectManager. - * - * @return ObjectManager - */ - public function getObjectManager() - { - return $this->objectManager; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php deleted file mode 100644 index 18b6554..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php +++ /dev/null @@ -1,84 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Event; - -/** - * Provides event arguments for the onClear event. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Roman Borschel - * @author Benjamin Eberlei - */ -class OnClearEventArgs extends \Doctrine\Common\EventArgs -{ - /** - * @var \Doctrine\Common\Persistence\ObjectManager - */ - private $objectManager; - - /** - * @var string - */ - private $entityClass; - - /** - * Constructor. - * - * @param \Doctrine\Common\Persistence\ObjectManager $objectManager - * @param string $entityClass Optional entity class - */ - public function __construct($objectManager, $entityClass = null) - { - $this->objectManager = $objectManager; - $this->entityClass = $entityClass; - } - - /** - * Retrieve associated ObjectManager. - * - * @return \Doctrine\Common\Persistence\ObjectManager - */ - public function getObjectManager() - { - return $this->objectManager; - } - - /** - * Name of the entity class that is cleared, or empty if all are cleared. - * - * @return string - */ - public function getEntityClass() - { - return $this->entityClass; - } - - /** - * Check if event clears all entities. - * - * @return bool - */ - public function clearsAllEntities() - { - return ($this->entityClass === null); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php deleted file mode 100644 index 86ac819..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php +++ /dev/null @@ -1,133 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Event; - -use Doctrine\Common\EventArgs, - Doctrine\Common\Persistence\ObjectManager; - -/** - * Class that holds event arguments for a preUpdate event. - * - * @author Guilherme Blanco - * @author Roman Borschel - * @author Benjamin Eberlei - * @since 2.2 - */ -class PreUpdateEventArgs extends LifecycleEventArgs -{ - /** - * @var array - */ - private $entityChangeSet; - - /** - * Constructor. - * - * @param object $entity - * @param ObjectManager $objectManager - * @param array $changeSet - */ - public function __construct($entity, ObjectManager $objectManager, array &$changeSet) - { - parent::__construct($entity, $objectManager); - - $this->entityChangeSet = &$changeSet; - } - - /** - * Retrieve entity changeset. - * - * @return array - */ - public function getEntityChangeSet() - { - return $this->entityChangeSet; - } - - /** - * Check if field has a changeset. - * - * @param string $field - * - * @return boolean - */ - public function hasChangedField($field) - { - return isset($this->entityChangeSet[$field]); - } - - /** - * Get the old value of the changeset of the changed field. - * - * @param string $field - * @return mixed - */ - public function getOldValue($field) - { - $this->assertValidField($field); - - return $this->entityChangeSet[$field][0]; - } - - /** - * Get the new value of the changeset of the changed field. - * - * @param string $field - * @return mixed - */ - public function getNewValue($field) - { - $this->assertValidField($field); - - return $this->entityChangeSet[$field][1]; - } - - /** - * Set the new value of this field. - * - * @param string $field - * @param mixed $value - */ - public function setNewValue($field, $value) - { - $this->assertValidField($field); - - $this->entityChangeSet[$field][1] = $value; - } - - /** - * Assert the field exists in changeset. - * - * @param string $field - * - * @throws \InvalidArgumentException - */ - private function assertValidField($field) - { - if ( ! isset($this->entityChangeSet[$field])) { - throw new \InvalidArgumentException(sprintf( - 'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.', - $field, - get_class($this->getEntity()) - )); - } - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php deleted file mode 100644 index bdb23bd..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php +++ /dev/null @@ -1,112 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence; - -/** - * Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Fabien Potencier - * @author Benjamin Eberlei - * @author Lukas Kahwe Smith - */ -interface ManagerRegistry extends ConnectionRegistry -{ - /** - * Gets the default object manager name. - * - * @return string The default object manager name - */ - function getDefaultManagerName(); - - /** - * Gets a named object manager. - * - * @param string $name The object manager name (null for the default one) - * - * @return \Doctrine\Common\Persistence\ObjectManager - */ - function getManager($name = null); - - /** - * Gets an array of all registered object managers - * - * @return \Doctrine\Common\Persistence\ObjectManager[] An array of ObjectManager instances - */ - function getManagers(); - - /** - * Resets a named object manager. - * - * This method is useful when an object manager has been closed - * because of a rollbacked transaction AND when you think that - * it makes sense to get a new one to replace the closed one. - * - * Be warned that you will get a brand new object manager as - * the existing one is not useable anymore. This means that any - * other object with a dependency on this object manager will - * hold an obsolete reference. You can inject the registry instead - * to avoid this problem. - * - * @param string $name The object manager name (null for the default one) - * - * @return \Doctrine\Common\Persistence\ObjectManager - */ - function resetManager($name = null); - - /** - * Resolves a registered namespace alias to the full namespace. - * - * This method looks for the alias in all registered object managers. - * - * @param string $alias The alias - * - * @return string The full namespace - */ - function getAliasNamespace($alias); - - /** - * Gets all connection names. - * - * @return array An array of connection names - */ - function getManagerNames(); - - /** - * Gets the ObjectRepository for an persistent object. - * - * @param string $persistentObject The name of the persistent object. - * @param string $persistentManagerName The object manager name (null for the default one) - * - * @return \Doctrine\Common\Persistence\ObjectRepository - */ - function getRepository($persistentObject, $persistentManagerName = null); - - /** - * Gets the object manager associated with a given class. - * - * @param string $class A persistent object class name - * - * @return \Doctrine\Common\Persistence\ObjectManager|null - */ - function getManagerForClass($class); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php deleted file mode 100644 index 1ace1cc..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php +++ /dev/null @@ -1,383 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping; - -use Doctrine\Common\Cache\Cache, - Doctrine\Common\Util\ClassUtils; - -/** - * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the - * metadata mapping informations of a class which describes how a class should be mapped - * to a relational database. - * - * This class was abstracted from the ORM ClassMetadataFactory - * - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -abstract class AbstractClassMetadataFactory implements ClassMetadataFactory -{ - /** - * Salt used by specific Object Manager implementation. - * - * @var string - */ - protected $cacheSalt = "\$CLASSMETADATA"; - - /** - * @var \Doctrine\Common\Cache\Cache - */ - private $cacheDriver; - - /** - * @var array - */ - private $loadedMetadata = array(); - - /** - * @var bool - */ - protected $initialized = false; - - /** - * @var ReflectionService - */ - private $reflectionService; - - /** - * Sets the cache driver used by the factory to cache ClassMetadata instances. - * - * @param Doctrine\Common\Cache\Cache $cacheDriver - */ - public function setCacheDriver(Cache $cacheDriver = null) - { - $this->cacheDriver = $cacheDriver; - } - - /** - * Gets the cache driver used by the factory to cache ClassMetadata instances. - * - * @return Doctrine\Common\Cache\Cache - */ - public function getCacheDriver() - { - return $this->cacheDriver; - } - - /** - * Return an array of all the loaded metadata currently in memory. - * - * @return array - */ - public function getLoadedMetadata() - { - return $this->loadedMetadata; - } - - /** - * Forces the factory to load the metadata of all classes known to the underlying - * mapping driver. - * - * @return array The ClassMetadata instances of all mapped classes. - */ - public function getAllMetadata() - { - if ( ! $this->initialized) { - $this->initialize(); - } - - $driver = $this->getDriver(); - $metadata = array(); - foreach ($driver->getAllClassNames() as $className) { - $metadata[] = $this->getMetadataFor($className); - } - - return $metadata; - } - - /** - * Lazy initialization of this stuff, especially the metadata driver, - * since these are not needed at all when a metadata cache is active. - * - * @return void - */ - abstract protected function initialize(); - - /** - * Get the fully qualified class-name from the namespace alias. - * - * @param string $namespaceAlias - * @param string $simpleClassName - * @return string - */ - abstract protected function getFqcnFromAlias($namespaceAlias, $simpleClassName); - - /** - * Return the mapping driver implementation. - * - * @return \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver - */ - abstract protected function getDriver(); - - /** - * Wakeup reflection after ClassMetadata gets unserialized from cache. - * - * @param ClassMetadata $class - * @param ReflectionService $reflService - * @return void - */ - abstract protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService); - - /** - * Initialize Reflection after ClassMetadata was constructed. - * - * @param ClassMetadata $class - * @param ReflectionService $reflService - * @return void - */ - abstract protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService); - - /** - * Checks whether the class metadata is an entity. - * - * This method should false for mapped superclasses or - * embedded classes. - * - * @param ClassMetadata $class - * @return boolean - */ - abstract protected function isEntity(ClassMetadata $class); - - /** - * Gets the class metadata descriptor for a class. - * - * @param string $className The name of the class. - * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata - */ - public function getMetadataFor($className) - { - if (isset($this->loadedMetadata[$className])) { - return $this->loadedMetadata[$className]; - } - - $realClassName = $className; - - // Check for namespace alias - if (strpos($className, ':') !== false) { - list($namespaceAlias, $simpleClassName) = explode(':', $className); - $realClassName = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName); - } else { - $realClassName = ClassUtils::getRealClass($realClassName); - } - - if (isset($this->loadedMetadata[$realClassName])) { - // We do not have the alias name in the map, include it - $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName]; - - return $this->loadedMetadata[$realClassName]; - } - - if ($this->cacheDriver) { - if (($cached = $this->cacheDriver->fetch($realClassName . $this->cacheSalt)) !== false) { - $this->loadedMetadata[$realClassName] = $cached; - $this->wakeupReflection($cached, $this->getReflectionService()); - } else { - foreach ($this->loadMetadata($realClassName) as $loadedClassName) { - $this->cacheDriver->save( - $loadedClassName . $this->cacheSalt, $this->loadedMetadata[$loadedClassName], null - ); - } - } - } else { - $this->loadMetadata($realClassName); - } - - if ($className != $realClassName) { - // We do not have the alias name in the map, include it - $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName]; - } - - return $this->loadedMetadata[$className]; - } - - /** - * Checks whether the factory has the metadata for a class loaded already. - * - * @param string $className - * @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise. - */ - public function hasMetadataFor($className) - { - return isset($this->loadedMetadata[$className]); - } - - /** - * Sets the metadata descriptor for a specific class. - * - * NOTE: This is only useful in very special cases, like when generating proxy classes. - * - * @param string $className - * @param ClassMetadata $class - */ - public function setMetadataFor($className, $class) - { - $this->loadedMetadata[$className] = $class; - } - - /** - * Get array of parent classes for the given entity class - * - * @param string $name - * @return array $parentClasses - */ - protected function getParentClasses($name) - { - // Collect parent classes, ignoring transient (not-mapped) classes. - $parentClasses = array(); - foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) { - if ( ! $this->getDriver()->isTransient($parentClass)) { - $parentClasses[] = $parentClass; - } - } - return $parentClasses; - } - - /** - * Loads the metadata of the class in question and all it's ancestors whose metadata - * is still not loaded. - * - * @param string $name The name of the class for which the metadata should get loaded. - * - * @return array - */ - protected function loadMetadata($name) - { - if ( ! $this->initialized) { - $this->initialize(); - } - - $loaded = array(); - - $parentClasses = $this->getParentClasses($name); - $parentClasses[] = $name; - - // Move down the hierarchy of parent classes, starting from the topmost class - $parent = null; - $rootEntityFound = false; - $visited = array(); - $reflService = $this->getReflectionService(); - foreach ($parentClasses as $className) { - if (isset($this->loadedMetadata[$className])) { - $parent = $this->loadedMetadata[$className]; - if ($this->isEntity($parent)) { - $rootEntityFound = true; - array_unshift($visited, $className); - } - continue; - } - - $class = $this->newClassMetadataInstance($className); - $this->initializeReflection($class, $reflService); - - $this->doLoadMetadata($class, $parent, $rootEntityFound, $visited); - - $this->loadedMetadata[$className] = $class; - - $parent = $class; - - if ($this->isEntity($class)) { - $rootEntityFound = true; - array_unshift($visited, $className); - } - - $this->wakeupReflection($class, $reflService); - - $loaded[] = $className; - } - - return $loaded; - } - - /** - * Actually load the metadata from the underlying metadata - * - * @param ClassMetadata $class - * @param ClassMetadata|null $parent - * @param bool $rootEntityFound - * @param array $nonSuperclassParents classnames all parent classes that are not marked as mapped superclasses - * @return void - */ - abstract protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents); - - /** - * Creates a new ClassMetadata instance for the given class name. - * - * @param string $className - * @return ClassMetadata - */ - abstract protected function newClassMetadataInstance($className); - - /** - * Check if this class is mapped by this Object Manager + ClassMetadata configuration - * - * @param $class - * @return bool - */ - public function isTransient($class) - { - if ( ! $this->initialized) { - $this->initialize(); - } - - // Check for namespace alias - if (strpos($class, ':') !== false) { - list($namespaceAlias, $simpleClassName) = explode(':', $class); - $class = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName); - } - - return $this->getDriver()->isTransient($class); - } - - /** - * Set reflectionService. - * - * @param ReflectionService $reflectionService - */ - public function setReflectionService(ReflectionService $reflectionService) - { - $this->reflectionService = $reflectionService; - } - - /** - * Get the reflection service associated with this metadata factory. - * - * @return ReflectionService - */ - public function getReflectionService() - { - if ($this->reflectionService === null) { - $this->reflectionService = new RuntimeReflectionService(); - } - return $this->reflectionService; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php deleted file mode 100644 index 4836bf8..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php +++ /dev/null @@ -1,165 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping; - -/** - * Contract for a Doctrine persistence layer ClassMetadata class to implement. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Benjamin Eberlei - * @author Jonathan Wage - */ -interface ClassMetadata -{ - /** - * Get fully-qualified class name of this persistent class. - * - * @return string - */ - function getName(); - - /** - * Gets the mapped identifier field name. - * - * The returned structure is an array of the identifier field names. - * - * @return array - */ - function getIdentifier(); - - /** - * Gets the ReflectionClass instance for this mapped class. - * - * @return \ReflectionClass - */ - function getReflectionClass(); - - /** - * Checks if the given field name is a mapped identifier for this class. - * - * @param string $fieldName - * @return boolean - */ - function isIdentifier($fieldName); - - /** - * Checks if the given field is a mapped property for this class. - * - * @param string $fieldName - * @return boolean - */ - function hasField($fieldName); - - /** - * Checks if the given field is a mapped association for this class. - * - * @param string $fieldName - * @return boolean - */ - function hasAssociation($fieldName); - - /** - * Checks if the given field is a mapped single valued association for this class. - * - * @param string $fieldName - * @return boolean - */ - function isSingleValuedAssociation($fieldName); - - /** - * Checks if the given field is a mapped collection valued association for this class. - * - * @param string $fieldName - * @return boolean - */ - function isCollectionValuedAssociation($fieldName); - - /** - * A numerically indexed list of field names of this persistent class. - * - * This array includes identifier fields if present on this class. - * - * @return array - */ - function getFieldNames(); - - /** - * Returns an array of identifier field names numerically indexed. - * - * @return array - */ - function getIdentifierFieldNames(); - - /** - * A numerically indexed list of association names of this persistent class. - * - * This array includes identifier associations if present on this class. - * - * @return array - */ - function getAssociationNames(); - - /** - * Returns a type name of this field. - * - * This type names can be implementation specific but should at least include the php types: - * integer, string, boolean, float/double, datetime. - * - * @param string $fieldName - * @return string - */ - function getTypeOfField($fieldName); - - /** - * Returns the target class name of the given association. - * - * @param string $assocName - * @return string - */ - function getAssociationTargetClass($assocName); - - /** - * Checks if the association is the inverse side of a bidirectional association - * - * @param string $assocName - * @return boolean - */ - function isAssociationInverseSide($assocName); - - /** - * Returns the target field of the owning side of the association - * - * @param string $assocName - * @return string - */ - function getAssociationMappedByTargetField($assocName); - - /** - * Return the identifier of this object as an array with field name as key. - * - * Has to return an empty array if no identifier isset. - * - * @param object $object - * @return array - */ - function getIdentifierValues($object); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php deleted file mode 100644 index 3fa39bc..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php +++ /dev/null @@ -1,74 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping; - -/** - * Contract for a Doctrine persistence layer ClassMetadata class to implement. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Benjamin Eberlei - * @author Jonathan Wage - */ -interface ClassMetadataFactory -{ - /** - * Forces the factory to load the metadata of all classes known to the underlying - * mapping driver. - * - * @return array The ClassMetadata instances of all mapped classes. - */ - function getAllMetadata(); - - /** - * Gets the class metadata descriptor for a class. - * - * @param string $className The name of the class. - * @return ClassMetadata - */ - function getMetadataFor($className); - - /** - * Checks whether the factory has the metadata for a class loaded already. - * - * @param string $className - * @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise. - */ - function hasMetadataFor($className); - - /** - * Sets the metadata descriptor for a specific class. - * - * @param string $className - * @param ClassMetadata $class - */ - function setMetadataFor($className, $class); - - /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped directly or as a - * MappedSuperclass. - * - * @param string $className - * @return boolean - */ - function isTransient($className); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php deleted file mode 100644 index 1131add..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php +++ /dev/null @@ -1,214 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -use Doctrine\Common\Cache\ArrayCache, - Doctrine\Common\Annotations\AnnotationReader, - Doctrine\Common\Annotations\AnnotationRegistry, - Doctrine\Common\Persistence\Mapping\MappingException; - -/** - * The AnnotationDriver reads the mapping metadata from docblock annotations. - * - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel - */ -abstract class AnnotationDriver implements MappingDriver -{ - /** - * The AnnotationReader. - * - * @var AnnotationReader - */ - protected $reader; - - /** - * The paths where to look for mapping files. - * - * @var array - */ - protected $paths = array(); - - /** - * The file extension of mapping documents. - * - * @var string - */ - protected $fileExtension = '.php'; - - /** - * Cache for AnnotationDriver#getAllClassNames() - * - * @var array - */ - protected $classNames; - - /** - * Name of the entity annotations as keys - * - * @var array - */ - protected $entityAnnotationClasses = array(); - - /** - * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading - * docblock annotations. - * - * @param AnnotationReader $reader The AnnotationReader to use, duck-typed. - * @param string|array $paths One or multiple paths where mapping classes can be found. - */ - public function __construct($reader, $paths = null) - { - $this->reader = $reader; - if ($paths) { - $this->addPaths((array) $paths); - } - } - - /** - * Append lookup paths to metadata driver. - * - * @param array $paths - */ - public function addPaths(array $paths) - { - $this->paths = array_unique(array_merge($this->paths, $paths)); - } - - /** - * Retrieve the defined metadata lookup paths. - * - * @return array - */ - public function getPaths() - { - return $this->paths; - } - - /** - * Retrieve the current annotation reader - * - * @return AnnotationReader - */ - public function getReader() - { - return $this->reader; - } - - /** - * Get the file extension used to look for mapping files under - * - * @return string - */ - public function getFileExtension() - { - return $this->fileExtension; - } - - /** - * Set the file extension used to look for mapping files under - * - * @param string $fileExtension The file extension to set - * @return void - */ - public function setFileExtension($fileExtension) - { - $this->fileExtension = $fileExtension; - } - - /** - * Whether the class with the specified name is transient. Only non-transient - * classes, that is entities and mapped superclasses, should have their metadata loaded. - * - * A class is non-transient if it is annotated with an annotation - * from the {@see AnnotationDriver::entityAnnotationClasses}. - * - * @param string $className - * @return boolean - */ - public function isTransient($className) - { - $classAnnotations = $this->reader->getClassAnnotations(new \ReflectionClass($className)); - - foreach ($classAnnotations as $annot) { - if (isset($this->entityAnnotationClasses[get_class($annot)])) { - return false; - } - } - return true; - } - - /** - * {@inheritDoc} - */ - public function getAllClassNames() - { - if ($this->classNames !== null) { - return $this->classNames; - } - - if (!$this->paths) { - throw MappingException::pathRequired(); - } - - $classes = array(); - $includedFiles = array(); - - foreach ($this->paths as $path) { - if ( ! is_dir($path)) { - throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); - } - - $iterator = new \RegexIterator( - new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), - \RecursiveIteratorIterator::LEAVES_ONLY - ), - '/^.+' . str_replace('.', '\.', $this->fileExtension) . '$/i', - \RecursiveRegexIterator::GET_MATCH - ); - - foreach ($iterator as $file) { - $sourceFile = realpath($file[0]); - - require_once $sourceFile; - - $includedFiles[] = $sourceFile; - } - } - - $declared = get_declared_classes(); - - foreach ($declared as $className) { - $rc = new \ReflectionClass($className); - $sourceFile = $rc->getFileName(); - if (in_array($sourceFile, $includedFiles) && ! $this->isTransient($className)) { - $classes[] = $className; - } - } - - $this->classNames = $classes; - - return $classes; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php deleted file mode 100644 index 0d61174..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php +++ /dev/null @@ -1,170 +0,0 @@ -. -*/ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\MappingException; - -/** - * Locate the file that contains the metadata information for a given class name. - * - * This behavior is inpependent of the actual content of the file. It just detects - * the file which is responsible for the given class name. - * - * @author Benjamin Eberlei - * @author Johannes M. Schmitt - */ -class DefaultFileLocator implements FileLocator -{ - /** - * The paths where to look for mapping files. - * - * @var array - */ - protected $paths = array(); - - /** - * The file extension of mapping documents. - * - * @var string - */ - protected $fileExtension; - - /** - * Initializes a new FileDriver that looks in the given path(s) for mapping - * documents and operates in the specified operating mode. - * - * @param string|array $paths One or multiple paths where mapping documents can be found. - * @param string|null $fileExtension - */ - public function __construct($paths, $fileExtension = null) - { - $this->addPaths((array) $paths); - $this->fileExtension = $fileExtension; - } - - /** - * Append lookup paths to metadata driver. - * - * @param array $paths - */ - public function addPaths(array $paths) - { - $this->paths = array_unique(array_merge($this->paths, $paths)); - } - - /** - * Retrieve the defined metadata lookup paths. - * - * @return array - */ - public function getPaths() - { - return $this->paths; - } - - /** - * Get the file extension used to look for mapping files under - * - * @return string - */ - public function getFileExtension() - { - return $this->fileExtension; - } - - /** - * Set the file extension used to look for mapping files under - * - * @param string $fileExtension The file extension to set - * @return void - */ - public function setFileExtension($fileExtension) - { - $this->fileExtension = $fileExtension; - } - - /** - * {@inheritDoc} - */ - public function findMappingFile($className) - { - $fileName = str_replace('\\', '.', $className) . $this->fileExtension; - - // Check whether file exists - foreach ($this->paths as $path) { - if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { - return $path . DIRECTORY_SEPARATOR . $fileName; - } - } - - throw MappingException::mappingFileNotFound($className, $fileName); - } - - /** - * {@inheritDoc} - */ - public function getAllClassNames($globalBasename) - { - $classes = array(); - - if ($this->paths) { - foreach ($this->paths as $path) { - if ( ! is_dir($path)) { - throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); - } - - $iterator = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path), - \RecursiveIteratorIterator::LEAVES_ONLY - ); - - foreach ($iterator as $file) { - $fileName = $file->getBasename($this->fileExtension); - - if ($fileName == $file->getBasename() || $fileName == $globalBasename) { - continue; - } - - // NOTE: All files found here means classes are not transient! - $classes[] = str_replace('.', '\\', $fileName); - } - } - } - - return $classes; - } - - /** - * {@inheritDoc} - */ - public function fileExists($className) - { - $fileName = str_replace('\\', '.', $className) . $this->fileExtension; - - // Check whether file exists - foreach ((array) $this->paths as $path) { - if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { - return true; - } - } - - return false; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php deleted file mode 100644 index b0a7685..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php +++ /dev/null @@ -1,214 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\MappingException; - -/** - * Base driver for file-based metadata drivers. - * - * A file driver operates in a mode where it loads the mapping files of individual - * classes on demand. This requires the user to adhere to the convention of 1 mapping - * file per class and the file names of the mapping files must correspond to the full - * class name, including namespace, with the namespace delimiters '\', replaced by dots '.'. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.com - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel - */ -abstract class FileDriver implements MappingDriver -{ - /** - * @var FileLocator - */ - protected $locator; - - /** - * @var array - */ - protected $classCache; - - /** - * @var string - */ - protected $globalBasename; - - /** - * Initializes a new FileDriver that looks in the given path(s) for mapping - * documents and operates in the specified operating mode. - * - * @param string|array|FileLocator $locator A FileLocator or one/multiple paths where mapping documents can be found. - * @param string $fileExtension - */ - public function __construct($locator, $fileExtension = null) - { - if ($locator instanceof FileLocator) { - $this->locator = $locator; - } else { - $this->locator = new DefaultFileLocator((array)$locator, $fileExtension); - } - } - - /** - * Set global basename - * - * @param string $file - */ - public function setGlobalBasename($file) - { - $this->globalBasename = $file; - } - - /** - * Retrieve global basename - * - * @return string - */ - public function getGlobalBasename() - { - return $this->globalBasename; - } - - /** - * Get the element of schema meta data for the class from the mapping file. - * This will lazily load the mapping file if it is not loaded yet - * - * @param string $className - * - * @throws MappingException - * @return array The element of schema meta data - */ - public function getElement($className) - { - if ($this->classCache === null) { - $this->initialize(); - } - - if (isset($this->classCache[$className])) { - return $this->classCache[$className]; - } - - $result = $this->loadMappingFile($this->locator->findMappingFile($className)); - if (!isset($result[$className])) { - throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->locator->getFileExtension()); - } - - return $result[$className]; - } - - /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped as an Entity or a - * MappedSuperclass. - * - * @param string $className - * @return boolean - */ - public function isTransient($className) - { - if ($this->classCache === null) { - $this->initialize(); - } - - if (isset($this->classCache[$className])) { - return false; - } - - return !$this->locator->fileExists($className); - } - - /** - * Gets the names of all mapped classes known to this driver. - * - * @return array The names of all mapped classes known to this driver. - */ - public function getAllClassNames() - { - if ($this->classCache === null) { - $this->initialize(); - } - - $classNames = (array)$this->locator->getAllClassNames($this->globalBasename); - if ($this->classCache) { - $classNames = array_merge(array_keys($this->classCache), $classNames); - } - return $classNames; - } - - /** - * Loads a mapping file with the given name and returns a map - * from class/entity names to their corresponding file driver elements. - * - * @param string $file The mapping file to load. - * @return array - */ - abstract protected function loadMappingFile($file); - - /** - * Initialize the class cache from all the global files. - * - * Using this feature adds a substantial performance hit to file drivers as - * more metadata has to be loaded into memory than might actually be - * necessary. This may not be relevant to scenarios where caching of - * metadata is in place, however hits very hard in scenarios where no - * caching is used. - * - * @return void - */ - protected function initialize() - { - $this->classCache = array(); - if (null !== $this->globalBasename) { - foreach ($this->locator->getPaths() as $path) { - $file = $path.'/'.$this->globalBasename.$this->locator->getFileExtension(); - if (is_file($file)) { - $this->classCache = array_merge( - $this->classCache, - $this->loadMappingFile($file) - ); - } - } - } - } - - /** - * Retrieve the locator used to discover mapping files by className - * - * @return FileLocator - */ - public function getLocator() - { - return $this->locator; - } - - /** - * Set the locator used to discover mapping files by className - * - * @param FileLocator $locator - */ - public function setLocator(FileLocator $locator) - { - $this->locator = $locator; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php deleted file mode 100644 index ec2b606..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php +++ /dev/null @@ -1,71 +0,0 @@ -. -*/ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -/** - * Locate the file that contains the metadata information for a given class name. - * - * This behavior is independent of the actual content of the file. It just detects - * the file which is responsible for the given class name. - * - * @author Benjamin Eberlei - * @author Johannes M. Schmitt - */ -interface FileLocator -{ - /** - * Locate mapping file for the given class name. - * - * @param string $className - * @return string - */ - function findMappingFile($className); - - /** - * Get all class names that are found with this file locator. - * - * @param string $globalBasename Passed to allow excluding the basename - * @return array - */ - function getAllClassNames($globalBasename); - - /** - * Check if a file can be found for this class name. - * - * @param string $className - * - * @return bool - */ - function fileExists($className); - - /** - * Get all the paths that this file locator looks for mapping files. - * - * @return array - */ - function getPaths(); - - /** - * Get the file extension that mapping files are suffixed with. - * - * @return string - */ - function getFileExtension(); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php deleted file mode 100644 index 955d831..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php +++ /dev/null @@ -1,56 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\ClassMetadata; - -/** - * Contract for metadata drivers. - * - * @since 2.2 - * @author Jonathan H. Wage - */ -interface MappingDriver -{ - /** - * Loads the metadata for the specified class into the provided container. - * - * @param string $className - * @param ClassMetadata $metadata - */ - function loadMetadataForClass($className, ClassMetadata $metadata); - - /** - * Gets the names of all mapped classes known to this driver. - * - * @return array The names of all mapped classes known to this driver. - */ - function getAllClassNames(); - - /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped as an Entity or a - * MappedSuperclass. - * - * @param string $className - * @return boolean - */ - function isTransient($className); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php deleted file mode 100644 index 3b1049d..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php +++ /dev/null @@ -1,168 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, - Doctrine\Common\Persistence\Mapping\ClassMetadata, - Doctrine\Common\Persistence\Mapping\MappingException; - -/** - * The DriverChain allows you to add multiple other mapping drivers for - * certain namespaces - * - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel - */ -class MappingDriverChain implements MappingDriver -{ - /** - * The default driver - * - * @var MappingDriver - */ - private $defaultDriver; - - /** - * @var array - */ - private $drivers = array(); - - /** - * Get the default driver. - * - * @return MappingDriver|null - */ - public function getDefaultDriver() - { - return $this->defaultDriver; - } - - /** - * Set the default driver. - * - * @param MappingDriver $driver - */ - public function setDefaultDriver(MappingDriver $driver) - { - $this->defaultDriver = $driver; - } - - /** - * Add a nested driver. - * - * @param MappingDriver $nestedDriver - * @param string $namespace - */ - public function addDriver(MappingDriver $nestedDriver, $namespace) - { - $this->drivers[$namespace] = $nestedDriver; - } - - /** - * Get the array of nested drivers. - * - * @return array $drivers - */ - public function getDrivers() - { - return $this->drivers; - } - - /** - * Loads the metadata for the specified class into the provided container. - * - * @param string $className - * @param ClassMetadata $metadata - * - * @throws MappingException - */ - public function loadMetadataForClass($className, ClassMetadata $metadata) - { - /* @var $driver MappingDriver */ - foreach ($this->drivers as $namespace => $driver) { - if (strpos($className, $namespace) === 0) { - $driver->loadMetadataForClass($className, $metadata); - return; - } - } - - if (null !== $this->defaultDriver) { - $this->defaultDriver->loadMetadataForClass($className, $metadata); - return; - } - - throw MappingException::classNotFoundInNamespaces($className, array_keys($this->drivers)); - } - - /** - * Gets the names of all mapped classes known to this driver. - * - * @return array The names of all mapped classes known to this driver. - */ - public function getAllClassNames() - { - $classNames = array(); - $driverClasses = array(); - - /* @var $driver MappingDriver */ - foreach ($this->drivers AS $namespace => $driver) { - $oid = spl_object_hash($driver); - - if (!isset($driverClasses[$oid])) { - $driverClasses[$oid] = $driver->getAllClassNames(); - } - - foreach ($driverClasses[$oid] AS $className) { - if (strpos($className, $namespace) === 0) { - $classNames[$className] = true; - } - } - } - - return array_keys($classNames); - } - - /** - * Whether the class with the specified name should have its metadata loaded. - * - * This is only the case for non-transient classes either mapped as an Entity or MappedSuperclass. - * - * @param string $className - * @return boolean - */ - public function isTransient($className) - { - /* @var $driver MappingDriver */ - foreach ($this->drivers AS $namespace => $driver) { - if (strpos($className, $namespace) === 0) { - return $driver->isTransient($className); - } - } - - if ($this->defaultDriver !== null) { - return $this->defaultDriver->isTransient($className); - } - - return true; - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php deleted file mode 100644 index e0c8611..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\ClassMetadata; - -/** - * The PHPDriver includes php files which just populate ClassMetadataInfo - * instances with plain php code - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel - */ -class PHPDriver extends FileDriver -{ - /** - * {@inheritdoc} - */ - protected $metadata; - - /** - * {@inheritDoc} - */ - public function __construct($locator, $fileExtension = null) - { - $fileExtension = ".php"; - parent::__construct($locator, $fileExtension); - } - - /** - * {@inheritdoc} - */ - public function loadMetadataForClass($className, ClassMetadata $metadata) - { - $this->metadata = $metadata; - $this->loadMappingFile($this->locator->findMappingFile($className)); - } - - /** - * {@inheritdoc} - */ - protected function loadMappingFile($file) - { - $metadata = $this->metadata; - include $file; - - return array($metadata->getName() => $metadata); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php deleted file mode 100644 index e3cea73..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php +++ /dev/null @@ -1,141 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\ClassMetadata; -use Doctrine\Common\Persistence\Mapping\MappingException; - -/** - * The StaticPHPDriver calls a static loadMetadata() method on your entity - * classes where you can manually populate the ClassMetadata instance. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.2 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel - */ -class StaticPHPDriver implements MappingDriver -{ - /** - * Paths of entity directories. - * - * @var array - */ - private $paths = array(); - - /** - * Map of all class names. - * - * @var array - */ - private $classNames; - - /** - * Constructor - * - * @param array|string $paths - */ - public function __construct($paths) - { - $this->addPaths((array) $paths); - } - - /** - * Add paths - * - * @param array $paths - */ - public function addPaths(array $paths) - { - $this->paths = array_unique(array_merge($this->paths, $paths)); - } - - /** - * {@inheritdoc} - */ - public function loadMetadataForClass($className, ClassMetadata $metadata) - { - $className::loadMetadata($metadata); - } - - /** - * {@inheritDoc} - * @todo Same code exists in AnnotationDriver, should we re-use it somehow or not worry about it? - */ - public function getAllClassNames() - { - if ($this->classNames !== null) { - return $this->classNames; - } - - if (!$this->paths) { - throw MappingException::pathRequired(); - } - - $classes = array(); - $includedFiles = array(); - - foreach ($this->paths as $path) { - if (!is_dir($path)) { - throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); - } - - $iterator = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path), - \RecursiveIteratorIterator::LEAVES_ONLY - ); - - foreach ($iterator as $file) { - if ($file->getBasename('.php') == $file->getBasename()) { - continue; - } - - $sourceFile = realpath($file->getPathName()); - require_once $sourceFile; - $includedFiles[] = $sourceFile; - } - } - - $declared = get_declared_classes(); - - foreach ($declared as $className) { - $rc = new \ReflectionClass($className); - $sourceFile = $rc->getFileName(); - if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) { - $classes[] = $className; - } - } - - $this->classNames = $classes; - - return $classes; - } - - /** - * {@inheritdoc} - */ - public function isTransient($className) - { - return ! method_exists($className, 'loadMetadata'); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php deleted file mode 100644 index 9095187..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php +++ /dev/null @@ -1,214 +0,0 @@ -. -*/ - -namespace Doctrine\Common\Persistence\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\MappingException; - -/** - * The Symfony File Locator makes a simplifying assumptions compared - * to the DefaultFileLocator. By assuming paths only contain entities of a certain - * namespace the mapping files consists of the short classname only. - * - * @author Fabien Potencier - * @author Benjamin Eberlei - * @license MIT - */ -class SymfonyFileLocator implements FileLocator -{ - /** - * The paths where to look for mapping files. - * - * @var array - */ - protected $paths = array(); - - /** - * A map of mapping directory path to namespace prefix used to expand class shortnames. - * - * @var array - */ - protected $prefixes = array(); - - /** - * File extension that is searched for. - * - * @var string - */ - protected $fileExtension; - - /** - * Constructor - * - * @param array $prefixes - * @param string|null $fileExtension - */ - public function __construct(array $prefixes, $fileExtension = null) - { - $this->addNamespacePrefixes($prefixes); - $this->fileExtension = $fileExtension; - } - - /** - * Add Namespace Prefixes - * - * @param array $prefixes - */ - public function addNamespacePrefixes(array $prefixes) - { - $this->prefixes = array_merge($this->prefixes, $prefixes); - $this->paths = array_merge($this->paths, array_keys($prefixes)); - } - - /** - * Get Namespace Prefixes - * - * @return array - */ - public function getNamespacePrefixes() - { - return $this->prefixes; - } - - /** - * {@inheritDoc} - */ - public function getPaths() - { - return $this->paths; - } - - /** - * {@inheritDoc} - */ - public function getFileExtension() - { - return $this->fileExtension; - } - - /** - * Set the file extension used to look for mapping files under - * - * @param string $fileExtension The file extension to set - * @return void - */ - public function setFileExtension($fileExtension) - { - $this->fileExtension = $fileExtension; - } - - /** - * {@inheritDoc} - */ - public function fileExists($className) - { - $defaultFileName = str_replace('\\', '.', $className).$this->fileExtension; - foreach ($this->paths as $path) { - if (!isset($this->prefixes[$path])) { - // global namespace class - if (is_file($path.DIRECTORY_SEPARATOR.$defaultFileName)) { - return true; - } - - continue; - } - - $prefix = $this->prefixes[$path]; - - if (0 !== strpos($className, $prefix.'\\')) { - continue; - } - - $filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->fileExtension; - return is_file($filename); - } - - return false; - } - - /** - * {@inheritDoc} - */ - public function getAllClassNames($globalBasename = null) - { - $classes = array(); - - if ($this->paths) { - foreach ((array) $this->paths as $path) { - if (!is_dir($path)) { - throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); - } - - $iterator = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path), - \RecursiveIteratorIterator::LEAVES_ONLY - ); - - foreach ($iterator as $file) { - $fileName = $file->getBasename($this->fileExtension); - - if ($fileName == $file->getBasename() || $fileName == $globalBasename) { - continue; - } - - // NOTE: All files found here means classes are not transient! - if (isset($this->prefixes[$path])) { - $classes[] = $this->prefixes[$path].'\\'.str_replace('.', '\\', $fileName); - } else { - $classes[] = str_replace('.', '\\', $fileName); - } - } - } - } - - return $classes; - } - - /** - * {@inheritDoc} - */ - public function findMappingFile($className) - { - $defaultFileName = str_replace('\\', '.', $className).$this->fileExtension; - foreach ($this->paths as $path) { - if (!isset($this->prefixes[$path])) { - if (is_file($path.DIRECTORY_SEPARATOR.$defaultFileName)) { - return $path.DIRECTORY_SEPARATOR.$defaultFileName; - } - - continue; - } - - $prefix = $this->prefixes[$path]; - - if (0 !== strpos($className, $prefix.'\\')) { - continue; - } - - $filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->fileExtension; - if (is_file($filename)) { - return $filename; - } - - throw MappingException::mappingFileNotFound($className, $filename); - } - - throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1).$this->fileExtension); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php deleted file mode 100644 index c1e7ad5..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php +++ /dev/null @@ -1,86 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping; - -/** - * A MappingException indicates that something is wrong with the mapping setup. - * - * @since 2.2 - */ -class MappingException extends \Exception -{ - /** - * - * @param string $className - * @param array $namespaces - * - * @return MappingException - */ - public static function classNotFoundInNamespaces($className, $namespaces) - { - return new self("The class '" . $className . "' was not found in the ". - "chain configured namespaces " . implode(", ", $namespaces)); - } - - /** - * @return MappingException - */ - public static function pathRequired() - { - return new self("Specifying the paths to your entities is required ". - "in the AnnotationDriver to retrieve all class names."); - } - - /** - * @param string|null $path - * @return MappingException - */ - public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null) - { - if ( ! empty($path)) { - $path = '[' . $path . ']'; - } - - return new self( - 'File mapping drivers must have a valid directory path, ' . - 'however the given path ' . $path . ' seems to be incorrect!' - ); - } - - /** - * @param string $entityName - * @param string $fileName - * @return MappingException - */ - public static function mappingFileNotFound($entityName, $fileName) - { - return new self("No mapping file found named '$fileName' for class '$entityName'."); - } - - /** - * @param string $entityName - * @param string $fileName - * @return MappingException - */ - public static function invalidMappingFile($entityName, $fileName) - { - return new self("Invalid mapping file '$fileName' for class '$entityName'."); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php deleted file mode 100644 index 3db85d9..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php +++ /dev/null @@ -1,80 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping; - -/** - * Very simple reflection service abstraction. - * - * This is required inside metadata layers that may require either - * static or runtime reflection. - * - * @author Benjamin Eberlei - */ -interface ReflectionService -{ - /** - * Return an array of the parent classes (not interfaces) for the given class. - * - * @param string $class - * @return array - */ - function getParentClasses($class); - - /** - * Return the shortname of a class. - * - * @param string $class - * @return string - */ - function getClassShortName($class); - - /** - * @param string $class - * @return string - */ - function getClassNamespace($class); - - /** - * Return a reflection class instance or null - * - * @param string $class - * @return \ReflectionClass|null - */ - function getClass($class); - - /** - * Return an accessible property (setAccessible(true)) or null. - * - * @param string $class - * @param string $property - * @return \ReflectionProperty|null - */ - function getAccessibleProperty($class, $property); - - /** - * Check if the class have a public method with the given name. - * - * @param mixed $class - * @param mixed $method - * @return bool - */ - function hasPublicMethod($class, $method); -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php deleted file mode 100644 index 77b9e76..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php +++ /dev/null @@ -1,102 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping; - -use ReflectionClass; -use ReflectionProperty; - -/** - * PHP Runtime Reflection Service - * - * @author Benjamin Eberlei - */ -class RuntimeReflectionService implements ReflectionService -{ - /** - * Return an array of the parent classes (not interfaces) for the given class. - * - * @param string $class - * @return array - */ - public function getParentClasses($class) - { - return class_parents($class); - } - - /** - * Return the shortname of a class. - * - * @param string $class - * @return string - */ - public function getClassShortName($class) - { - $r = new ReflectionClass($class); - return $r->getShortName(); - } - - /** - * @param string $class - * @return string - */ - public function getClassNamespace($class) - { - $r = new ReflectionClass($class); - return $r->getNamespaceName(); - } - - /** - * Return a reflection class instance or null - * - * @param string $class - * @return ReflectionClass|null - */ - public function getClass($class) - { - return new ReflectionClass($class); - } - - /** - * Return an accessible property (setAccessible(true)) or null. - * - * @param string $class - * @param string $property - * @return ReflectionProperty|null - */ - public function getAccessibleProperty($class, $property) - { - $property = new ReflectionProperty($class, $property); - $property->setAccessible(true); - return $property; - } - - /** - * Check if the class have a public method with the given name. - * - * @param mixed $class - * @param mixed $method - * @return bool - */ - public function hasPublicMethod($class, $method) - { - return method_exists($class, $method) && is_callable(array($class, $method)); - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php deleted file mode 100644 index 4f6d1cf..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php +++ /dev/null @@ -1,107 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence\Mapping; - -use ReflectionClass; -use ReflectionProperty; - -/** - * PHP Runtime Reflection Service - * - * @author Benjamin Eberlei - */ -class StaticReflectionService implements ReflectionService -{ - /** - * Return an array of the parent classes (not interfaces) for the given class. - * - * @param string $class - * @return array - */ - public function getParentClasses($class) - { - return array(); - } - - /** - * Return the shortname of a class. - * - * @param string $className - * @return string - */ - public function getClassShortName($className) - { - if (strpos($className, '\\') !== false) { - $className = substr($className, strrpos($className, "\\")+1); - } - return $className; - } - - /** - * Return the namespace of a class. - * - * @param string $className - * @return string - */ - public function getClassNamespace($className) - { - $namespace = ''; - if (strpos($className, '\\') !== false) { - $namespace = strrev(substr( strrev($className), strpos(strrev($className), '\\')+1 )); - } - return $namespace; - } - - /** - * Return a reflection class instance or null - * - * @param string $class - * @return ReflectionClass|null - */ - public function getClass($class) - { - return null; - } - - /** - * Return an accessible property (setAccessible(true)) or null. - * - * @param string $class - * @param string $property - * @return ReflectionProperty|null - */ - public function getAccessibleProperty($class, $property) - { - return null; - } - - /** - * Check if the class have a public method with the given name. - * - * @param mixed $class - * @param mixed $method - * @return bool - */ - public function hasPublicMethod($class, $method) - { - return method_exists($class, $method) && is_callable(array($class, $method)); - } -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php deleted file mode 100644 index 2bb8722..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php +++ /dev/null @@ -1,152 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence; - -/** - * Contract for a Doctrine persistence layer ObjectManager class to implement. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Benjamin Eberlei - * @author Jonathan Wage - */ -interface ObjectManager -{ - /** - * Finds a object by its identifier. - * - * This is just a convenient shortcut for getRepository($className)->find($id). - * - * @param string - * @param mixed - * @return object - */ - function find($className, $id); - - /** - * Tells the ObjectManager to make an instance managed and persistent. - * - * The object will be entered into the database as a result of the flush operation. - * - * NOTE: The persist operation always considers objects that are not yet known to - * this ObjectManager as NEW. Do not pass detached objects to the persist operation. - * - * @param object $object The instance to make managed and persistent. - */ - function persist($object); - - /** - * Removes an object instance. - * - * A removed object will be removed from the database as a result of the flush operation. - * - * @param object $object The object instance to remove. - */ - function remove($object); - - /** - * Merges the state of a detached object into the persistence context - * of this ObjectManager and returns the managed copy of the object. - * The object passed to merge will not become associated/managed with this ObjectManager. - * - * @param object $object - * @return object - */ - function merge($object); - - /** - * Clears the ObjectManager. All objects that are currently managed - * by this ObjectManager become detached. - * - * @param string $objectName if given, only objects of this type will get detached - */ - function clear($objectName = null); - - /** - * Detaches an object from the ObjectManager, causing a managed object to - * become detached. Unflushed changes made to the object if any - * (including removal of the object), will not be synchronized to the database. - * Objects which previously referenced the detached object will continue to - * reference it. - * - * @param object $object The object to detach. - */ - function detach($object); - - /** - * Refreshes the persistent state of an object from the database, - * overriding any local changes that have not yet been persisted. - * - * @param object $object The object to refresh. - */ - function refresh($object); - - /** - * Flushes all changes to objects that have been queued up to now to the database. - * This effectively synchronizes the in-memory state of managed objects with the - * database. - */ - function flush(); - - /** - * Gets the repository for a class. - * - * @param string $className - * @return \Doctrine\Common\Persistence\ObjectRepository - */ - function getRepository($className); - - /** - * Returns the ClassMetadata descriptor for a class. - * - * The class name must be the fully-qualified class name without a leading backslash - * (as it is returned by get_class($obj)). - * - * @param string $className - * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata - */ - function getClassMetadata($className); - - /** - * Gets the metadata factory used to gather the metadata of classes. - * - * @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory - */ - function getMetadataFactory(); - - /** - * Helper method to initialize a lazy loading proxy or persistent collection. - * - * This method is a no-op for other objects. - * - * @param object $obj - */ - function initializeObject($obj); - - /** - * Check if the object is part of the current UnitOfWork and therefore - * managed. - * - * @param object $object - * @return bool - */ - function contains($object); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php deleted file mode 100644 index 69fba78..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence; - -use Doctrine\Common\Persistence\Mapping\ClassMetadata; - -/** - * Makes a Persistent Objects aware of its own object-manager. - * - * Using this interface the managing object manager and class metadata instances - * are injected into the persistent object after construction. This allows - * you to implement ActiveRecord functionality on top of the persistance-ignorance - * that Doctrine propagates. - * - * Word of Warning: This is a very powerful hook to change how you can work with your domain models. - * Using this hook will break the Single Responsibility Principle inside your Domain Objects - * and increase the coupling of database and objects. - * - * Every ObjectManager has to implement this functionality itself. - * - * @author Benjamin Eberlei - */ -interface ObjectManagerAware -{ - /** - * Injects responsible ObjectManager and the ClassMetadata into this persistent object. - * - * @param ObjectManager $objectManager - * @param ClassMetadata $classMetadata - */ - public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php deleted file mode 100644 index 9a3e5b6..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php +++ /dev/null @@ -1,78 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence; - -/** - * Contract for a Doctrine persistence layer ObjectRepository class to implement. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.1 - * @author Benjamin Eberlei - * @author Jonathan Wage - */ -interface ObjectRepository -{ - /** - * Finds an object by its primary key / identifier. - * - * @param int $id The identifier. - * @return object The object. - */ - function find($id); - - /** - * Finds all objects in the repository. - * - * @return mixed The objects. - */ - function findAll(); - - /** - * Finds objects by a set of criteria. - * - * Optionally sorting and limiting details can be passed. An implementation may throw - * an UnexpectedValueException if certain values of the sorting or limiting details are - * not supported. - * - * @throws \UnexpectedValueException - * @param array $criteria - * @param array|null $orderBy - * @param int|null $limit - * @param int|null $offset - * @return mixed The objects. - */ - function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null); - - /** - * Finds a single object by a set of criteria. - * - * @param array $criteria - * @return object The object. - */ - function findOneBy(array $criteria); - - /** - * Returns the class name of the object managed by the repository - * - * @return string - */ - function getClassName(); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php deleted file mode 100644 index 9fcc4cb..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php +++ /dev/null @@ -1,244 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence; - -use Doctrine\Common\Persistence\Mapping\ClassMetadata; -use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Collections\Collection; - -/** - * PersistentObject base class that implements getter/setter methods for all mapped fields and associations - * by overriding __call. - * - * This class is a forward compatible implementation of the PersistentObject trait. - * - * - * Limitations: - * - * 1. All persistent objects have to be associated with a single ObjectManager, multiple - * ObjectManagers are not supported. You can set the ObjectManager with `PersistentObject#setObjectManager()`. - * 2. Setters and getters only work if a ClassMetadata instance was injected into the PersistentObject. - * This is either done on `postLoad` of an object or by accessing the global object manager. - * 3. There are no hooks for setters/getters. Just implement the method yourself instead of relying on __call(). - * 4. Slower than handcoded implementations: An average of 7 method calls per access to a field and 11 for an association. - * 5. Only the inverse side associations get autoset on the owning side aswell. Setting objects on the owning side - * will not set the inverse side associations. - * - * @example - * - * PersistentObject::setObjectManager($em); - * - * class Foo extends PersistentObject - * { - * private $id; - * } - * - * $foo = new Foo(); - * $foo->getId(); // method exists through __call - * - * @author Benjamin Eberlei - */ -abstract class PersistentObject implements ObjectManagerAware -{ - /** - * @var ObjectManager - */ - private static $objectManager; - - /** - * @var ClassMetadata - */ - private $cm; - - /** - * Set the object manager responsible for all persistent object base classes. - * - * @param ObjectManager $objectManager - */ - static public function setObjectManager(ObjectManager $objectManager = null) - { - self::$objectManager = $objectManager; - } - - /** - * @return ObjectManager - */ - static public function getObjectManager() - { - return self::$objectManager; - } - - /** - * Inject Doctrine Object Manager - * - * @param ObjectManager $objectManager - * @param ClassMetadata $classMetadata - * - * @throws \RuntimeException - */ - public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata) - { - if ($objectManager !== self::$objectManager) { - throw new \RuntimeException("Trying to use PersistentObject with different ObjectManager instances. " . - "Was PersistentObject::setObjectManager() called?"); - } - - $this->cm = $classMetadata; - } - - /** - * Sets a persistent fields value. - * - * @param string $field - * @param array $args - * - * @throws \BadMethodCallException - When no persistent field exists by that name. - * @throws \InvalidArgumentException - When the wrong target object type is passed to an association - * @return void - */ - private function set($field, $args) - { - $this->initializeDoctrine(); - - if ($this->cm->hasField($field) && !$this->cm->isIdentifier($field)) { - $this->$field = $args[0]; - } else if ($this->cm->hasAssociation($field) && $this->cm->isSingleValuedAssociation($field)) { - $targetClass = $this->cm->getAssociationTargetClass($field); - if (!($args[0] instanceof $targetClass) && $args[0] !== null) { - throw new \InvalidArgumentException("Expected persistent object of type '".$targetClass."'"); - } - $this->$field = $args[0]; - $this->completeOwningSide($field, $targetClass, $args[0]); - } else { - throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'"); - } - } - - /** - * Get persistent field value. - * - * - * @param string $field - * - * @throws \BadMethodCallException - When no persistent field exists by that name. - * @return mixed - */ - private function get($field) - { - $this->initializeDoctrine(); - - if ( $this->cm->hasField($field) || $this->cm->hasAssociation($field) ) { - return $this->$field; - } else { - throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'"); - } - } - - /** - * If this is an inverse side association complete the owning side. - * - * @param string $field - * @param ClassMetadata $targetClass - * @param object $targetObject - */ - private function completeOwningSide($field, $targetClass, $targetObject) - { - // add this object on the owning side aswell, for obvious infinite recursion - // reasons this is only done when called on the inverse side. - if ($this->cm->isAssociationInverseSide($field)) { - $mappedByField = $this->cm->getAssociationMappedByTargetField($field); - $targetMetadata = self::$objectManager->getClassMetadata($targetClass); - - $setter = ($targetMetadata->isCollectionValuedAssociation($mappedByField) ? "add" : "set").$mappedByField; - $targetObject->$setter($this); - } - } - - /** - * Add an object to a collection - * - * @param string $field - * @param array $args - * - * @throws \BadMethodCallException - * @throws \InvalidArgumentException - */ - private function add($field, $args) - { - $this->initializeDoctrine(); - - if ($this->cm->hasAssociation($field) && $this->cm->isCollectionValuedAssociation($field)) { - $targetClass = $this->cm->getAssociationTargetClass($field); - if (!($args[0] instanceof $targetClass)) { - throw new \InvalidArgumentException("Expected persistent object of type '".$targetClass."'"); - } - if (!($this->$field instanceof Collection)) { - $this->$field = new ArrayCollection($this->$field ?: array()); - } - $this->$field->add($args[0]); - $this->completeOwningSide($field, $targetClass, $args[0]); - } else { - throw new \BadMethodCallException("There is no method add".$field."() on ".$this->cm->getName()); - } - } - - /** - * Initialize Doctrine Metadata for this class. - * - * @throws \RuntimeException - * @return void - */ - private function initializeDoctrine() - { - if ($this->cm !== null) { - return; - } - - if (!self::$objectManager) { - throw new \RuntimeException("No runtime object manager set. Call PersistentObject#setObjectManager()."); - } - - $this->cm = self::$objectManager->getClassMetadata(get_class($this)); - } - - /** - * Magic method that implements - * - * @param string $method - * @param array $args - * - * @throws \BadMethodCallException - * @return mixed - */ - public function __call($method, $args) - { - $command = substr($method, 0, 3); - $field = lcfirst(substr($method, 3)); - if ($command == "set") { - $this->set($field, $args); - } else if ($command == "get") { - return $this->get($field); - } else if ($command == "add") { - $this->add($field, $args); - } else { - throw new \BadMethodCallException("There is no method ".$method." on ".$this->cm->getName()); - } - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php b/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php deleted file mode 100644 index e25598c..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php +++ /dev/null @@ -1,60 +0,0 @@ -. - */ - -namespace Doctrine\Common\Persistence; - -/** - * Interface for proxy classes. - * - * @author Roman Borschel - * @since 2.2 - */ -interface Proxy -{ - /** - * Marker for Proxy class names. - * - * @var string - */ - const MARKER = '__CG__'; - - /** - * Length of the proxy marker - * - * @var int - */ - const MARKER_LENGTH = 6; - - /** - * Initialize this proxy if its not yet initialized. - * - * Acts as a no-op if already initialized. - * - * @return void - */ - public function __load(); - - /** - * Is this proxy initialized or not. - * - * @return bool - */ - public function __isInitialized(); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/PropertyChangedListener.php b/vendor/doctrine/common/lib/Doctrine/Common/PropertyChangedListener.php deleted file mode 100644 index 1171874..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/PropertyChangedListener.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * Contract for classes that are potential listeners of a NotifyPropertyChanged - * implementor. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision: 3938 $ - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -interface PropertyChangedListener -{ - /** - * Notifies the listener of a property change. - * - * @param object $sender The object on which the property changed. - * @param string $propertyName The name of the property that changed. - * @param mixed $oldValue The old value of the property that changed. - * @param mixed $newValue The new value of the property that changed. - */ - function propertyChanged($sender, $propertyName, $oldValue, $newValue); -} - diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ClassFinderInterface.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ClassFinderInterface.php deleted file mode 100644 index ae69607..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ClassFinderInterface.php +++ /dev/null @@ -1,38 +0,0 @@ -. - */ - -namespace Doctrine\Common\Reflection; - -/** - * Finds a class in a PSR-0 structure. - * - * @author Karoly Negyesi - */ -interface ClassFinderInterface -{ - /** - * Finds a class. - * - * @param string $class The name of the class. - * - * @return - * The name of the class or NULL if not found. - */ - public function findFile($class); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/Psr0FindFile.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/Psr0FindFile.php deleted file mode 100644 index b6a5fd1..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/Psr0FindFile.php +++ /dev/null @@ -1,83 +0,0 @@ -. - */ - -namespace Doctrine\Common\Reflection; - -/** - * Finds a class in a PSR-0 structure. - * - * @author Karoly Negyesi - */ -class Psr0FindFile implements ClassFinderInterface -{ - /** - * The PSR-0 prefixes. - * - * @var string - */ - protected $prefixes; - - /** - * @param string $prefixes - * An array of prefixes. Each key is a PHP namespace and each value is - * a list of directories. - */ - public function __construct($prefixes) - { - $this->prefixes = $prefixes; - } - - /** - * Finds a class. - * - * @param string $class The name of the class. - * - * @return - * The name of the class or NULL if not found. - */ - public function findFile($class) - { - $lastNsPos = strrpos($class, '\\'); - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - if (false !== $lastNsPos) { - // namespaced class name - $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $lastNsPos)) . DIRECTORY_SEPARATOR; - $className = substr($class, $lastNsPos + 1); - } else { - // PEAR-like class name - $classPath = null; - $className = $class; - } - - $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; - - foreach ($this->prefixes as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) { - return $dir . DIRECTORY_SEPARATOR . $classPath; - } - } - } - } - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ReflectionProviderInterface.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ReflectionProviderInterface.php deleted file mode 100644 index a436a2d..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/ReflectionProviderInterface.php +++ /dev/null @@ -1,45 +0,0 @@ -. - */ - -namespace Doctrine\Common\Reflection; - -interface ReflectionProviderInterface -{ - /** - * Get the ReflectionClass equivalent for this class. - * - * @return ReflectionClass - */ - public function getReflectionClass(); - - /** - * Get the ReflectionClass equivalent for this class. - * - * @return ReflectionMethod - */ - public function getReflectionMethod($name); - - /** - * Get the ReflectionClass equivalent for this class. - * - * @return ReflectionMethod - */ - public function getReflectionProperty($name); -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php deleted file mode 100644 index 12e45d5..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php +++ /dev/null @@ -1,112 +0,0 @@ -. - */ - -namespace Doctrine\Common\Reflection; - -use ReflectionClass; -use ReflectionException; - -class StaticReflectionClass extends ReflectionClass -{ - /** - * The static reflection parser object. - * - * @var StaticReflectionParser - */ - private $staticReflectionParser; - - public function __construct(StaticReflectionParser $staticReflectionParser) - { - $this->staticReflectionParser = $staticReflectionParser; - } - - public function getName() - { - return $this->staticReflectionParser->getClassName(); - } - - public function getDocComment() - { - return $this->staticReflectionParser->getDocComment(); - } - - public function getNamespaceName() - { - return $this->staticReflectionParser->getNamespaceName(); - } - - public function getUseStatements() - { - return $this->staticReflectionParser->getUseStatements(); - } - - public function getMethod($name) - { - return $this->staticReflectionParser->getReflectionMethod($name); - } - - public function getProperty($name) - { - return $this->staticReflectionParser->getReflectionProperty($name); - } - - public static function export($argument, $return = false) { throw new ReflectionException('Method not implemented'); } - public function getConstant($name) { throw new ReflectionException('Method not implemented'); } - public function getConstants() { throw new ReflectionException('Method not implemented'); } - public function getConstructor() { throw new ReflectionException('Method not implemented'); } - public function getDefaultProperties() { throw new ReflectionException('Method not implemented'); } - public function getEndLine() { throw new ReflectionException('Method not implemented'); } - public function getExtension() { throw new ReflectionException('Method not implemented'); } - public function getExtensionName() { throw new ReflectionException('Method not implemented'); } - public function getFileName() { throw new ReflectionException('Method not implemented'); } - public function getInterfaceNames() { throw new ReflectionException('Method not implemented'); } - public function getInterfaces() { throw new ReflectionException('Method not implemented'); } - public function getMethods($filter = NULL) { throw new ReflectionException('Method not implemented'); } - public function getModifiers() { throw new ReflectionException('Method not implemented'); } - public function getParentClass() { throw new ReflectionException('Method not implemented'); } - public function getProperties($filter = NULL) { throw new ReflectionException('Method not implemented'); } - public function getShortName() { throw new ReflectionException('Method not implemented'); } - public function getStartLine() { throw new ReflectionException('Method not implemented'); } - public function getStaticProperties() { throw new ReflectionException('Method not implemented'); } - public function getStaticPropertyValue($name, $default = '') { throw new ReflectionException('Method not implemented'); } - public function getTraitAliases() { throw new ReflectionException('Method not implemented'); } - public function getTraitNames() { throw new ReflectionException('Method not implemented'); } - public function getTraits() { throw new ReflectionException('Method not implemented'); } - public function hasConstant($name) { throw new ReflectionException('Method not implemented'); } - public function hasMethod($name) { throw new ReflectionException('Method not implemented'); } - public function hasProperty($name) { throw new ReflectionException('Method not implemented'); } - public function implementsInterface($interface) { throw new ReflectionException('Method not implemented'); } - public function inNamespace() { throw new ReflectionException('Method not implemented'); } - public function isAbstract() { throw new ReflectionException('Method not implemented'); } - public function isCloneable() { throw new ReflectionException('Method not implemented'); } - public function isFinal() { throw new ReflectionException('Method not implemented'); } - public function isInstance($object) { throw new ReflectionException('Method not implemented'); } - public function isInstantiable() { throw new ReflectionException('Method not implemented'); } - public function isInterface() { throw new ReflectionException('Method not implemented'); } - public function isInternal() { throw new ReflectionException('Method not implemented'); } - public function isIterateable() { throw new ReflectionException('Method not implemented'); } - public function isSubclassOf($class) { throw new ReflectionException('Method not implemented'); } - public function isTrait() { throw new ReflectionException('Method not implemented'); } - public function isUserDefined() { throw new ReflectionException('Method not implemented'); } - public function newInstance($args) { throw new ReflectionException('Method not implemented'); } - public function newInstanceArgs(array $args = array()) { throw new ReflectionException('Method not implemented'); } - public function newInstanceWithoutConstructor() { throw new ReflectionException('Method not implemented'); } - public function setStaticPropertyValue($name, $value) { throw new ReflectionException('Method not implemented'); } - public function __toString() { throw new ReflectionException('Method not implemented'); } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php deleted file mode 100644 index 6482036..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionMethod.php +++ /dev/null @@ -1,103 +0,0 @@ -. - */ - -namespace Doctrine\Common\Reflection; - -use ReflectionMethod; -use ReflectionException; - -class StaticReflectionMethod extends ReflectionMethod -{ - /** - * The PSR-0 parser object. - * - * @var StaticReflectionParser - */ - protected $staticReflectionParser; - - /** - * The name of the method. - * - * @var string - */ - protected $methodName; - - public function __construct(StaticReflectionParser $staticReflectionParser, $methodName) - { - $this->staticReflectionParser = $staticReflectionParser; - $this->methodName = $methodName; - } - public function getName() - { - return $this->methodName; - } - protected function getStaticReflectionParser() - { - return $this->staticReflectionParser->getStaticReflectionParserForDeclaringClass('method', $this->methodName); - } - public function getDeclaringClass() - { - return $this->getStaticReflectionParser()->getReflectionClass(); - } - public function getNamespaceName() - { - return $this->getStaticReflectionParser()->getNamespaceName(); - } - public function getDocComment() - { - return $this->getStaticReflectionParser()->getDocComment('method', $this->methodName); - } - public function getUseStatements() - { - return $this->getStaticReflectionParser()->getUseStatements(); - } - public static function export($class, $name, $return = false) { throw new ReflectionException('Method not implemented'); } - public function getClosure($object) { throw new ReflectionException('Method not implemented'); } - public function getModifiers() { throw new ReflectionException('Method not implemented'); } - public function getPrototype() { throw new ReflectionException('Method not implemented'); } - public function invoke($object, $parameter = NULL) { throw new ReflectionException('Method not implemented'); } - public function invokeArgs($object, array $args) { throw new ReflectionException('Method not implemented'); } - public function isAbstract() { throw new ReflectionException('Method not implemented'); } - public function isConstructor() { throw new ReflectionException('Method not implemented'); } - public function isDestructor() { throw new ReflectionException('Method not implemented'); } - public function isFinal() { throw new ReflectionException('Method not implemented'); } - public function isPrivate() { throw new ReflectionException('Method not implemented'); } - public function isProtected() { throw new ReflectionException('Method not implemented'); } - public function isPublic() { throw new ReflectionException('Method not implemented'); } - public function isStatic() { throw new ReflectionException('Method not implemented'); } - public function setAccessible($accessible) { throw new ReflectionException('Method not implemented'); } - public function __toString() { throw new ReflectionException('Method not implemented'); } - public function getClosureThis() { throw new ReflectionException('Method not implemented'); } - public function getEndLine() { throw new ReflectionException('Method not implemented'); } - public function getExtension() { throw new ReflectionException('Method not implemented'); } - public function getExtensionName() { throw new ReflectionException('Method not implemented'); } - public function getFileName() { throw new ReflectionException('Method not implemented'); } - public function getNumberOfParameters() { throw new ReflectionException('Method not implemented'); } - public function getNumberOfRequiredParameters() { throw new ReflectionException('Method not implemented'); } - public function getParameters() { throw new ReflectionException('Method not implemented'); } - public function getShortName() { throw new ReflectionException('Method not implemented'); } - public function getStartLine() { throw new ReflectionException('Method not implemented'); } - public function getStaticVariables() { throw new ReflectionException('Method not implemented'); } - public function inNamespace() { throw new ReflectionException('Method not implemented'); } - public function isClosure() { throw new ReflectionException('Method not implemented'); } - public function isDeprecated() { throw new ReflectionException('Method not implemented'); } - public function isInternal() { throw new ReflectionException('Method not implemented'); } - public function isUserDefined() { throw new ReflectionException('Method not implemented'); } - public function returnsReference() { throw new ReflectionException('Method not implemented'); } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php deleted file mode 100644 index 7f3e41f..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php +++ /dev/null @@ -1,282 +0,0 @@ -. - */ - -namespace Doctrine\Common\Reflection; - -use ReflectionException; -use Doctrine\Common\Annotations\TokenParser; - -/** - * Parses a file for namespaces/use/class declarations. - * - * @author Karoly Negyesi - */ -class StaticReflectionParser implements ReflectionProviderInterface -{ - - /** - * The name of the class. - * - * @var string - */ - protected $className; - - /** - * TRUE if the caller only wants class annotations. - * - * @var boolean. - */ - protected $classAnnotationOptimize; - - /** - * TRUE when the parser has ran. - * - * @var boolean - */ - protected $parsed = false; - - /** - * The namespace of the class - * - * @var string - */ - protected $namespace = ''; - - /** - * The use statements of this class. - * - * @var array - */ - protected $useStatements = array(); - - /** - * The docComment of the class. - * - * @var string - */ - protected $docComment = array( - 'class' => '', - 'property' => array(), - 'method' => array(), - ); - - /** - * The name of the class this class extends, if any. - * - * @var string - */ - protected $parentClassName = ''; - - /** - * The parent PSR-0 Parser. - * - * @var \Doctrine\Common\Annotations\StaticReflectionParser - */ - protected $parentStaticReflectionParser; - - /** - * Parses a class residing in a PSR-0 hierarchy. - * - * @param string $class - * The full, namespaced class name. - * @param ClassFinder $finder - * A ClassFinder object which finds the class. - * @param boolean $classAnnotationOptimize - * Only retrieve the class docComment. Presumes there is only one - * statement per line. - */ - public function __construct($className, $finder, $classAnnotationOptimize = false) - { - $this->className = ltrim($className, '\\'); - if ($lastNsPos = strrpos($this->className, '\\')) { - $this->namespace = substr($this->className, 0, $lastNsPos); - } - $this->finder = $finder; - $this->classAnnotationOptimize = $classAnnotationOptimize; - } - - protected function parse() - { - if ($this->parsed || !$fileName = $this->finder->findFile($this->className)) { - return; - } - $this->parsed = true; - $contents = file_get_contents($fileName); - if ($this->classAnnotationOptimize) { - if (preg_match("/(\A.*)^\s+(abstract|final)?\s+class\s+$className\s+{/sm", $contents, $matches)) { - $contents = $matches[1]; - } - } - $tokenParser = new TokenParser($contents); - $docComment = ''; - while ($token = $tokenParser->next(false)) { - if (is_array($token)) { - switch ($token[0]) { - case T_USE: - $this->useStatements = array_merge($this->useStatements, $tokenParser->parseUseStatement()); - break; - case T_DOC_COMMENT: - $docComment = $token[1]; - break; - case T_CLASS: - $this->docComment['class'] = $docComment; - $docComment = ''; - break; - case T_VAR: - case T_PRIVATE: - case T_PROTECTED: - case T_PUBLIC: - $token = $tokenParser->next(); - if ($token[0] === T_VARIABLE) { - $propertyName = substr($token[1], 1); - $this->docComment['property'][$propertyName] = $docComment; - continue 2; - } - if ($token[0] !== T_FUNCTION) { - // For example, it can be T_FINAL. - continue 2; - } - // No break. - case T_FUNCTION: - // The next string after function is the name, but - // there can be & before the function name so find the - // string. - while (($token = $tokenParser->next()) && $token[0] !== T_STRING); - $methodName = $token[1]; - $this->docComment['method'][$methodName] = $docComment; - $docComment = ''; - break; - case T_EXTENDS: - $this->parentClassName = $tokenParser->parseClass(); - $nsPos = strpos($this->parentClassName, '\\'); - $fullySpecified = false; - if ($nsPos === 0) { - $fullySpecified = true; - } else { - if ($nsPos) { - $prefix = strtolower(substr($this->parentClassName, 0, $nsPos)); - $postfix = substr($this->parentClassName, $nsPos); - } else { - $prefix = strtolower($this->parentClassName); - $postfix = ''; - } - foreach ($this->useStatements as $alias => $use) { - if ($alias == $prefix) { - $this->parentClassName = '\\' . $use . $postfix; - $fullySpecified = true; - } - } - } - if (!$fullySpecified) { - $this->parentClassName = '\\' . $this->namespace . '\\' . $this->parentClassName; - } - break; - } - } - } - } - - protected function getParentStaticReflectionParser() - { - if (empty($this->parentStaticReflectionParser)) { - $this->parentStaticReflectionParser = new static($this->parentClassName, $this->finder); - } - - return $this->parentStaticReflectionParser; - } - - public function getClassName() - { - return $this->className; - } - - public function getNamespaceName() - { - return $this->namespace; - } - - /** - * Get the ReflectionClass equivalent for this file / class. - */ - public function getReflectionClass() - { - return new StaticReflectionClass($this); - } - - /** - * Get the ReflectionMethod equivalent for the method of this file / class. - */ - public function getReflectionMethod($methodName) - { - return new StaticReflectionMethod($this, $methodName); - } - - /** - * Get the ReflectionProperty equivalent for the method of this file / class. - */ - public function getReflectionProperty($propertyName) - { - return new StaticReflectionProperty($this, $propertyName); - } - - /** - * Get the use statements from this file. - */ - public function getUseStatements() - { - $this->parse(); - - return $this->useStatements; - } - - /** - * Get docComment. - * - * @param string $type class, property or method. - * @param string $name Name of the property or method, not needed for class. - * - * @return string the doc comment or empty string if none. - */ - public function getDocComment($type = 'class', $name = '') - { - $this->parse(); - - return $name ? $this->docComment[$type][$name] : $this->docComment[$type]; - } - - /** - * Get the PSR-0 parser for the declaring class. - * - * @param string $type property or method. - * @param string $name Name of the property or method. - * - * @return StaticReflectionParser A static reflection parser for the declaring class. - */ - public function getStaticReflectionParserForDeclaringClass($type, $name) - { - $this->parse(); - if (isset($this->docComment[$type][$name])) { - return $this; - } - if (!empty($this->parentClassName)) { - return $this->getParentStaticReflectionParser()->getStaticReflectionParserForDeclaringClass($type, $name); - } - throw new ReflectionException('Invalid ' . $type . ' "' . $name . '"'); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php b/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php deleted file mode 100644 index 7c6411a..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -namespace Doctrine\Common\Reflection; - -use ReflectionProperty; -use ReflectionException; - -class StaticReflectionProperty extends ReflectionProperty -{ - /** - * The PSR-0 parser object. - * - * @var StaticReflectionParser - */ - protected $staticReflectionParser; - - /** - * The name of the property. - * - * @var string - */ - protected $propertyName; - - public function __construct(StaticReflectionParser $staticReflectionParser, $propertyName) - { - $this->staticReflectionParser = $staticReflectionParser; - $this->propertyName = $propertyName; - } - public function getName() - { - return $this->propertyName; - } - protected function getStaticReflectionParser() - { - return $this->staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', $this->propertyName); - } - public function getDeclaringClass() - { - return $this->getStaticReflectionParser()->getReflectionClass(); - } - public function getDocComment() - { - return $this->getStaticReflectionParser()->getDocComment('property', $this->propertyName); - } - public function getUseStatements() - { - return $this->getStaticReflectionParser()->getUseStatements(); - } - public static function export ($class, $name, $return = false) { throw new ReflectionException('Method not implemented'); } - public function getModifiers() { throw new ReflectionException('Method not implemented'); } - public function getValue($object = NULL) { throw new ReflectionException('Method not implemented'); } - public function isDefault() { throw new ReflectionException('Method not implemented'); } - public function isPrivate() { throw new ReflectionException('Method not implemented'); } - public function isProtected() { throw new ReflectionException('Method not implemented'); } - public function isPublic() { throw new ReflectionException('Method not implemented'); } - public function isStatic() { throw new ReflectionException('Method not implemented'); } - public function setAccessible ($accessible) { throw new ReflectionException('Method not implemented'); } - public function setValue ($object, $value = NULL) { throw new ReflectionException('Method not implemented'); } - public function __toString() { throw new ReflectionException('Method not implemented'); } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Util/ClassUtils.php b/vendor/doctrine/common/lib/Doctrine/Common/Util/ClassUtils.php deleted file mode 100644 index 078a8db..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Util/ClassUtils.php +++ /dev/null @@ -1,103 +0,0 @@ -. - */ - -namespace Doctrine\Common\Util; - -use Doctrine\Common\Persistence\Proxy; - -/** - * Class and reflection related functionality for objects that - * might or not be proxy objects at the moment. - * - * @author Benjamin Eberlei - * @author Johannes Schmitt - */ -class ClassUtils -{ - /** - * Get the real class name of a class name that could be a proxy. - * - * @param string - * @return string - */ - public static function getRealClass($class) - { - if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) { - return $class; - } - - return substr($class, $pos + Proxy::MARKER_LENGTH + 2); - } - - /** - * Get the real class name of an object (even if its a proxy) - * - * @param object - * @return string - */ - public static function getClass($object) - { - return self::getRealClass(get_class($object)); - } - - /** - * Get the real parent class name of a class or object - * - * @param string - * @return string - */ - public static function getParentClass($className) - { - return get_parent_class( self::getRealClass( $className ) ); - } - - /** - * Create a new reflection class - * - * @param string - * @return \ReflectionClass - */ - public static function newReflectionClass($class) - { - return new \ReflectionClass( self::getRealClass( $class ) ); - } - - /** - * Create a new reflection object - * - * @param object - * @return \ReflectionObject - */ - public static function newReflectionObject($object) - { - return self::newReflectionClass( self::getClass( $object ) ); - } - - /** - * Given a class name and a proxy namespace return the proxy name. - * - * @param string $className - * @param string $proxyNamespace - * @return string - */ - public static function generateProxyClassName($className, $proxyNamespace) - { - return rtrim($proxyNamespace, '\\') . '\\'.Proxy::MARKER.'\\' . ltrim($className, '\\'); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php b/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php deleted file mode 100644 index 458e5c8..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php +++ /dev/null @@ -1,135 +0,0 @@ -. - */ - -namespace Doctrine\Common\Util; - -/** - * Static class containing most used debug methods. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Giorgio Sironi - */ -final class Debug -{ - /** - * Private constructor (prevents from instantiation) - * - */ - private function __construct() {} - - /** - * Prints a dump of the public, protected and private properties of $var. - * - * @link http://xdebug.org/ - * @param mixed $var - * @param integer $maxDepth Maximum nesting level for object properties - * @param boolean $stripTags Flag that indicate if output should strip HTML tags - */ - public static function dump($var, $maxDepth = 2, $stripTags = true) - { - ini_set('html_errors', 'On'); - - if (extension_loaded('xdebug')) { - ini_set('xdebug.var_display_max_depth', $maxDepth); - } - - $var = self::export($var, $maxDepth++); - - ob_start(); - var_dump($var); - $dump = ob_get_contents(); - ob_end_clean(); - - echo ($stripTags ? strip_tags(html_entity_decode($dump)) : $dump); - - ini_set('html_errors', 'Off'); - } - - /** - * Export - * - * @param mixed $var - * @param int $maxDepth - * @return mixed - */ - public static function export($var, $maxDepth) - { - $return = null; - $isObj = is_object($var); - - if ($isObj && in_array('Doctrine\Common\Collections\Collection', class_implements($var))) { - $var = $var->toArray(); - } - - if ($maxDepth) { - if (is_array($var)) { - $return = array(); - - foreach ($var as $k => $v) { - $return[$k] = self::export($v, $maxDepth - 1); - } - } else if ($isObj) { - $return = new \stdclass(); - if ($var instanceof \DateTime) { - $return->__CLASS__ = "DateTime"; - $return->date = $var->format('c'); - $return->timezone = $var->getTimeZone()->getName(); - } else { - $reflClass = ClassUtils::newReflectionObject($var); - $return->__CLASS__ = ClassUtils::getClass($var); - - if ($var instanceof \Doctrine\Common\Persistence\Proxy) { - $return->__IS_PROXY__ = true; - $return->__PROXY_INITIALIZED__ = $var->__isInitialized(); - } - - foreach ($reflClass->getProperties() as $reflProperty) { - $name = $reflProperty->getName(); - - $reflProperty->setAccessible(true); - $return->$name = self::export($reflProperty->getValue($var), $maxDepth - 1); - } - } - } else { - $return = $var; - } - } else { - $return = is_object($var) ? get_class($var) - : (is_array($var) ? 'Array(' . count($var) . ')' : $var); - } - - return $return; - } - - /** - * Convert to string - * - * @param object $obj - * @return string - */ - public static function toString($obj) - { - return method_exists('__toString', $obj) ? (string) $obj : get_class($obj) . '@' . spl_object_hash($obj); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Util/Inflector.php b/vendor/doctrine/common/lib/Doctrine/Common/Util/Inflector.php deleted file mode 100644 index 214ed57..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Util/Inflector.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -namespace Doctrine\Common\Util; - -/** - * Doctrine inflector has static methods for inflecting text - * - * The methods in these classes are from several different sources collected - * across several different php projects and several different authors. The - * original author names and emails are not known - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 1.0 - * @version $Revision: 3189 $ - * @author Konsta Vesterinen - * @author Jonathan H. Wage - */ -class Inflector -{ - /** - * Convert word in to the format for a Doctrine table name. Converts 'ModelName' to 'model_name' - * - * @param string $word Word to tableize - * @return string $word Tableized word - */ - public static function tableize($word) - { - return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word)); - } - - /** - * Convert a word in to the format for a Doctrine class name. Converts 'table_name' to 'TableName' - * - * @param string $word Word to classify - * @return string $word Classified word - */ - public static function classify($word) - { - return str_replace(" ", "", ucwords(strtr($word, "_-", " "))); - } - - /** - * Camelize a word. This uses the classify() method and turns the first character to lowercase - * - * @param string $word - * @return string $word - */ - public static function camelize($word) - { - return lcfirst(self::classify($word)); - } -} diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Version.php b/vendor/doctrine/common/lib/Doctrine/Common/Version.php deleted file mode 100644 index cca4894..0000000 --- a/vendor/doctrine/common/lib/Doctrine/Common/Version.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -namespace Doctrine\Common; - -/** - * Class to store and retrieve the version of Doctrine - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - */ -class Version -{ - /** - * Current Doctrine Version - */ - const VERSION = '2.3.0'; - - /** - * Compares a Doctrine version with the current one. - * - * @param string $version Doctrine version to compare. - * @return int Returns -1 if older, 0 if it is the same, 1 if version - * passed as argument is newer. - */ - public static function compare($version) - { - $currentVersion = str_replace(' ', '', strtolower(self::VERSION)); - $version = str_replace(' ', '', $version); - - return version_compare($version, $currentVersion); - } -} diff --git a/vendor/doctrine/common/phpunit.xml.dist b/vendor/doctrine/common/phpunit.xml.dist deleted file mode 100644 index b9d3b34..0000000 --- a/vendor/doctrine/common/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - ./tests/Doctrine/ - - - - - - ./lib/Doctrine/ - - - - - - performance - - - diff --git a/vendor/doctrine/common/tests/.gitignore b/vendor/doctrine/common/tests/.gitignore deleted file mode 100644 index 7210405..0000000 --- a/vendor/doctrine/common/tests/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Doctrine/Tests/Proxies/ -Doctrine/Tests/ORM/Proxy/generated/ -Doctrine/Tests/ORM/Tools/Export/export diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php deleted file mode 100644 index 4261e6b..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ /dev/null @@ -1,517 +0,0 @@ - array($testsRoot), - ); - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); - return array( - 'native' => array(new ReflectionClass($className)), - 'static' => array($staticReflectionParser->getReflectionClass()), - ); - } - - /** - * @dataProvider getReflectionClass - */ - public function testAnnotations($class) - { - $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); - } - - /** - * @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')); - } - - /** - * @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 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); - } - - /** - * @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'))); - } - - abstract protected function getReader(); -} - -/** - * @parseAnnotation("var") - * @author Johannes M. Schmitt - * - */ -class TestParseAnnotationClass -{ - /** - * @var - */ - private $field; -} - -/** - * @Name - * @author Johannes M. Schmitt - */ -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 \Doctrine\Common\Annotations\Annotation {} -/** @Annotation */ -class DummyColumn extends \Doctrine\Common\Annotations\Annotation { - public $type; -} -/** @Annotation */ -class DummyGeneratedValue extends \Doctrine\Common\Annotations\Annotation {} -/** @Annotation */ -class DummyAnnotation extends \Doctrine\Common\Annotations\Annotation { - public $dummyValue; -} -/** @Annotation */ -class DummyJoinColumn extends \Doctrine\Common\Annotations\Annotation { - public $name; - public $referencedColumnName; -} -/** @Annotation */ -class DummyJoinTable extends \Doctrine\Common\Annotations\Annotation { - public $name; - public $joinColumns; - public $inverseJoinColumns; -} - -/** - * @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 -*/ -class DummyClassWithEmail -{ - -} - -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; -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php deleted file mode 100644 index d2cc667..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php +++ /dev/null @@ -1,13 +0,0 @@ -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 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php deleted file mode 100644 index 03a55c8..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php +++ /dev/null @@ -1,137 +0,0 @@ -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, \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' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\IntefaceWithConstants::SOME_VALUE', - 'position' => 66, - 'type' => DocLexer::T_IDENTIFIER, - ), - array( - 'value' => ')', - 'position' => 143, - '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 diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php deleted file mode 100644 index b14698f..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ /dev/null @@ -1,1208 +0,0 @@ -createTestParser(); - - // Nested arrays with nested annotations - $result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})'); - $annot = $result[0]; - - $this->assertTrue($annot instanceof Name); - $this->assertNull($annot->value); - $this->assertEquals(3, count($annot->foo)); - $this->assertEquals(1, $annot->foo[0]); - $this->assertEquals(2, $annot->foo[1]); - $this->assertTrue(is_array($annot->foo[2])); - - $nestedArray = $annot->foo[2]; - $this->assertTrue(isset($nestedArray['key'])); - $this->assertTrue($nestedArray['key'] instanceof Name); - } - - public function testBasicAnnotations() - { - $parser = $this->createTestParser(); - - // Marker annotation - $result = $parser->parse("@Name"); - $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertNull($annot->value); - $this->assertNull($annot->foo); - - // Associative arrays - $result = $parser->parse('@Name(foo={"key1" = "value1"})'); - $annot = $result[0]; - $this->assertNull($annot->value); - $this->assertTrue(is_array($annot->foo)); - $this->assertTrue(isset($annot->foo['key1'])); - - // Numerical arrays - $result = $parser->parse('@Name({2="foo", 4="bar"})'); - $annot = $result[0]; - $this->assertTrue(is_array($annot->value)); - $this->assertEquals('foo', $annot->value[2]); - $this->assertEquals('bar', $annot->value[4]); - $this->assertFalse(isset($annot->value[0])); - $this->assertFalse(isset($annot->value[1])); - $this->assertFalse(isset($annot->value[3])); - - // Multiple values - $result = $parser->parse('@Name(@Name, @Name)'); - $annot = $result[0]; - - $this->assertTrue($annot instanceof Name); - $this->assertTrue(is_array($annot->value)); - $this->assertTrue($annot->value[0] instanceof Name); - $this->assertTrue($annot->value[1] instanceof Name); - - // Multiple types as values - $result = $parser->parse('@Name(foo="Bar", @Name, {"key1"="value1", "key2"="value2"})'); - $annot = $result[0]; - - $this->assertTrue($annot instanceof Name); - $this->assertTrue(is_array($annot->value)); - $this->assertTrue($annot->value[0] instanceof Name); - $this->assertTrue(is_array($annot->value[1])); - $this->assertEquals('value1', $annot->value[1]['key1']); - $this->assertEquals('value2', $annot->value[1]['key2']); - - // Complete docblock - $docblock = <<parse($docblock); - $this->assertEquals(1, count($result)); - $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); - $this->assertNull($annot->value); - } - - public function testNamespacedAnnotations() - { - $parser = new DocParser; - $parser->setIgnoreNotImportedAnnotations(true); - - $docblock = << - * @Doctrine\Tests\Common\Annotations\Name(foo="bar") - * @ignore - */ -DOCBLOCK; - - $result = $parser->parse($docblock); - $this->assertEquals(1, count($result)); - $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); - } - - /** - * @group debug - */ - public function testTypicalMethodDocBlock() - { - $parser = $this->createTestParser(); - - $docblock = <<parse($docblock); - $this->assertEquals(2, count($result)); - $this->assertTrue(isset($result[0])); - $this->assertTrue(isset($result[1])); - $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); - $marker = $result[1]; - $this->assertTrue($marker instanceof Marker); - } - - - public function testAnnotationWithoutConstructor() - { - $parser = $this->createTestParser(); - - - $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $annot = $result[0]; - - $this->assertNotNull($annot); - $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); - - $this->assertNull($annot->name); - $this->assertNotNull($annot->data); - $this->assertEquals($annot->data, "Some data"); - - - - -$docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $annot = $result[0]; - - $this->assertNotNull($annot); - $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); - - $this->assertEquals($annot->name, "Some Name"); - $this->assertEquals($annot->data, "Some data"); - - - - -$docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $annot = $result[0]; - - $this->assertEquals($annot->data, "Some data"); - $this->assertNull($annot->name); - - - $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $annot = $result[0]; - - $this->assertEquals($annot->name, "Some name"); - $this->assertNull($annot->data); - - $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $annot = $result[0]; - - $this->assertEquals($annot->data, "Some data"); - $this->assertNull($annot->name); - - - - $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $annot = $result[0]; - - $this->assertEquals($annot->name, "Some name"); - $this->assertEquals($annot->data, "Some data"); - - - $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $annot = $result[0]; - - $this->assertEquals($annot->name, "Some name"); - $this->assertEquals($annot->data, "Some data"); - - $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $this->assertTrue($result[0] instanceof SomeAnnotationClassNameWithoutConstructorAndProperties); - } - - public function testAnnotationTarget() - { - - $parser = new DocParser; - $parser->setImports(array( - '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations\Fixtures', - )); - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget'); - - - $context = 'class ' . $class->getName(); - $docComment = $class->getDocComment(); - - $parser->setTarget(Target::TARGET_CLASS); - $this->assertNotNull($parser->parse($docComment,$context)); - - - $property = $class->getProperty('foo'); - $docComment = $property->getDocComment(); - $context = 'property ' . $class->getName() . "::\$" . $property->getName(); - - $parser->setTarget(Target::TARGET_PROPERTY); - $this->assertNotNull($parser->parse($docComment,$context)); - - - - $method = $class->getMethod('someFunction'); - $docComment = $property->getDocComment(); - $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; - - $parser->setTarget(Target::TARGET_METHOD); - $this->assertNotNull($parser->parse($docComment,$context)); - - - try { - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass'); - $context = 'class ' . $class->getName(); - $docComment = $class->getDocComment(); - - $parser->setTarget(Target::TARGET_CLASS); - $parser->parse($class->getDocComment(),$context); - - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); - } - - - try { - - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod'); - $method = $class->getMethod('functionName'); - $docComment = $method->getDocComment(); - $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; - - $parser->setTarget(Target::TARGET_METHOD); - $parser->parse($docComment,$context); - - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); - } - - - try { - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty'); - $property = $class->getProperty('foo'); - $docComment = $property->getDocComment(); - $context = 'property ' . $class->getName() . "::\$" . $property->getName(); - - $parser->setTarget(Target::TARGET_PROPERTY); - $parser->parse($docComment,$context); - - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); - } - - } - - public function getAnnotationVarTypeProviderValid() - { - //({attribute name}, {attribute value}) - return array( - // mixed type - array('mixed', '"String Value"'), - array('mixed', 'true'), - array('mixed', 'false'), - array('mixed', '1'), - array('mixed', '1.2'), - array('mixed', '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll'), - - // boolean type - array('boolean', 'true'), - array('boolean', 'false'), - - // alias for internal type boolean - array('bool', 'true'), - array('bool', 'false'), - - // integer type - array('integer', '0'), - array('integer', '1'), - array('integer', '123456789'), - array('integer', '9223372036854775807'), - - // alias for internal type double - array('float', '0.1'), - array('float', '1.2'), - array('float', '123.456'), - - // string type - array('string', '"String Value"'), - array('string', '"true"'), - array('string', '"123"'), - - // array type - array('array', '{@AnnotationExtendsAnnotationTargetAll}'), - array('array', '{@AnnotationExtendsAnnotationTargetAll,@AnnotationExtendsAnnotationTargetAll}'), - - array('arrayOfIntegers', '1'), - array('arrayOfIntegers', '{1}'), - array('arrayOfIntegers', '{1,2,3,4}'), - array('arrayOfAnnotations', '@AnnotationExtendsAnnotationTargetAll'), - array('arrayOfAnnotations', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll}'), - array('arrayOfAnnotations', '{@AnnotationExtendsAnnotationTargetAll, @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll}'), - - // annotation instance - array('annotation', '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll'), - array('annotation', '@AnnotationExtendsAnnotationTargetAll'), - ); - } - - public function getAnnotationVarTypeProviderInvalid() - { - //({attribute name}, {type declared type}, {attribute value} , {given type or class}) - return array( - // boolean type - array('boolean','boolean','1','integer'), - array('boolean','boolean','1.2','double'), - array('boolean','boolean','"str"','string'), - array('boolean','boolean','{1,2,3}','array'), - array('boolean','boolean','@Name', 'an instance of Doctrine\Tests\Common\Annotations\Name'), - - // alias for internal type boolean - array('bool','bool', '1','integer'), - array('bool','bool', '1.2','double'), - array('bool','bool', '"str"','string'), - array('bool','bool', '{"str"}','array'), - - // integer type - array('integer','integer', 'true','boolean'), - array('integer','integer', 'false','boolean'), - array('integer','integer', '1.2','double'), - array('integer','integer', '"str"','string'), - array('integer','integer', '{"str"}','array'), - array('integer','integer', '{1,2,3,4}','array'), - - // alias for internal type double - array('float','float', 'true','boolean'), - array('float','float', 'false','boolean'), - array('float','float', '123','integer'), - array('float','float', '"str"','string'), - array('float','float', '{"str"}','array'), - array('float','float', '{12.34}','array'), - array('float','float', '{1,2,3}','array'), - - // string type - array('string','string', 'true','boolean'), - array('string','string', 'false','boolean'), - array('string','string', '12','integer'), - array('string','string', '1.2','double'), - array('string','string', '{"str"}','array'), - array('string','string', '{1,2,3,4}','array'), - - // annotation instance - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'true','boolean'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'false','boolean'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '12','integer'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '1.2','double'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{"str"}','array'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{1,2,3,4}','array'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '@Name','an instance of Doctrine\Tests\Common\Annotations\Name'), - ); - } - - public function getAnnotationVarTypeArrayProviderInvalid() - { - //({attribute name}, {type declared type}, {attribute value} , {given type or class}) - return array( - array('arrayOfIntegers','integer', 'true','boolean'), - array('arrayOfIntegers','integer', 'false','boolean'), - array('arrayOfIntegers','integer', '{true,true}','boolean'), - array('arrayOfIntegers','integer', '{1,true}','boolean'), - array('arrayOfIntegers','integer', '{1,2,1.2}','double'), - array('arrayOfIntegers','integer', '{1,2,"str"}','string'), - - - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'true','boolean'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'false','boolean'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}','boolean'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}','boolean'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,1.2}','double'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,@AnnotationExtendsAnnotationTargetAll,"str"}','string'), - ); - } - - /** - * @dataProvider getAnnotationVarTypeProviderValid - */ - public function testAnnotationWithVarType($attribute, $value) - { - $parser = $this->createTestParser(); - $context = 'property SomeClassName::$invalidProperty.'; - $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType(%s = %s)',$attribute, $value); - $parser->setTarget(Target::TARGET_PROPERTY); - - $result = $parser->parse($docblock, $context); - - $this->assertTrue(sizeof($result) === 1); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType', $result[0]); - $this->assertNotNull($result[0]->$attribute); - } - - /** - * @dataProvider getAnnotationVarTypeProviderInvalid - */ - public function testAnnotationWithVarTypeError($attribute,$type,$value,$given) - { - $parser = $this->createTestParser(); - $context = 'property SomeClassName::invalidProperty.'; - $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType(%s = %s)',$attribute, $value); - $parser->setTarget(Target::TARGET_PROPERTY); - - try { - $parser->parse($docblock, $context); - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage()); - } - } - - - /** - * @dataProvider getAnnotationVarTypeArrayProviderInvalid - */ - public function testAnnotationWithVarTypeArrayError($attribute,$type,$value,$given) - { - $parser = $this->createTestParser(); - $context = 'property SomeClassName::invalidProperty.'; - $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType(%s = %s)',$attribute, $value); - $parser->setTarget(Target::TARGET_PROPERTY); - - try { - $parser->parse($docblock, $context); - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage()); - } - } - - /** - * @dataProvider getAnnotationVarTypeProviderValid - */ - public function testAnnotationWithAttributes($attribute, $value) - { - $parser = $this->createTestParser(); - $context = 'property SomeClassName::$invalidProperty.'; - $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes(%s = %s)',$attribute, $value); - $parser->setTarget(Target::TARGET_PROPERTY); - - $result = $parser->parse($docblock, $context); - - $this->assertTrue(sizeof($result) === 1); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes', $result[0]); - $getter = "get".ucfirst($attribute); - $this->assertNotNull($result[0]->$getter()); - } - - /** - * @dataProvider getAnnotationVarTypeProviderInvalid - */ - public function testAnnotationWithAttributesError($attribute,$type,$value,$given) - { - $parser = $this->createTestParser(); - $context = 'property SomeClassName::invalidProperty.'; - $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes(%s = %s)',$attribute, $value); - $parser->setTarget(Target::TARGET_PROPERTY); - - try { - $parser->parse($docblock, $context); - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage()); - } - } - - - /** - * @dataProvider getAnnotationVarTypeArrayProviderInvalid - */ - public function testAnnotationWithAttributesWithVarTypeArrayError($attribute,$type,$value,$given) - { - $parser = $this->createTestParser(); - $context = 'property SomeClassName::invalidProperty.'; - $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes(%s = %s)',$attribute, $value); - $parser->setTarget(Target::TARGET_PROPERTY); - - try { - $parser->parse($docblock, $context); - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage()); - } - } - - public function testAnnotationWithRequiredAttributes() - { - $parser = $this->createTestParser(); - $context = 'property SomeClassName::invalidProperty.'; - $parser->setTarget(Target::TARGET_PROPERTY); - - - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; - $result = $parser->parse($docblock); - - $this->assertTrue(sizeof($result) === 1); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes', $result[0]); - $this->assertEquals("Some Value",$result[0]->getValue()); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->getAnnot()); - - - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value")'; - try { - $result = $parser->parse($docblock,$context); - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage()); - } - - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; - try { - $result = $parser->parse($docblock,$context); - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains('Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage()); - } - - } - - public function testAnnotationWithRequiredAttributesWithoutContructor() - { - $parser = $this->createTestParser(); - $context = 'property SomeClassName::invalidProperty.'; - $parser->setTarget(Target::TARGET_PROPERTY); - - - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; - $result = $parser->parse($docblock); - - $this->assertTrue(sizeof($result) === 1); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor', $result[0]); - $this->assertEquals("Some Value", $result[0]->value); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->annot); - - - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor("Some Value")'; - try { - $result = $parser->parse($docblock,$context); - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor declared on property SomeClassName::invalidProperty. expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage()); - } - - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; - try { - $result = $parser->parse($docblock,$context); - $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains('Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage()); - } - - } - - public function getConstantsProvider() - { - $provider[] = array( - '@AnnotationWithConstants(PHP_EOL)', - PHP_EOL - ); - $provider[] = array( - '@AnnotationWithConstants(AnnotationWithConstants::INTEGER)', - AnnotationWithConstants::INTEGER - ); - $provider[] = array( - '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants(AnnotationWithConstants::STRING)', - AnnotationWithConstants::STRING - ); - $provider[] = array( - '@AnnotationWithConstants(Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants::FLOAT)', - AnnotationWithConstants::FLOAT - ); - $provider[] = array( - '@AnnotationWithConstants(ClassWithConstants::SOME_VALUE)', - ClassWithConstants::SOME_VALUE - ); - $provider[] = array( - '@AnnotationWithConstants(Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants::SOME_VALUE)', - ClassWithConstants::SOME_VALUE - ); - $provider[] = array( - '@AnnotationWithConstants(IntefaceWithConstants::SOME_VALUE)', - IntefaceWithConstants::SOME_VALUE - ); - $provider[] = array( - '@AnnotationWithConstants(\Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)', - IntefaceWithConstants::SOME_VALUE - ); - $provider[] = array( - '@AnnotationWithConstants({AnnotationWithConstants::STRING, AnnotationWithConstants::INTEGER, AnnotationWithConstants::FLOAT})', - array(AnnotationWithConstants::STRING, AnnotationWithConstants::INTEGER, AnnotationWithConstants::FLOAT) - ); - $provider[] = array( - '@AnnotationWithConstants({ - AnnotationWithConstants::STRING = AnnotationWithConstants::INTEGER - })', - array(AnnotationWithConstants::STRING => AnnotationWithConstants::INTEGER) - ); - $provider[] = array( - '@AnnotationWithConstants({ - Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_KEY = AnnotationWithConstants::INTEGER - })', - array(IntefaceWithConstants::SOME_KEY => AnnotationWithConstants::INTEGER) - ); - $provider[] = array( - '@AnnotationWithConstants({ - \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_KEY = AnnotationWithConstants::INTEGER - })', - array(IntefaceWithConstants::SOME_KEY => AnnotationWithConstants::INTEGER) - ); - $provider[] = array( - '@AnnotationWithConstants({ - AnnotationWithConstants::STRING = AnnotationWithConstants::INTEGER, - ClassWithConstants::SOME_KEY = ClassWithConstants::SOME_VALUE, - Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants::SOME_KEY = IntefaceWithConstants::SOME_VALUE - })', - array( - AnnotationWithConstants::STRING => AnnotationWithConstants::INTEGER, - ClassWithConstants::SOME_KEY => ClassWithConstants::SOME_VALUE, - ClassWithConstants::SOME_KEY => IntefaceWithConstants::SOME_VALUE - ) - ); - return $provider; - } - - /** - * @dataProvider getConstantsProvider - */ - public function testSupportClassConstants($docblock, $expected) - { - $parser = $this->createTestParser(); - $parser->setImports(array( - 'classwithconstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants', - 'intefacewithconstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants', - 'annotationwithconstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' - )); - - $result = $parser->parse($docblock); - $this->assertInstanceOf('\Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants', $annotation = $result[0]); - $this->assertEquals($expected, $annotation->value); - } - - /** - * @expectedException Doctrine\Common\Annotations\AnnotationException - * @expectedExceptionMessage The annotation @SomeAnnotationClassNameWithoutConstructorAndProperties declared on does not accept any values, but got {"value":"Foo"}. - */ - public function testWithoutConstructorWhenIsNotDefaultValue() - { - $parser = $this->createTestParser(); - $docblock = <<setTarget(Target::TARGET_CLASS); - $parser->parse($docblock); - } - - /** - * @expectedException Doctrine\Common\Annotations\AnnotationException - * @expectedExceptionMessage The annotation @SomeAnnotationClassNameWithoutConstructorAndProperties declared on does not accept any values, but got {"value":"Foo"}. - */ - public function testWithoutConstructorWhenHasNoProperties() - { - $parser = $this->createTestParser(); - $docblock = <<setTarget(Target::TARGET_CLASS); - $parser->parse($docblock); - } - - /** - * @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 testAnnotationTargetSyntaxError() - { - $parser = $this->createTestParser(); - $context = 'class ' . 'SomeClassName'; - $docblock = <<setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid Target "Foo". Available targets: [ALL, CLASS, METHOD, PROPERTY, ANNOTATION] - */ - public function testAnnotationWithInvalidTargetDeclarationError() - { - $parser = $this->createTestParser(); - $context = 'class ' . 'SomeClassName'; - $docblock = <<setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage @Target expects either a string value, or an array of strings, "NULL" given. - */ - public function testAnnotationWithTargetEmptyError() - { - $parser = $this->createTestParser(); - $context = 'class ' . 'SomeClassName'; - $docblock = <<setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); - } - - /** - * @group DDC-575 - */ - public function testRegressionDDC575() - { - $parser = $this->createTestParser(); - - $docblock = <<parse($docblock); - - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]); - - $docblock = <<parse($docblock); - - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]); - } - - /** - * @group DDC-77 - */ - public function testAnnotationWithoutClassIsIgnoredWithoutWarning() - { - $parser = new DocParser(); - $parser->setIgnoreNotImportedAnnotations(true); - $result = $parser->parse("@param"); - - $this->assertEquals(0, count($result)); - } - - /** - * @expectedException Doctrine\Common\Annotations\AnnotationException - * @expectedExceptionMessage Expected PlainValue, got ''' at position 10. - */ - public function testAnnotationDontAcceptSingleQuotes() - { - $parser = $this->createTestParser(); - $parser->parse("@Name(foo='bar')"); - } - - /** - * @group DCOM-41 - */ - public function testAnnotationDoesntThrowExceptionWhenAtSignIsNotFollowedByIdentifier() - { - $parser = new DocParser(); - $result = $parser->parse("'@'"); - - $this->assertEquals(0, count($result)); - } - - /** - * @group DCOM-41 - * @expectedException Doctrine\Common\Annotations\AnnotationException - */ - public function testAnnotationThrowsExceptionWhenAtSignIsNotFollowedByIdentifierInNestedAnnotation() - { - $parser = new DocParser(); - $result = $parser->parse("@Doctrine\Tests\Common\Annotations\Name(@')"); - } - - /** - * @group DCOM-56 - */ - public function testAutoloadAnnotation() - { - $this->assertFalse(class_exists('Doctrine\Tests\Common\Annotations\Fixture\Annotation\Autoload', false), 'Pre-condition: Doctrine\Tests\Common\Annotations\Fixture\Annotation\Autoload not allowed to be loaded.'); - - $parser = new DocParser(); - - AnnotationRegistry::registerAutoloadNamespace('Doctrine\Tests\Common\Annotations\Fixtures\Annotation', __DIR__ . '/../../../../'); - - $parser->setImports(array( - 'autoload' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', - )); - $annotations = $parser->parse('@Autoload'); - - $this->assertEquals(1, count($annotations)); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); - } - - public function createTestParser() - { - $parser = new DocParser(); - $parser->setIgnoreNotImportedAnnotations(true); - $parser->setImports(array( - 'name' => 'Doctrine\Tests\Common\Annotations\Name', - '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations', - )); - - return $parser; - } - - /** - * @group DDC-78 - * @expectedException Doctrine\Common\Annotations\AnnotationException - * @expectedExceptionMessage Expected PlainValue, got ''' at position 10 in class \Doctrine\Tests\Common\Annotations\Name - */ - public function testSyntaxErrorWithContextDescription() - { - $parser = $this->createTestParser(); - $parser->parse("@Name(foo='bar')", "class \Doctrine\Tests\Common\Annotations\Name"); - } - - /** - * @group DDC-183 - */ - public function testSyntaxErrorWithUnknownCharacters() - { - $docblock = <<setInput(trim($docblock, '/ *')); - //var_dump($lexer); - - try { - $parser = $this->createTestParser(); - $result = $parser->parse($docblock); - } catch (Exception $e) { - $this->fail($e->getMessage()); - } - } - - /** - * @group DCOM-14 - */ - public function testIgnorePHPDocThrowTag() - { - $docblock = <<createTestParser(); - $result = $parser->parse($docblock); - } catch (Exception $e) { - $this->fail($e->getMessage()); - } - } - - /** - * @group DCOM-38 - */ - public function testCastInt() - { - $parser = $this->createTestParser(); - - $result = $parser->parse("@Name(foo=1234)"); - $annot = $result[0]; - $this->assertInternalType('int', $annot->foo); - } - - /** - * @group DCOM-38 - */ - public function testCastNegativeInt() - { - $parser = $this->createTestParser(); - - $result = $parser->parse("@Name(foo=-1234)"); - $annot = $result[0]; - $this->assertInternalType('int', $annot->foo); - } - - /** - * @group DCOM-38 - */ - public function testCastFloat() - { - $parser = $this->createTestParser(); - - $result = $parser->parse("@Name(foo=1234.345)"); - $annot = $result[0]; - $this->assertInternalType('float', $annot->foo); - } - - /** - * @group DCOM-38 - */ - public function testCastNegativeFloat() - { - $parser = $this->createTestParser(); - - $result = $parser->parse("@Name(foo=-1234.345)"); - $annot = $result[0]; - $this->assertInternalType('float', $annot->foo); - - $result = $parser->parse("@Marker(-1234.345)"); - $annot = $result[0]; - $this->assertInternalType('float', $annot->value); - } - - public function testReservedKeywordsInAnnotations() - { - $parser = $this->createTestParser(); - - $result = $parser->parse('@Doctrine\Tests\Common\Annotations\True'); - $this->assertTrue($result[0] instanceof True); - $result = $parser->parse('@Doctrine\Tests\Common\Annotations\False'); - $this->assertTrue($result[0] instanceof False); - $result = $parser->parse('@Doctrine\Tests\Common\Annotations\Null'); - $this->assertTrue($result[0] instanceof Null); - - $result = $parser->parse('@True'); - $this->assertTrue($result[0] instanceof True); - $result = $parser->parse('@False'); - $this->assertTrue($result[0] instanceof False); - $result = $parser->parse('@Null'); - $this->assertTrue($result[0] instanceof Null); - } - - /** - * @expectedException Doctrine\Common\Annotations\AnnotationException - * @expectedExceptionMessage [Creation Error] The annotation @SomeAnnotationClassNameWithoutConstructor declared on some class does not have a property named "invalidaProperty". Available properties: data, name - */ - public function testSetValuesExeption() - { - $docblock = <<createTestParser()->parse($docblock, 'some class'); - } - - /** - * @expectedException Doctrine\Common\Annotations\AnnotationException - * @expectedExceptionMessage [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_IDENTIFIER or Doctrine\Common\Annotations\DocLexer::T_TRUE or Doctrine\Common\Annotations\DocLexer::T_FALSE or Doctrine\Common\Annotations\DocLexer::T_NULL, got '3.42' at position 5. - */ - public function testInvalidIdentifierInAnnotation() - { - $parser = $this->createTestParser(); - $parser->parse('@Foo\3.42'); - } - - public function testTrailingCommaIsAllowed() - { - $parser = $this->createTestParser(); - - $annots = $parser->parse('@Name({ - "Foo", - "Bar", - })'); - $this->assertEquals(1, count($annots)); - $this->assertEquals(array('Foo', 'Bar'), $annots[0]->value); - } - - public function testDefaultAnnotationValueIsNotOverwritten() - { - $parser = $this->createTestParser(); - - $annots = $parser->parse('@Doctrine\Tests\Common\Annotations\Fixtures\Annotation\AnnotWithDefaultValue'); - $this->assertEquals(1, count($annots)); - $this->assertEquals('bar', $annots[0]->foo); - } - - public function testArrayWithColon() - { - $parser = $this->createTestParser(); - - $annots = $parser->parse('@Name({"foo": "bar"})'); - $this->assertEquals(1, count($annots)); - $this->assertEquals(array('foo' => 'bar'), $annots[0]->value); - } - - /** - * @expectedException Doctrine\Common\Annotations\AnnotationException - * @expectedExceptionMessage [Semantical Error] Couldn't find constant foo. - */ - public function testInvalidContantName() - { - $parser = $this->createTestParser(); - $parser->parse('@Name(foo: "bar")'); - } -} - -/** @Annotation */ -class SomeAnnotationClassNameWithoutConstructor -{ - public $data; - public $name; -} - -/** @Annotation */ -class SomeAnnotationWithConstructorWithoutParams -{ - function __construct() - { - $this->data = "Some data"; - } - public $data; - public $name; -} - -/** @Annotation */ -class SomeAnnotationClassNameWithoutConstructorAndProperties{} - -/** - * @Annotation - * @Target("Foo") - */ -class AnnotationWithInvalidTargetDeclaration{} - -/** - * @Annotation - * @Target - */ -class AnnotationWithTargetEmpty{} - -/** @Annotation */ -class AnnotationExtendsAnnotationTargetAll extends \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll -{ -} - -/** @Annotation */ -class Name extends \Doctrine\Common\Annotations\Annotation { - public $foo; -} - -/** @Annotation */ -class Marker { - public $value; -} - -/** @Annotation */ -class True {} - -/** @Annotation */ -class False {} - -/** @Annotation */ -class Null {} - -namespace Doctrine\Tests\Common\Annotations\FooBar; - -/** @Annotation */ -class Name extends \Doctrine\Common\Annotations\Annotation { -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DummyClass.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DummyClass.php deleted file mode 100644 index 17223f6..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DummyClass.php +++ /dev/null @@ -1,48 +0,0 @@ -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)); - - $cache = new FileCacheReader(new AnnotationReader(), $this->cacheDir); - - $this->assertTrue(is_dir($this->cacheDir)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php deleted file mode 100644 index 44108e1..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php +++ /dev/null @@ -1,10 +0,0 @@ -roles = $values['value']; - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php deleted file mode 100644 index b507e60..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php +++ /dev/null @@ -1,14 +0,0 @@ -name = isset($values['value']) ? $values['value'] : null; - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php deleted file mode 100644 index 09ef031..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php +++ /dev/null @@ -1,11 +0,0 @@ -"), - @Attribute("annotation", type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll"), - @Attribute("arrayOfAnnotations", type = "array"), - }) - */ -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 $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 array - */ - public function getArrayOfIntegers() - { - return $this->arrayOfIntegers; - } - - /** - * @return array - */ - public function getArrayOfAnnotations() - { - return $this->arrayOfAnnotations; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithConstants.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithConstants.php deleted file mode 100644 index 9c94558..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithConstants.php +++ /dev/null @@ -1,20 +0,0 @@ - $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; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php deleted file mode 100644 index bf458ee..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - public $arrayOfIntegers; - - /** - * @var array - */ - public $arrayOfAnnotations; - -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php deleted file mode 100644 index 4e652e1..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php +++ /dev/null @@ -1,30 +0,0 @@ -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; - } - -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php deleted file mode 100644 index 055e245..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ -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)); - } - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/DifferentNamespacesPerFileWithClassAsFirst.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/DifferentNamespacesPerFileWithClassAsFirst.php deleted file mode 100644 index bda2cc2..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/DifferentNamespacesPerFileWithClassAsFirst.php +++ /dev/null @@ -1,15 +0,0 @@ -test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test2() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test3() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test4() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test5() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test6() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test7() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test8() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - - } - - public function test9() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test10() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test11() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test12() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test13() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test14() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test15() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test16() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test17() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - - } - - public function test18() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test19() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test20() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test21() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test22() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test23() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test24() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test25() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test26() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test27() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - - } - - public function test28() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test29() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test30() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test31() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test32() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test33() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test34() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test35() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test36() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test37() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - - } - - public function test38() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test39() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/NoAnnotation.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/NoAnnotation.php deleted file mode 100644 index 1dae104..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/NoAnnotation.php +++ /dev/null @@ -1,5 +0,0 @@ -test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test2() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test3() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test4() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test5() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test6() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test7() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test8() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - - } - - public function test9() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test10() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test11() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test12() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test13() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test14() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test15() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test16() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test17() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - - } - - public function test18() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test19() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test20() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test21() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test22() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test23() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test24() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test25() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test26() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test27() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - - } - - public function test28() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test29() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test30() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test31() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test32() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test33() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test34() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test35() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test36() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test37() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - - } - - public function test38() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } - - public function test39() - { - echo $this->test1; - echo $this->test2; - echo $this->test3; - $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - foreach ($array as $key => $value) { - echo $key . ' => ' . $value; - } - - $val = (string)self::TEST1; - $val .= (string)self::TEST2; - $val .= (string)self::TEST3; - $val .= (string)self::TEST4; - $val .= (string)self::TEST5; - $val .= (string)self::TEST6; - $val .= (string)self::TEST7; - $val .= (string)self::TEST8; - $val .= (string)self::TEST9; - - strtolower($val); - - return $val; - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php deleted file mode 100644 index 58c5e6a..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -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"; - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php deleted file mode 100644 index cf81116..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php +++ /dev/null @@ -1,194 +0,0 @@ -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 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)); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php deleted file mode 100644 index 376539f..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php +++ /dev/null @@ -1,97 +0,0 @@ -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; - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php deleted file mode 100644 index a7b9e2f..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php +++ /dev/null @@ -1,65 +0,0 @@ -getClassAnnotations($class); - } - - public function testAnnotation() - { - $class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Consumer'); - $reader = new \Doctrine\Common\Annotations\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 \Doctrine\Common\Annotations\AnnotationReader(); - $annots = $reader->getClassAnnotations($class); - - $this->assertEquals(0, count($annots)); - } -} - -/** - * @Controller - */ -class Dummy -{ - -} - -/** - * @Annotation - */ -class DCOM55Annotation -{ - -} - -/** - * @DCOM55Annotation - */ -class DCOM55Consumer -{ - -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php deleted file mode 100644 index 708bcc9..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php +++ /dev/null @@ -1,8 +0,0 @@ -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 \Doctrine\Common\Annotations\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 \Doctrine\Common\Annotations\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 \Doctrine\Common\Annotations\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 \Doctrine\Common\Annotations\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 \Doctrine\Common\Annotations\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 -{ - -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php deleted file mode 100644 index ff3ca37..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php +++ /dev/null @@ -1,8 +0,0 @@ -markTestSkipped('The ' . __CLASS__ .' requires the use of APC'); - } - } - - protected function _getCacheDriver() - { - return new ApcCache(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php deleted file mode 100644 index 6cad891..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php +++ /dev/null @@ -1,21 +0,0 @@ -_getCacheDriver(); - $stats = $cache->getStats(); - - $this->assertNull($stats); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/CacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/CacheTest.php deleted file mode 100644 index 1bbc165..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/CacheTest.php +++ /dev/null @@ -1,91 +0,0 @@ -_getCacheDriver(); - - // Test save - $cache->save('test_key', 'testing this out'); - - // Test contains to test that save() worked - $this->assertTrue($cache->contains('test_key')); - - // Test fetch - $this->assertEquals('testing this out', $cache->fetch('test_key')); - - // Test delete - $cache->save('test_key2', 'test2'); - $cache->delete('test_key2'); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testObjects() - { - $cache = $this->_getCacheDriver(); - - // Fetch/save test with objects (Is cache driver serializes/unserializes objects correctly ?) - $cache->save('test_object_key', new \ArrayObject()); - $this->assertTrue($cache->fetch('test_object_key') instanceof \ArrayObject); - } - - public function testDeleteAll() - { - $cache = $this->_getCacheDriver(); - $cache->save('test_key1', '1'); - $cache->save('test_key2', '2'); - $cache->deleteAll(); - - $this->assertFalse($cache->contains('test_key1')); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testFlushAll() - { - $cache = $this->_getCacheDriver(); - $cache->save('test_key1', '1'); - $cache->save('test_key2', '2'); - $cache->flushAll(); - - $this->assertFalse($cache->contains('test_key1')); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testNamespace() - { - $cache = $this->_getCacheDriver(); - $cache->setNamespace('test_'); - $cache->save('key1', 'test'); - - $this->assertTrue($cache->contains('key1')); - - $cache->setNamespace('test2_'); - - $this->assertFalse($cache->contains('key1')); - } - - /** - * @group DCOM-43 - */ - public function testGetStats() - { - $cache = $this->_getCacheDriver(); - $stats = $cache->getStats(); - - $this->assertArrayHasKey(Cache::STATS_HITS, $stats); - $this->assertArrayHasKey(Cache::STATS_MISSES, $stats); - $this->assertArrayHasKey(Cache::STATS_UPTIME, $stats); - $this->assertArrayHasKey(Cache::STATS_MEMORY_USAGE, $stats); - $this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILIABLE, $stats); - } - - /** - * @return \Doctrine\Common\Cache\CacheProvider - */ - abstract protected function _getCacheDriver(); -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php deleted file mode 100644 index f782e3c..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php +++ /dev/null @@ -1,97 +0,0 @@ -assertFalse(is_dir($dir)); - - $this->driver = new FilesystemCache($dir); - $this->assertTrue(is_dir($dir)); - - return $this->driver; - } - - public function testLifetime() - { - $cache = $this->_getCacheDriver(); - - // Test save - $cache->save('test_key', 'testing this out', 10); - - // Test contains to test that save() worked - $this->assertTrue($cache->contains('test_key')); - - // Test fetch - $this->assertEquals('testing this out', $cache->fetch('test_key')); - - // access private methods - $getFilename = new \ReflectionMethod($cache, 'getFilename'); - $getNamespacedId = new \ReflectionMethod($cache, 'getNamespacedId'); - - $getFilename->setAccessible(true); - $getNamespacedId->setAccessible(true); - - $id = $getNamespacedId->invoke($cache, 'test_key'); - $filename = $getFilename->invoke($cache, $id); - - $data = ''; - $lifetime = 0; - $resource = fopen($filename, "r"); - - if (false !== ($line = fgets($resource))) { - $lifetime = (integer) $line; - } - - while (false !== ($line = fgets($resource))) { - $data .= $line; - } - - $this->assertNotEquals(0, $lifetime, "previous lifetime could not be loaded"); - - // update lifetime - $lifetime = $lifetime - 20; - file_put_contents($filename, $lifetime . PHP_EOL . $data); - - // test expired data - $this->assertFalse($cache->contains('test_key')); - $this->assertFalse($cache->fetch('test_key')); - } - - public function testGetStats() - { - $cache = $this->_getCacheDriver(); - $stats = $cache->getStats(); - - $this->assertNull($stats); - } - - public function tearDown() - { - $dir = $this->driver->getDirectory(); - $ext = $this->driver->getExtension(); - $iterator = new \RecursiveDirectoryIterator($dir); - - foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) { - if ($file->isFile()) { - @unlink($file->getRealPath()); - } else { - @rmdir($file->getRealPath()); - } - } - } - -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php deleted file mode 100644 index 36c180c..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php +++ /dev/null @@ -1,45 +0,0 @@ -_memcache = new \Memcache; - $ok = @$this->_memcache->connect('localhost', 11211); - if (!$ok) { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); - } - } else { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); - } - } - - public function testNoExpire() { - $cache = $this->_getCacheDriver(); - $cache->save('noexpire', 'value', 0); - sleep(1); - $this->assertTrue($cache->contains('noexpire'), 'Memcache provider should support no-expire'); - } - - public function testLongLifetime() - { - $cache = $this->_getCacheDriver(); - $cache->save('key', 'value', 30 * 24 * 3600 + 1); - $this->assertTrue($cache->contains('key'), 'Memcache provider should support TTL > 30 days'); - } - - protected function _getCacheDriver() - { - $driver = new MemcacheCache(); - $driver->setMemcache($this->_memcache); - return $driver; - } - -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php deleted file mode 100644 index ecbe5a6..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php +++ /dev/null @@ -1,48 +0,0 @@ -memcached = new \Memcached(); - $this->memcached->setOption(\Memcached::OPT_COMPRESSION, false); - $this->memcached->addServer('127.0.0.1', 11211); - - $fh = @fsockopen('127.0.0.1', 11211); - if (!$fh) { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); - } - } else { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); - } - } - - public function testNoExpire() { - $cache = $this->_getCacheDriver(); - $cache->save('noexpire', 'value', 0); - sleep(1); - $this->assertTrue($cache->contains('noexpire'), 'Memcache provider should support no-expire'); - } - - public function testLongLifetime() - { - $cache = $this->_getCacheDriver(); - $cache->save('key', 'value', 30 * 24 * 3600 + 1); - - $this->assertTrue($cache->contains('key'), 'Memcached provider should support TTL > 30 days'); - } - - protected function _getCacheDriver() - { - $driver = new MemcachedCache(); - $driver->setMemcached($this->memcached); - return $driver; - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php deleted file mode 100644 index 5085f46..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php +++ /dev/null @@ -1,149 +0,0 @@ -assertFalse(is_dir($dir)); - - $this->driver = new PhpFileCache($dir); - $this->assertTrue(is_dir($dir)); - - return $this->driver; - } - - public function testObjects() - { - $this->markTestSkipped('PhpFileCache does not support saving objects that dont implement __set_state()'); - } - - public function testLifetime() - { - $cache = $this->_getCacheDriver(); - - // Test save - $cache->save('test_key', 'testing this out', 10); - - // Test contains to test that save() worked - $this->assertTrue($cache->contains('test_key')); - - // Test fetch - $this->assertEquals('testing this out', $cache->fetch('test_key')); - - // access private methods - $getFilename = new \ReflectionMethod($cache, 'getFilename'); - $getNamespacedId = new \ReflectionMethod($cache, 'getNamespacedId'); - - $getFilename->setAccessible(true); - $getNamespacedId->setAccessible(true); - - $id = $getNamespacedId->invoke($cache, 'test_key'); - $path = $getFilename->invoke($cache, $id); - $value = include $path; - - // update lifetime - $value['lifetime'] = $value['lifetime'] - 20; - file_put_contents($path, 'assertFalse($cache->contains('test_key')); - $this->assertFalse($cache->fetch('test_key')); - } - - public function testImplementsSetState() - { - $cache = $this->_getCacheDriver(); - - // Test save - $cache->save('test_set_state', new SetStateClass(array(1,2,3))); - - //Test __set_state call - $this->assertCount(0, SetStateClass::$values); - - // Test fetch - $value = $cache->fetch('test_set_state'); - $this->assertInstanceOf('Doctrine\Tests\Common\Cache\SetStateClass', $value); - $this->assertEquals(array(1,2,3), $value->getValue()); - - //Test __set_state call - $this->assertCount(1, SetStateClass::$values); - - // Test contains - $this->assertTrue($cache->contains('test_set_state')); - } - - public function testNotImplementsSetState() - { - $cache = $this->_getCacheDriver(); - - $this->setExpectedException('InvalidArgumentException'); - $cache->save('test_not_set_state', new NotSetStateClass(array(1,2,3))); - } - - public function testGetStats() - { - $cache = $this->_getCacheDriver(); - $stats = $cache->getStats(); - - $this->assertNull($stats); - } - - public function tearDown() - { - if (!$this->driver) { - return; - } - - $dir = $this->driver->getDirectory(); - $ext = $this->driver->getExtension(); - $iterator = new \RecursiveDirectoryIterator($dir); - - foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) { - if ($file->isFile()) { - @unlink($file->getRealPath()); - } else { - @rmdir($file->getRealPath()); - } - } - } - -} - -class NotSetStateClass -{ - private $value; - - public function __construct($value) - { - $this->value = $value; - } - - public function getValue() - { - return $this->value; - } -} - -class SetStateClass extends NotSetStateClass -{ - public static $values = array(); - - public static function __set_state($data) - { - self::$values = $data; - return new self($data['value']); - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php deleted file mode 100644 index 45bbc75..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php +++ /dev/null @@ -1,30 +0,0 @@ -_redis = new \Redis(); - $ok = @$this->_redis->connect('127.0.0.1'); - if (!$ok) { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of redis'); - } - } else { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of redis'); - } - } - - protected function _getCacheDriver() - { - $driver = new RedisCache(); - $driver->setRedis($this->_redis); - return $driver; - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php deleted file mode 100644 index cb363df..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php +++ /dev/null @@ -1,20 +0,0 @@ -markTestSkipped('The ' . __CLASS__ .' requires the use of Wincache'); - } - } - - protected function _getCacheDriver() - { - return new WincacheCache(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php deleted file mode 100644 index 6259848..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php +++ /dev/null @@ -1,20 +0,0 @@ -markTestSkipped('The ' . __CLASS__ .' requires the use of xcache'); - } - } - - protected function _getCacheDriver() - { - return new XcacheCache(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php deleted file mode 100644 index cd66e15..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php +++ /dev/null @@ -1,28 +0,0 @@ -markTestSkipped('The ' . __CLASS__ .' requires the use of Zend Data Cache which only works in apache2handler SAPI'); - } - } - - public function testGetStats() - { - $cache = $this->_getCacheDriver(); - $stats = $cache->getStats(); - - $this->assertNull($stats); - } - - protected function _getCacheDriver() - { - return new ZendDataCache(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php deleted file mode 100644 index 567cf91..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php +++ /dev/null @@ -1,45 +0,0 @@ -setIncludePath(__DIR__); - $classLoader->setFileExtension('.class.php'); - $classLoader->setNamespaceSeparator('_'); - - $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassA')); - $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassB')); - $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassC')); - $this->assertFalse($classLoader->canLoadClass('OtherClass')); - $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassA'), true); - $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassB'), true); - $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassC'), true); - } - - public function testClassExists() - { - $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\ClassD')); - $badLoader = function($className) { - require __DIR__ . '/ClassLoaderTest/ClassD.php'; - return true; - }; - spl_autoload_register($badLoader); - $this->assertTrue(ClassLoader::classExists('ClassLoaderTest\ClassD')); - spl_autoload_unregister($badLoader); - } - - public function testGetClassLoader() - { - $cl = new ClassLoader('ClassLoaderTest', __DIR__); - $cl->register(); - $this->assertTrue(ClassLoader::getClassLoader('ClassLoaderTest\ClassD') instanceof \Doctrine\Common\ClassLoader); - $this->assertNull(ClassLoader::getClassLoader('This\Class\Does\Not\Exist')); - $cl->unregister(); - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php deleted file mode 100644 index 8554654..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php +++ /dev/null @@ -1,6 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Common\Collections; - -use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor; -use Doctrine\Common\Collections\ExpressionBuilder; - -/** - * @group DDC-1637 - */ -class ClosureExpressionVisitorTest extends \PHPUnit_Framework_TestCase -{ - private $visitor; - private $builder; - - public function setUp() - { - $this->visitor = new ClosureExpressionVisitor(); - $this->builder = new ExpressionBuilder(); - } - - public function testWalkEqualsComparison() - { - $closure = $this->visitor->walkComparison($this->builder->eq("foo", 1)); - - $this->assertTrue($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(2))); - } - - public function testWalkNotEqualsComparison() - { - $closure = $this->visitor->walkComparison($this->builder->neq("foo", 1)); - - $this->assertFalse($closure(new TestObject(1))); - $this->assertTrue($closure(new TestObject(2))); - } - - public function testWalkLessThanComparison() - { - $closure = $this->visitor->walkComparison($this->builder->lt("foo", 1)); - - $this->assertFalse($closure(new TestObject(1))); - $this->assertTrue($closure(new TestObject(0))); - } - - public function testWalkLessThanEqualsComparison() - { - $closure = $this->visitor->walkComparison($this->builder->lte("foo", 1)); - - $this->assertFalse($closure(new TestObject(2))); - $this->assertTrue($closure(new TestObject(1))); - $this->assertTrue($closure(new TestObject(0))); - } - - public function testWalkGreaterThanEqualsComparison() - { - $closure = $this->visitor->walkComparison($this->builder->gte("foo", 1)); - - $this->assertTrue($closure(new TestObject(2))); - $this->assertTrue($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(0))); - } - - public function testWalkGreaterThanComparison() - { - $closure = $this->visitor->walkComparison($this->builder->gt("foo", 1)); - - $this->assertTrue($closure(new TestObject(2))); - $this->assertFalse($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(0))); - } - - public function testWalkInComparison() - { - $closure = $this->visitor->walkComparison($this->builder->in("foo", array(1, 2, 3))); - - $this->assertTrue($closure(new TestObject(2))); - $this->assertTrue($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(0))); - } - - public function testWalkNotInComparison() - { - $closure = $this->visitor->walkComparison($this->builder->notIn("foo", array(1, 2, 3))); - - $this->assertFalse($closure(new TestObject(1))); - $this->assertFalse($closure(new TestObject(2))); - $this->assertTrue($closure(new TestObject(0))); - $this->assertTrue($closure(new TestObject(4))); - } - - public function testWalkAndCompositeExpression() - { - $closure = $this->visitor->walkCompositeExpression( - $this->builder->andX( - $this->builder->eq("foo", 1), - $this->builder->eq("bar", 1) - ) - ); - - $this->assertTrue($closure(new TestObject(1, 1))); - $this->assertFalse($closure(new TestObject(1, 0))); - $this->assertFalse($closure(new TestObject(0, 1))); - $this->assertFalse($closure(new TestObject(0, 0))); - } - - public function testWalkOrCompositeExpression() - { - $closure = $this->visitor->walkCompositeExpression( - $this->builder->orX( - $this->builder->eq("foo", 1), - $this->builder->eq("bar", 1) - ) - ); - - $this->assertTrue($closure(new TestObject(1, 1))); - $this->assertTrue($closure(new TestObject(1, 0))); - $this->assertTrue($closure(new TestObject(0, 1))); - $this->assertFalse($closure(new TestObject(0, 0))); - } - - public function testSortByFieldAscending() - { - $objects = array(new TestObject("b"), new TestObject("a"), new TestObject("c")); - $sort = ClosureExpressionVisitor::sortByField("foo"); - - usort($objects, $sort); - - $this->assertEquals("a", $objects[0]->getFoo()); - $this->assertEquals("b", $objects[1]->getFoo()); - $this->assertEquals("c", $objects[2]->getFoo()); - } - - public function testSortByFieldDescending() - { - $objects = array(new TestObject("b"), new TestObject("a"), new TestObject("c")); - $sort = ClosureExpressionVisitor::sortByField("foo", -1); - - usort($objects, $sort); - - $this->assertEquals("c", $objects[0]->getFoo()); - $this->assertEquals("b", $objects[1]->getFoo()); - $this->assertEquals("a", $objects[2]->getFoo()); - } - - public function testSortDelegate() - { - $objects = array(new TestObject("a", "c"), new TestObject("a", "b"), new TestObject("a", "a")); - $sort = ClosureExpressionVisitor::sortByField("bar", 1); - $sort = ClosureExpressionVisitor::sortByField("foo", 1, $sort); - - usort($objects, $sort); - - $this->assertEquals("a", $objects[0]->getBar()); - $this->assertEquals("b", $objects[1]->getBar()); - $this->assertEquals("c", $objects[2]->getBar()); - } -} - -class TestObject -{ - private $foo; - private $bar; - - public function __construct($foo = null, $bar = null) - { - $this->foo = $foo; - $this->bar = $bar; - } - - public function getFoo() - { - return $this->foo; - } - - public function getBar() - { - return $this->bar; - } -} - diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CollectionTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CollectionTest.php deleted file mode 100644 index 280efa3..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CollectionTest.php +++ /dev/null @@ -1,251 +0,0 @@ -_coll = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function testIssetAndUnset() - { - $this->assertFalse(isset($this->_coll[0])); - $this->_coll->add('testing'); - $this->assertTrue(isset($this->_coll[0])); - unset($this->_coll[0]); - $this->assertFalse(isset($this->_coll[0])); - } - - public function testToString() - { - $this->_coll->add('testing'); - $this->assertTrue(is_string((string) $this->_coll)); - } - - public function testRemovingNonExistentEntryReturnsNull() - { - $this->assertEquals(null, $this->_coll->remove('testing_does_not_exist')); - } - - public function testExists() - { - $this->_coll->add("one"); - $this->_coll->add("two"); - $exists = $this->_coll->exists(function($k, $e) { return $e == "one"; }); - $this->assertTrue($exists); - $exists = $this->_coll->exists(function($k, $e) { return $e == "other"; }); - $this->assertFalse($exists); - } - - public function testMap() - { - $this->_coll->add(1); - $this->_coll->add(2); - $res = $this->_coll->map(function($e) { return $e * 2; }); - $this->assertEquals(array(2, 4), $res->toArray()); - } - - public function testFilter() - { - $this->_coll->add(1); - $this->_coll->add("foo"); - $this->_coll->add(3); - $res = $this->_coll->filter(function($e) { return is_numeric($e); }); - $this->assertEquals(array(0 => 1, 2 => 3), $res->toArray()); - } - - public function testFirstAndLast() - { - $this->_coll->add('one'); - $this->_coll->add('two'); - - $this->assertEquals($this->_coll->first(), 'one'); - $this->assertEquals($this->_coll->last(), 'two'); - } - - public function testArrayAccess() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - - $this->assertEquals($this->_coll[0], 'one'); - $this->assertEquals($this->_coll[1], 'two'); - - unset($this->_coll[0]); - $this->assertEquals($this->_coll->count(), 1); - } - - public function testContainsKey() - { - $this->_coll[5] = 'five'; - $this->assertTrue($this->_coll->containsKey(5)); - } - - public function testContains() - { - $this->_coll[0] = 'test'; - $this->assertTrue($this->_coll->contains('test')); - } - - public function testSearch() - { - $this->_coll[0] = 'test'; - $this->assertEquals(0, $this->_coll->indexOf('test')); - } - - public function testGet() - { - $this->_coll[0] = 'test'; - $this->assertEquals('test', $this->_coll->get(0)); - } - - public function testGetKeys() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->assertEquals(array(0, 1), $this->_coll->getKeys()); - } - - public function testGetValues() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->assertEquals(array('one', 'two'), $this->_coll->getValues()); - } - - public function testCount() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->assertEquals($this->_coll->count(), 2); - $this->assertEquals(count($this->_coll), 2); - } - - public function testForAll() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->assertEquals($this->_coll->forAll(function($k, $e) { return is_string($e); }), true); - $this->assertEquals($this->_coll->forAll(function($k, $e) { return is_array($e); }), false); - } - - public function testPartition() - { - $this->_coll[] = true; - $this->_coll[] = false; - $partition = $this->_coll->partition(function($k, $e) { return $e == true; }); - $this->assertEquals($partition[0][0], true); - $this->assertEquals($partition[1][0], false); - } - - public function testClear() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->_coll->clear(); - $this->assertEquals($this->_coll->isEmpty(), true); - } - - public function testRemove() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $el = $this->_coll->remove(0); - - $this->assertEquals('one', $el); - $this->assertEquals($this->_coll->contains('one'), false); - $this->assertNull($this->_coll->remove(0)); - } - - public function testRemoveElement() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - - $this->assertTrue($this->_coll->removeElement('two')); - $this->assertFalse($this->_coll->contains('two')); - $this->assertFalse($this->_coll->removeElement('two')); - } - - public function testSlice() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->_coll[] = 'three'; - - $slice = $this->_coll->slice(0, 1); - $this->assertInternalType('array', $slice); - $this->assertEquals(array('one'), $slice); - - $slice = $this->_coll->slice(1); - $this->assertEquals(array(1 => 'two', 2 => 'three'), $slice); - - $slice = $this->_coll->slice(1, 1); - $this->assertEquals(array(1 => 'two'), $slice); - } - - public function fillMatchingFixture() - { - $std1 = new \stdClass(); - $std1->foo = "bar"; - $this->_coll[] = $std1; - - $std2 = new \stdClass(); - $std2->foo = "baz"; - $this->_coll[] = $std2; - } - - /** - * @group DDC-1637 - */ - public function testMatching() - { - $this->fillMatchingFixture(); - - $col = $this->_coll->matching(new Criteria(Criteria::expr()->eq("foo", "bar"))); - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $col); - $this->assertNotSame($col, $this->_coll); - $this->assertEquals(1, count($col)); - } - - /** - * @group DDC-1637 - */ - public function testMatchingOrdering() - { - $this->fillMatchingFixture(); - - $col = $this->_coll->matching(new Criteria(null, array('foo' => 'DESC'))); - - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $col); - $this->assertNotSame($col, $this->_coll); - $this->assertEquals(2, count($col)); - $this->assertEquals('baz', $col[0]->foo); - $this->assertEquals('bar', $col[1]->foo); - } - - /** - * @group DDC-1637 - */ - public function testMatchingSlice() - { - $this->fillMatchingFixture(); - - $col = $this->_coll->matching(new Criteria(null, null, 1, 1)); - - $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $col); - $this->assertNotSame($col, $this->_coll); - $this->assertEquals(1, count($col)); - $this->assertEquals('baz', $col[0]->foo); - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php deleted file mode 100644 index 03fb6ca..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/CriteriaTest.php +++ /dev/null @@ -1,82 +0,0 @@ -assertInstanceOf("Doctrine\Common\Collections\Criteria", $criteria); - } - - public function testConstructor() - { - $expr = new Comparison("field", "=", "value"); - $criteria = new Criteria($expr, array("foo" => "ASC"), 10, 20); - - $this->assertSame($expr, $criteria->getWhereExpression()); - $this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings()); - $this->assertEquals(10, $criteria->getFirstResult()); - $this->assertEquals(20, $criteria->getMaxResults()); - } - - public function testWhere() - { - $expr = new Comparison("field", "=", "value"); - $criteria = new Criteria(); - - $criteria->where($expr); - - $this->assertSame($expr, $criteria->getWhereExpression()); - } - - public function testAndWhere() - { - $expr = new Comparison("field", "=", "value"); - $criteria = new Criteria(); - - $criteria->where($expr); - $expr = $criteria->getWhereExpression(); - $criteria->andWhere($expr); - - $where = $criteria->getWhereExpression(); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\CompositeExpression', $where); - - $this->assertEquals(CompositeExpression::TYPE_AND, $where->getType()); - $this->assertSame(array($expr, $expr), $where->getExpressionList()); - } - - public function testOrWhere() - { - $expr = new Comparison("field", "=", "value"); - $criteria = new Criteria(); - - $criteria->where($expr); - $expr = $criteria->getWhereExpression(); - $criteria->orWhere($expr); - - $where = $criteria->getWhereExpression(); - $this->assertInstanceOf('Doctrine\Common\Collections\Expr\CompositeExpression', $where); - - $this->assertEquals(CompositeExpression::TYPE_OR, $where->getType()); - $this->assertSame(array($expr, $expr), $where->getExpressionList()); - } - - public function testOrderings() - { - $criteria = Criteria::create() - ->orderBy(array("foo" => "ASC")); - - $this->assertEquals(array("foo" => "ASC"), $criteria->getOrderings()); - } - - public function testExpr() - { - $this->assertInstanceOf('Doctrine\Common\Collections\ExpressionBuilder', Criteria::expr()); - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php deleted file mode 100644 index 68896b3..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Collections/ExpressionBuilderTest.php +++ /dev/null @@ -1,114 +0,0 @@ -builder = new ExpressionBuilder(); - } - - public function testAndX() - { - $expr = $this->builder->andX($this->builder->eq("a", "b")); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\CompositeExpression", $expr); - $this->assertEquals(CompositeExpression::TYPE_AND, $expr->getType()); - } - - public function testOrX() - { - $expr = $this->builder->orX($this->builder->eq("a", "b")); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\CompositeExpression", $expr); - $this->assertEquals(CompositeExpression::TYPE_OR, $expr->getType()); - } - - public function testInvalidAndXArgument() - { - $this->setExpectedException("RuntimeException"); - $this->builder->andX("foo"); - } - - public function testEq() - { - $expr = $this->builder->eq("a", "b"); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::EQ, $expr->getOperator()); - } - - public function testNeq() - { - $expr = $this->builder->neq("a", "b"); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::NEQ, $expr->getOperator()); - } - - public function testLt() - { - $expr = $this->builder->lt("a", "b"); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::LT, $expr->getOperator()); - } - - public function testGt() - { - $expr = $this->builder->gt("a", "b"); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::GT, $expr->getOperator()); - } - - public function testGte() - { - $expr = $this->builder->gte("a", "b"); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::GTE, $expr->getOperator()); - } - - public function testLte() - { - $expr = $this->builder->lte("a", "b"); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::LTE, $expr->getOperator()); - } - - public function testIn() - { - $expr = $this->builder->in("a", array("b")); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::IN, $expr->getOperator()); - } - - public function testNotIn() - { - $expr = $this->builder->notIn("a", array("b")); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::NIN, $expr->getOperator()); - } - - public function testIsNull() - { - $expr = $this->builder->isNull("a"); - - $this->assertInstanceOf("Doctrine\Common\Collections\Expr\Comparison", $expr); - $this->assertEquals(Comparison::IS, $expr->getOperator()); - } -} - diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/EventManagerTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/EventManagerTest.php deleted file mode 100644 index 2b11b20..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/EventManagerTest.php +++ /dev/null @@ -1,88 +0,0 @@ -_eventManager = new EventManager; - $this->_preFooInvoked = false; - $this->_postFooInvoked = false; - } - - public function testInitialState() - { - $this->assertEquals(array(), $this->_eventManager->getListeners()); - $this->assertFalse($this->_eventManager->hasListeners(self::preFoo)); - $this->assertFalse($this->_eventManager->hasListeners(self::postFoo)); - } - - public function testAddEventListener() - { - $this->_eventManager->addEventListener(array('preFoo', 'postFoo'), $this); - $this->assertTrue($this->_eventManager->hasListeners(self::preFoo)); - $this->assertTrue($this->_eventManager->hasListeners(self::postFoo)); - $this->assertEquals(1, count($this->_eventManager->getListeners(self::preFoo))); - $this->assertEquals(1, count($this->_eventManager->getListeners(self::postFoo))); - $this->assertEquals(2, count($this->_eventManager->getListeners())); - } - - public function testDispatchEvent() - { - $this->_eventManager->addEventListener(array('preFoo', 'postFoo'), $this); - $this->_eventManager->dispatchEvent(self::preFoo); - $this->assertTrue($this->_preFooInvoked); - $this->assertFalse($this->_postFooInvoked); - } - - public function testRemoveEventListener() - { - $this->_eventManager->addEventListener(array('preBar'), $this); - $this->assertTrue($this->_eventManager->hasListeners(self::preBar)); - $this->_eventManager->removeEventListener(array('preBar'), $this); - $this->assertFalse($this->_eventManager->hasListeners(self::preBar)); - } - - public function testAddEventSubscriber() - { - $eventSubscriber = new TestEventSubscriber(); - $this->_eventManager->addEventSubscriber($eventSubscriber); - $this->assertTrue($this->_eventManager->hasListeners(self::preFoo)); - $this->assertTrue($this->_eventManager->hasListeners(self::postFoo)); - } - - /* Listener methods */ - - public function preFoo(EventArgs $e) - { - $this->_preFooInvoked = true; - } - - public function postFoo(EventArgs $e) - { - $this->_postFooInvoked = true; - } -} - -class TestEventSubscriber implements \Doctrine\Common\EventSubscriber -{ - public function getSubscribedEvents() - { - return array('preFoo', 'postFoo'); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ChainDriverTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ChainDriverTest.php deleted file mode 100644 index 66ad762..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ChainDriverTest.php +++ /dev/null @@ -1,130 +0,0 @@ -getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); - - $chain = new MappingDriverChain(); - - $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $driver1->expects($this->never()) - ->method('loadMetadataForClass'); - $driver1->expectS($this->never()) - ->method('isTransient'); - - $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $driver2->expects($this->at(0)) - ->method('loadMetadataForClass') - ->with($this->equalTo($className), $this->equalTo($classMetadata)); - $driver2->expects($this->at(1)) - ->method('isTransient') - ->with($this->equalTo($className)) - ->will($this->returnValue( true )); - - $chain->addDriver($driver1, 'Doctrine\Tests\Models\Company'); - $chain->addDriver($driver2, 'Doctrine\Tests\Common\Persistence\Mapping'); - - $chain->loadMetadataForClass($className, $classMetadata); - - $this->assertTrue( $chain->isTransient($className) ); - } - - public function testLoadMetadata_NoDelegatorFound_ThrowsMappingException() - { - $className = 'Doctrine\Tests\Common\Persistence\Mapping\DriverChainEntity'; - $classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); - - $chain = new MappingDriverChain(); - - $this->setExpectedException('Doctrine\Common\Persistence\Mapping\MappingException'); - $chain->loadMetadataForClass($className, $classMetadata); - } - - public function testGatherAllClassNames() - { - $className = 'Doctrine\Tests\Common\Persistence\Mapping\DriverChainEntity'; - $classMetadata = $this->getMock('Doctrine\Common\Peristence\ClassMetadata'); - - $chain = new MappingDriverChain(); - - $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $driver1->expects($this->once()) - ->method('getAllClassNames') - ->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo'))); - - $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $driver2->expects($this->once()) - ->method('getAllClassNames') - ->will($this->returnValue(array('Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz'))); - - $chain->addDriver($driver1, 'Doctrine\Tests\Models\Company'); - $chain->addDriver($driver2, 'Doctrine\Tests\ORM\Mapping'); - - $this->assertEquals(array( - 'Doctrine\Tests\Models\Company\Foo', - 'Doctrine\Tests\ORM\Mapping\Bar', - 'Doctrine\Tests\ORM\Mapping\Baz' - ), $chain->getAllClassNames()); - } - - /** - * @group DDC-706 - */ - public function testIsTransient() - { - $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $chain = new MappingDriverChain(); - $chain->addDriver($driver1, 'Doctrine\Tests\Models\CMS'); - - $this->assertTrue($chain->isTransient('stdClass'), "stdClass isTransient"); - } - - /** - * @group DDC-1412 - */ - public function testDefaultDriver() - { - $companyDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $dafaultDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $entityClassName = 'Doctrine\Tests\ORM\Mapping\DriverChainEntity'; - $managerClassName = 'Doctrine\Tests\Models\Company\CompanyManager'; - $chain = new MappingDriverChain(); - - $companyDriver->expects($this->never()) - ->method('loadMetadataForClass'); - $companyDriver->expects($this->once()) - ->method('isTransient') - ->with($this->equalTo($managerClassName)) - ->will($this->returnValue(false)); - - $dafaultDriver->expects($this->never()) - ->method('loadMetadataForClass'); - $dafaultDriver->expects($this->once()) - ->method('isTransient') - ->with($this->equalTo($entityClassName)) - ->will($this->returnValue(true)); - - $this->assertNull($chain->getDefaultDriver()); - - $chain->setDefaultDriver($dafaultDriver); - $chain->addDriver($companyDriver, 'Doctrine\Tests\Models\Company'); - - $this->assertSame($dafaultDriver, $chain->getDefaultDriver()); - - $this->assertTrue($chain->isTransient($entityClassName)); - $this->assertFalse($chain->isTransient($managerClassName)); - } -} - -class DriverChainEntity -{ - -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php deleted file mode 100644 index bc1559a..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php +++ /dev/null @@ -1,139 +0,0 @@ -getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); - $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); - $this->cmf = new TestClassMetadataFactory($driver, $metadata); - } - - public function testGetCacheDriver() - { - $this->assertNull($this->cmf->getCacheDriver()); - $cache = new ArrayCache(); - $this->cmf->setCacheDriver($cache); - $this->assertSame($cache, $this->cmf->getCacheDriver()); - } - - public function testGetMetadataFor() - { - $metadata = $this->cmf->getMetadataFor('stdClass'); - - $this->assertInstanceOf('Doctrine\Common\Persistence\Mapping\ClassMetadata', $metadata); - $this->assertTrue($this->cmf->hasMetadataFor('stdClass')); - } - - public function testGetParentMetadata() - { - $metadata = $this->cmf->getMetadataFor(__NAMESPACE__ . '\ChildEntity'); - - $this->assertInstanceOf('Doctrine\Common\Persistence\Mapping\ClassMetadata', $metadata); - $this->assertTrue($this->cmf->hasMetadataFor(__NAMESPACE__ . '\ChildEntity')); - $this->assertTrue($this->cmf->hasMetadataFor(__NAMESPACE__ . '\RootEntity')); - } - - public function testGetCachedMetadata() - { - $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); - $cache = new ArrayCache(); - $cache->save(__NAMESPACE__. '\ChildEntity$CLASSMETADATA', $metadata); - - $this->cmf->setCacheDriver($cache); - - $loadedMetadata = $this->cmf->getMetadataFor(__NAMESPACE__ . '\ChildEntity'); - $this->assertSame($loadedMetadata, $metadata); - } - - public function testCacheGetMetadataFor() - { - $cache = new ArrayCache(); - $this->cmf->setCacheDriver($cache); - - $loadedMetadata = $this->cmf->getMetadataFor(__NAMESPACE__ . '\ChildEntity'); - - $this->assertSame($loadedMetadata, $cache->fetch(__NAMESPACE__. '\ChildEntity$CLASSMETADATA')); - } - - public function testGetAliasedMetadata() - { - $loadedMetadata = $this->cmf->getMetadataFor('prefix:ChildEntity'); - - $this->assertTrue($this->cmf->hasMetadataFor(__NAMESPACE__ . '\ChildEntity')); - $this->assertTrue($this->cmf->hasMetadataFor('prefix:ChildEntity')); - } -} - -class TestClassMetadataFactory extends AbstractClassMetadataFactory -{ - public $driver; - public $metadata; - - public function __construct($driver, $metadata) - { - $this->driver = $driver; - $this->metadata = $metadata; - } - - protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents) - { - - } - - protected function getFqcnFromAlias($namespaceAlias, $simpleClassName) - { - return __NAMESPACE__ . '\\' . $simpleClassName; - } - - protected function initialize() - { - - } - - protected function newClassMetadataInstance($className) - { - return $this->metadata; - } - - protected function getDriver() - { - return $this->driver; - } - protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService) - { - } - - protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService) - { - } - - protected function isEntity(ClassMetadata $class) - { - return true; - } -} - -class RootEntity -{ - -} - -class ChildEntity extends RootEntity -{ - -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php deleted file mode 100644 index 37072de..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php +++ /dev/null @@ -1,90 +0,0 @@ -assertEquals(array($path), $locator->getPaths()); - - $locator = new DefaultFileLocator($path); - $this->assertEquals(array($path), $locator->getPaths()); - } - - public function testGetFileExtension() - { - $locator = new DefaultFileLocator(array(), ".yml"); - $this->assertEquals(".yml", $locator->getFileExtension()); - $locator->setFileExtension(".xml"); - $this->assertEquals(".xml", $locator->getFileExtension()); - } - - public function testUniquePaths() - { - $path = __DIR__ . "/_files"; - - $locator = new DefaultFileLocator(array($path, $path)); - $this->assertEquals(array($path), $locator->getPaths()); - } - - public function testFindMappingFile() - { - $path = __DIR__ . "/_files"; - - $locator = new DefaultFileLocator(array($path), ".yml"); - - $this->assertEquals(__DIR__ . '/_files' . DIRECTORY_SEPARATOR . 'stdClass.yml', $locator->findMappingFile('stdClass')); - } - - public function testFindMappingFileNotFound() - { - $path = __DIR__ . "/_files"; - - $locator = new DefaultFileLocator(array($path), ".yml"); - - $this->setExpectedException( - 'Doctrine\Common\Persistence\Mapping\MappingException', - "No mapping file found named 'stdClass2.yml' for class 'stdClass2'" - ); - $locator->findMappingFile('stdClass2'); - } - - public function testGetAllClassNames() - { - $path = __DIR__ . "/_files"; - - $locator = new DefaultFileLocator(array($path), ".yml"); - $classes = $locator->getAllClassNames(null); - sort($classes); - - $this->assertEquals(array('global', 'stdClass'), $classes); - $this->assertEquals(array('stdClass'), $locator->getAllClassNames("global")); - } - - public function testGetAllClassNamesNonMatchingFileExtension() - { - $path = __DIR__ . "/_files"; - - $locator = new DefaultFileLocator(array($path), ".xml"); - $this->assertEquals(array(), $locator->getAllClassNames("global")); - } - - public function testFileExists() - { - $path = __DIR__ . "/_files"; - - $locator = new DefaultFileLocator(array($path), ".yml"); - - $this->assertTrue($locator->fileExists("stdClass")); - $this->assertFalse($locator->fileExists("stdClass2")); - $this->assertTrue($locator->fileExists("global")); - $this->assertFalse($locator->fileExists("global2")); - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php deleted file mode 100644 index 020c242..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php +++ /dev/null @@ -1,142 +0,0 @@ -assertNull($driver->getGlobalBasename()); - - $driver->setGlobalBasename("global"); - $this->assertEquals("global", $driver->getGlobalBasename()); - } - - public function testGetElementFromGlobalFile() - { - $driver = new TestFileDriver($this->newLocator()); - $driver->setGlobalBasename("global"); - - $element = $driver->getElement('stdGlobal'); - - $this->assertEquals('stdGlobal', $element); - } - - public function testGetElementFromFile() - { - $locator = $this->newLocator(); - $locator->expects($this->once()) - ->method('findMappingFile') - ->with($this->equalTo('stdClass')) - ->will($this->returnValue(__DIR__ . '/_files/stdClass.yml')); - - $driver = new TestFileDriver($locator); - - $this->assertEquals('stdClass', $driver->getElement('stdClass')); - } - - public function testGetAllClassNamesGlobalBasename() - { - $driver = new TestFileDriver($this->newLocator()); - $driver->setGlobalBasename("global"); - - $classNames = $driver->getAllClassNames(); - - $this->assertEquals(array('stdGlobal', 'stdGlobal2'), $classNames); - } - - public function testGetAllClassNamesFromMappingFile() - { - $locator = $this->newLocator(); - $locator->expects($this->any()) - ->method('getAllClassNames') - ->with($this->equalTo(null)) - ->will($this->returnValue(array('stdClass'))); - $driver = new TestFileDriver($locator); - - $classNames = $driver->getAllClassNames(); - - $this->assertEquals(array('stdClass'), $classNames); - } - - public function testGetAllClassNamesBothSources() - { - $locator = $this->newLocator(); - $locator->expects($this->any()) - ->method('getAllClassNames') - ->with($this->equalTo('global')) - ->will($this->returnValue(array('stdClass'))); - $driver = new TestFileDriver($locator); - $driver->setGlobalBasename("global"); - - $classNames = $driver->getAllClassNames(); - - $this->assertEquals(array('stdGlobal', 'stdGlobal2', 'stdClass'), $classNames); - } - - public function testIsNotTransient() - { - $locator = $this->newLocator(); - $locator->expects($this->once()) - ->method('fileExists') - ->with($this->equalTo('stdClass')) - ->will($this->returnValue( true )); - - $driver = new TestFileDriver($locator); - $driver->setGlobalBasename("global"); - - $this->assertFalse($driver->isTransient('stdClass')); - $this->assertFalse($driver->isTransient('stdGlobal')); - $this->assertFalse($driver->isTransient('stdGlobal2')); - } - - public function testIsTransient() - { - $locator = $this->newLocator(); - $locator->expects($this->once()) - ->method('fileExists') - ->with($this->equalTo('stdClass2')) - ->will($this->returnValue( false )); - - $driver = new TestFileDriver($locator); - - $this->assertTrue($driver->isTransient('stdClass2')); - } - - public function testNonLocatorFallback() - { - $driver = new TestFileDriver(__DIR__ . '/_files', '.yml'); - $this->assertTrue($driver->isTransient('stdClass2')); - $this->assertFalse($driver->isTransient('stdClass')); - } - - private function newLocator() - { - $locator = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\FileLocator'); - $locator->expects($this->any())->method('getFileExtension')->will($this->returnValue('.yml')); - $locator->expects($this->any())->method('getPaths')->will($this->returnValue(array(__DIR__ . "/_files"))); - return $locator; - } -} - -class TestFileDriver extends FileDriver -{ - protected function loadMappingFile($file) - { - if (strpos($file, "global.yml") !== false) { - return array('stdGlobal' => 'stdGlobal', 'stdGlobal2' => 'stdGlobal2'); - } - return array('stdClass' => 'stdClass'); - } - - public function loadMetadataForClass($className, ClassMetadata $metadata) - { - - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php deleted file mode 100644 index 8fc4d80..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php +++ /dev/null @@ -1,18 +0,0 @@ -getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); - $metadata->expects($this->once())->method('getFieldNames'); - - $driver = new PHPDriver(array(__DIR__ . "/_files")); - $driver->loadMetadataForClass('TestEntity', $metadata); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php deleted file mode 100644 index 5f06cad..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php +++ /dev/null @@ -1,70 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Common\Persistence\Mapping; - -use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; - -/** - * @group DCOM-93 - */ -class RuntimeReflectionServiceTest extends \PHPUnit_Framework_TestCase -{ - private $reflectionService; - - public function setUp() - { - $this->reflectionService = new RuntimeReflectionService(); - } - - public function testShortname() - { - $this->assertEquals("RuntimeReflectionServiceTest", $this->reflectionService->getClassShortName(__CLASS__)); - } - - public function testClassNamespaceName() - { - $this->assertEquals("Doctrine\Tests\Common\Persistence\Mapping", $this->reflectionService->getClassNamespace(__CLASS__)); - } - - public function testGetParentClasses() - { - $classes = $this->reflectionService->getParentClasses(__CLASS__); - $this->assertTrue(count($classes) >= 1, "The test class ".__CLASS__." should have at least one parent."); - } - - public function testGetReflectionClass() - { - $class = $this->reflectionService->getClass(__CLASS__); - $this->assertInstanceOf("ReflectionClass", $class); - } - - public function testGetMethods() - { - $this->assertTrue($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods")); - $this->assertFalse($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods2")); - } - - public function testGetAccessibleProperty() - { - $reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "reflectionService"); - $this->assertInstanceOf("ReflectionProperty", $reflProp); - } -} - diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php deleted file mode 100644 index 9f1c568..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php +++ /dev/null @@ -1,35 +0,0 @@ -getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); - $metadata->expects($this->once())->method('getFieldNames'); - - $driver = new StaticPHPDriver(array(__DIR__)); - $driver->loadMetadataForClass(__NAMESPACE__ . '\\TestEntity', $metadata); - } - - public function testGetAllClassNames() - { - $driver = new StaticPHPDriver(array(__DIR__)); - $classNames = $driver->getAllClassNames(); - - $this->assertContains( - 'Doctrine\Tests\Common\Persistence\Mapping\TestEntity', $classNames); - } -} - -class TestEntity -{ - static public function loadMetadata($metadata) - { - $metadata->getFieldNames(); - } -} \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php deleted file mode 100644 index ffce6d4..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php +++ /dev/null @@ -1,70 +0,0 @@ -. - */ - -namespace Doctrine\Tests\Common\Persistence\Mapping; - -use Doctrine\Common\Persistence\Mapping\StaticReflectionService; - -/** - * @group DCOM-93 - */ -class StaticReflectionServiceTest extends \PHPUnit_Framework_TestCase -{ - private $reflectionService; - - public function setUp() - { - $this->reflectionService = new StaticReflectionService(); - } - - public function testShortname() - { - $this->assertEquals("StaticReflectionServiceTest", $this->reflectionService->getClassShortName(__CLASS__)); - } - - public function testClassNamespaceName() - { - $this->assertEquals("Doctrine\Tests\Common\Persistence\Mapping", $this->reflectionService->getClassNamespace(__CLASS__)); - } - - public function testGetParentClasses() - { - $classes = $this->reflectionService->getParentClasses(__CLASS__); - $this->assertTrue(count($classes) == 0, "The test class ".__CLASS__." should have no parents according to static reflection."); - } - - public function testGetReflectionClass() - { - $class = $this->reflectionService->getClass(__CLASS__); - $this->assertNull($class); - } - - public function testGetMethods() - { - $this->assertTrue($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods")); - $this->assertFalse($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods2")); - } - - public function testGetAccessibleProperty() - { - $reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "reflectionService"); - $this->assertNull($reflProp); - } -} - diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php deleted file mode 100644 index b51162e..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php +++ /dev/null @@ -1,88 +0,0 @@ - $prefix)); - $this->assertEquals(array($path), $locator->getPaths()); - - $locator = new SymfonyFileLocator(array($path => $prefix)); - $this->assertEquals(array($path), $locator->getPaths()); - } - - public function testGetPrefixes() - { - $path = __DIR__ . "/_files"; - $prefix = "Foo"; - - $locator = new SymfonyFileLocator(array($path => $prefix)); - $this->assertEquals(array($path => $prefix), $locator->getNamespacePrefixes()); - } - - public function testGetFileExtension() - { - $locator = new SymfonyFileLocator(array(), ".yml"); - $this->assertEquals(".yml", $locator->getFileExtension()); - $locator->setFileExtension(".xml"); - $this->assertEquals(".xml", $locator->getFileExtension()); - } - - public function testFileExists() - { - $path = __DIR__ . "/_files"; - $prefix = "Foo"; - - $locator = new SymfonyFileLocator(array($path => $prefix), ".yml"); - - $this->assertTrue($locator->fileExists("Foo\stdClass")); - $this->assertTrue($locator->fileExists("Foo\global")); - $this->assertFalse($locator->fileExists("Foo\stdClass2")); - $this->assertFalse($locator->fileExists("Foo\global2")); - } - - public function testGetAllClassNames() - { - $path = __DIR__ . "/_files"; - $prefix = "Foo"; - - $locator = new SymfonyFileLocator(array($path => $prefix), ".yml"); - $classes = $locator->getAllClassNames(null); - sort($classes); - - $this->assertEquals(array("Foo\\global", "Foo\\stdClass"), $classes); - $this->assertEquals(array("Foo\\stdClass"), $locator->getAllClassNames("global")); - } - - public function testFindMappingFile() - { - $path = __DIR__ . "/_files"; - $prefix = "Foo"; - - $locator = new SymfonyFileLocator(array($path => $prefix), ".yml"); - - $this->assertEquals(__DIR__ . "/_files/stdClass.yml", $locator->findMappingFile("Foo\\stdClass")); - } - - public function testFindMappingFileNotFound() - { - $path = __DIR__ . "/_files"; - $prefix = "Foo"; - - $locator = new SymfonyFileLocator(array($path => $prefix), ".yml"); - - $this->setExpectedException( - "Doctrine\Common\Persistence\Mapping\MappingException", - "No mapping file found named '".__DIR__."/_files/stdClass2.yml' for class 'Foo\stdClass2'." - ); - $locator->findMappingFile("Foo\\stdClass2"); - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php deleted file mode 100644 index d0e9976..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php +++ /dev/null @@ -1,3 +0,0 @@ -getFieldNames(); \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml deleted file mode 100644 index 30d74d2..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml deleted file mode 100644 index 30d74d2..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php deleted file mode 100644 index a0f77b5..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php +++ /dev/null @@ -1,247 +0,0 @@ -cm = new TestObjectMetadata; - $this->om = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); - $this->om->expects($this->any())->method('getClassMetadata') - ->will($this->returnValue($this->cm)); - $this->object = new TestObject; - PersistentObject::setObjectManager($this->om); - $this->object->injectObjectManager($this->om, $this->cm); - } - - public function testGetObjectManager() - { - $this->assertSame($this->om, PersistentObject::getObjectManager()); - } - - public function testNonMatchingObjectManager() - { - $this->setExpectedException('RuntimeException'); - $om = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); - $this->object->injectObjectManager($om, $this->cm); - } - - public function testGetField() - { - $this->assertEquals('beberlei', $this->object->getName()); - } - - public function testSetField() - { - $this->object->setName("test"); - $this->assertEquals("test", $this->object->getName()); - } - - public function testGetIdentifier() - { - $this->assertEquals(1, $this->object->getId()); - } - - public function testSetIdentifier() - { - $this->setExpectedException('BadMethodCallException'); - $this->object->setId(2); - } - - public function testSetUnknownField() - { - $this->setExpectedException('BadMethodCallException'); - $this->object->setUnknown("test"); - } - - public function testGetUnknownField() - { - $this->setExpectedException('BadMethodCallException'); - $this->object->getUnknown(); - } - - public function testGetToOneAssociation() - { - $this->assertNull($this->object->getParent()); - } - - public function testSetToOneAssociation() - { - $parent = new TestObject(); - $this->object->setParent($parent); - $this->assertSame($parent, $this->object->getParent($parent)); - } - - public function testSetInvalidToOneAssocation() - { - $parent = new \stdClass(); - - $this->setExpectedException('InvalidArgumentException'); - $this->object->setParent($parent); - } - - public function testSetToOneAssociationNull() - { - $parent = new TestObject(); - $this->object->setParent($parent); - $this->object->setParent(null); - $this->assertNull($this->object->getParent()); - } - - public function testAddToManyAssocation() - { - $child = new TestObject(); - $this->object->addChildren($child); - - $this->assertSame($this->object, $child->getParent()); - $this->assertEquals(1, count($this->object->getChildren())); - - $child = new TestObject(); - $this->object->addChildren($child); - - $this->assertEquals(2, count($this->object->getChildren())); - } - - public function testAddInvalidToManyAssocation() - { - $this->setExpectedException('InvalidArgumentException'); - $this->object->addChildren(new \stdClass()); - } - - public function testNoObjectManagerSet() - { - PersistentObject::setObjectManager(null); - $child = new TestObject(); - - $this->setExpectedException('RuntimeException'); - $child->setName("test"); - } - - public function testInvalidMethod() - { - $this->setExpectedException('BadMethodCallException'); - $this->object->asdf(); - } - - public function testAddInvalidCollection() - { - $this->setExpectedException('BadMethodCallException'); - $this->object->addAsdf(new \stdClass()); - } -} - -class TestObject extends PersistentObject -{ - protected $id = 1; - protected $name = 'beberlei'; - protected $parent; - protected $children; -} - -class TestObjectMetadata implements ClassMetadata -{ - - public function getAssociationMappedByTargetField($assocName) - { - $assoc = array('children' => 'parent'); - return $assoc[$assocName]; - } - - public function getAssociationNames() - { - return array('parent', 'children'); - } - - public function getAssociationTargetClass($assocName) - { - return __NAMESPACE__ . '\TestObject'; - } - - public function getFieldNames() - { - return array('id', 'name'); - } - - public function getIdentifier() - { - return array('id'); - } - - public function getName() - { - return __NAMESPACE__ . '\TestObject'; - } - - public function getReflectionClass() - { - return new \ReflectionClass($this->getName()); - } - - public function getTypeOfField($fieldName) - { - $types = array('id' => 'integer', 'name' => 'string'); - return $types[$fieldName]; - } - - public function hasAssociation($fieldName) - { - return in_array($fieldName, array('parent', 'children')); - } - - public function hasField($fieldName) - { - return in_array($fieldName, array('id', 'name')); - } - - public function isAssociationInverseSide($assocName) - { - return ($assocName === 'children'); - } - - public function isCollectionValuedAssociation($fieldName) - { - return ($fieldName === 'children'); - } - - public function isIdentifier($fieldName) - { - return $fieldName === 'id'; - } - - public function isSingleValuedAssociation($fieldName) - { - return $fieldName === 'parent'; - } - - public function getIdentifierValues($entity) - { - - } - - public function getIdentifierFieldNames() - { - - } - - public function initializeReflection(ReflectionService $reflService) - { - - } - - public function wakeupReflection(ReflectionService $reflService) - { - - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/DeeperNamespaceParent.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/DeeperNamespaceParent.php deleted file mode 100644 index 72faa77..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/DeeperNamespaceParent.php +++ /dev/null @@ -1,7 +0,0 @@ - array($testsRoot), - ); - $noParentClassName = 'Doctrine\\Tests\\Common\\Reflection\\NoParent'; - $staticReflectionParser = new StaticReflectionParser($noParentClassName, new Psr0FindFile($paths)); - $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); - $this->assertEquals($noParentClassName, $declaringClassName); - - $className = 'Doctrine\\Tests\\Common\\Reflection\\FullyClassifiedParent'; - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); - $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); - $this->assertEquals($noParentClassName, $declaringClassName); - - $className = 'Doctrine\\Tests\\Common\\Reflection\\SameNamespaceParent'; - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); - $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); - $this->assertEquals($noParentClassName, $declaringClassName); - - $dummyParentClassName = 'Doctrine\\Tests\\Common\\Reflection\\Dummies\\NoParent'; - - $className = 'Doctrine\\Tests\\Common\\Reflection\\DeeperNamespaceParent'; - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); - $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); - $this->assertEquals($dummyParentClassName, $declaringClassName); - - $className = 'Doctrine\\Tests\\Common\\Reflection\\UseParent'; - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($paths)); - $declaringClassName = $staticReflectionParser->getStaticReflectionParserForDeclaringClass('property', 'test')->getClassName(); - $this->assertEquals($dummyParentClassName, $declaringClassName); - - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/UseParent.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/UseParent.php deleted file mode 100644 index dd512d4..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Reflection/UseParent.php +++ /dev/null @@ -1,9 +0,0 @@ -assertEquals($expectedClassName, ClassUtils::getRealClass($className)); - } - - /** - * @dataProvider dataGetClass - */ - public function testGetClass( $className, $expectedClassName ) - { - $object = new $className(); - $this->assertEquals($expectedClassName, ClassUtils::getClass($object)); - } - - public function testGetParentClass() - { - $parentClass = ClassUtils::getParentClass( 'MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\Doctrine\Tests\Common\Util\ChildObject' ); - $this->assertEquals('stdClass', $parentClass); - } - - public function testGenerateProxyClassName() - { - $this->assertEquals( 'Proxies\__CG__\stdClass', ClassUtils::generateProxyClassName( 'stdClass', 'Proxies' ) ); - } - - /** - * @dataProvider dataGetClass - */ - public function testNewReflectionClass( $className, $expectedClassName ) - { - $reflClass = ClassUtils::newReflectionClass( $className ); - $this->assertEquals( $expectedClassName, $reflClass->getName() ); - } - - /** - * @dataProvider dataGetClass - */ - public function testNewReflectionObject( $className, $expectedClassName ) - { - $object = new $className; - $reflClass = ClassUtils::newReflectionObject( $object ); - $this->assertEquals( $expectedClassName, $reflClass->getName() ); - } - } - - class ChildObject extends \stdClass - { - } -} - -namespace MyProject\Proxies\__CG__ -{ - class stdClass extends \stdClass - { - } -} - -namespace MyProject\Proxies\__CG__\Doctrine\Tests\Common\Util -{ - class ChildObject extends \Doctrine\Tests\Common\Util\ChildObject - { - } -} - -namespace MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__ -{ - class stdClass extends \MyProject\Proxies\__CG__\stdClass - { - } -} - -namespace MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\Doctrine\Tests\Common\Util -{ - class ChildObject extends \MyProject\Proxies\__CG__\Doctrine\Tests\Common\Util\ChildObject - { - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/DebugTest.php b/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/DebugTest.php deleted file mode 100644 index b4e9eed..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/Common/Util/DebugTest.php +++ /dev/null @@ -1,27 +0,0 @@ -foo = "bar"; - $obj->bar = 1234; - - $var = Debug::export($obj, 2); - $this->assertEquals( "stdClass", $var->__CLASS__ ); - } - - public function testExportDateTime() - { - $obj = new \DateTime( "2010-10-10 10:10:10" ); - - $var = Debug::export( $obj, 2 ); - $this->assertEquals( "DateTime", $var->__CLASS__ ); - } -} diff --git a/vendor/doctrine/common/tests/Doctrine/Tests/DoctrineTestCase.php b/vendor/doctrine/common/tests/Doctrine/Tests/DoctrineTestCase.php deleted file mode 100644 index e8323d2..0000000 --- a/vendor/doctrine/common/tests/Doctrine/Tests/DoctrineTestCase.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ -class NativePhpunitTask extends Task -{ - private $test; - private $testfile; - private $testdirectory; - private $configuration = null; - private $coverageClover = null; - private $junitlogfile = null; - private $haltonfailure = true; - private $haltonerror = true; - - public function setTestdirectory($directory) { - $this->testdirectory = $directory; - } - - public function setTest($test) { - $this->test = $test; - } - - public function setTestfile($testfile) { - $this->testfile = $testfile; - } - - public function setJunitlogfile($junitlogfile) { - if (strlen($junitlogfile) == 0) { - $junitlogfile = NULL; - } - - $this->junitlogfile = $junitlogfile; - } - - public function setConfiguration($configuration) { - if (strlen($configuration) == 0) { - $configuration = NULL; - } - - $this->configuration = $configuration; - } - - public function setCoverageClover($coverageClover) { - if (strlen($coverageClover) == 0) { - $coverageClover = NULL; - } - - $this->coverageClover = $coverageClover; - } - - public function setHaltonfailure($haltonfailures) { - $this->haltonfailure = $haltonfailures; - } - - public function setHaltonerror($haltonerrors) { - $this->haltonerror = $haltonerrors; - } - - public function init() - { - require_once "PHPUnit/Runner/Version.php"; - $version = PHPUnit_Runner_Version::id(); - - if (version_compare($version, '3.4.0') < 0) { - throw new BuildException("NativePHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation()); - } - - require_once 'PHPUnit/Util/Filter.php'; - - // point PHPUnit_MAIN_METHOD define to non-existing method - if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined'); - } - } - - public function main() - { - if (!is_dir(realpath($this->testdirectory))) { - throw new BuildException("NativePHPUnitTask requires a Test Directory path given, '".$this->testdirectory."' given."); - } - set_include_path(realpath($this->testdirectory) . PATH_SEPARATOR . get_include_path()); - - $printer = new NativePhpunitPrinter(); - - $arguments = array( - 'configuration' => $this->configuration, - 'coverageClover' => $this->coverageClover, - 'junitLogfile' => $this->junitlogfile, - 'printer' => $printer, - ); - - $runner = new PHPUnit_TextUI_TestRunner(); - $suite = $runner->getTest($this->test, $this->testfile, true); - - try { - $result = $runner->doRun($suite, $arguments); - /* @var $result PHPUnit_Framework_TestResult */ - - if ( ($this->haltonfailure && $result->failureCount() > 0) || ($this->haltonerror && $result->errorCount() > 0) ) { - throw new BuildException("PHPUnit: ".$result->failureCount()." Failures and ".$result->errorCount()." Errors, ". - "last failure message: ".$printer->getMessages()); - } - - $this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ". - "failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)"); - - // Hudson for example doesn't like the backslash in class names - if (file_exists($this->coverageClover)) { - $this->log("Generated Clover Coverage XML to: ".$this->coverageClover); - $content = file_get_contents($this->coverageClover); - $content = str_replace("\\", ".", $content); - file_put_contents($this->coverageClover, $content); - unset($content); - } - - } catch(\Exception $e) { - throw new BuildException("NativePhpunitTask failed: ".$e->getMessage()); - } - } -} - -class NativePhpunitPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener -{ - private $_messages = array(); - - public function write($buffer) - { - // do nothing - } - - public function getMessages() - { - return $this->_messages; - } - - /** - * An error occurred. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->_messages[] = "Test ERROR: ".$test->getName().": ".$e->getMessage(); - } - - /** - * A failure occurred. - * - * @param PHPUnit_Framework_Test $test - * @param PHPUnit_Framework_AssertionFailedError $e - * @param float $time - */ - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - $this->_messages[] = "Test FAILED: ".$test->getName().": ".$e->getMessage(); - } - - /** - * Incomplete test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - */ - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - - } - - /** - * Skipped test. - * - * @param PHPUnit_Framework_Test $test - * @param Exception $e - * @param float $time - * @since Method available since Release 3.0.0 - */ - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - - } - - /** - * A test suite started. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - - } - - /** - * A test suite ended. - * - * @param PHPUnit_Framework_TestSuite $suite - * @since Method available since Release 2.2.0 - */ - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - - } - - /** - * A test started. - * - * @param PHPUnit_Framework_Test $test - */ - public function startTest(PHPUnit_Framework_Test $test) - { - - } - - /** - * A test ended. - * - * @param PHPUnit_Framework_Test $test - * @param float $time - */ - public function endTest(PHPUnit_Framework_Test $test, $time) - { - - } -} diff --git a/vendor/doctrine/common/tests/README.markdown b/vendor/doctrine/common/tests/README.markdown deleted file mode 100644 index e6f1703..0000000 --- a/vendor/doctrine/common/tests/README.markdown +++ /dev/null @@ -1,27 +0,0 @@ -# Running the Doctrine 2 Testsuite - -## Running tests - -Execute PHPUnit in the root folder of your doctrine-common clone. - - phpunit - -## Testing Lock-Support - -The Lock support in Doctrine 2 is tested using Gearman, which allows to run concurrent tasks in parallel. -Install Gearman with PHP as follows: - -1. Go to http://www.gearman.org and download the latest Gearman Server -2. Compile it and then call ldconfig -3. Start it up "gearmand -vvvv" -4. Install pecl/gearman by calling "gearman-beta" - -You can then go into tests/ and start up two workers: - - php Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php - -Then run the locking test-suite: - - phpunit --configuration Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php - -This can run considerable time, because it is using sleep() to test for the timing ranges of locks. \ No newline at end of file diff --git a/vendor/fabpot/goutte/.gitignore b/vendor/fabpot/goutte/.gitignore index c0bb3e6..81b9258 100644 --- a/vendor/fabpot/goutte/.gitignore +++ b/vendor/fabpot/goutte/.gitignore @@ -1,3 +1,3 @@ +composer.lock phpunit.xml vendor - diff --git a/vendor/fabpot/goutte/.travis.yml b/vendor/fabpot/goutte/.travis.yml index 37705da..e85a7b4 100644 --- a/vendor/fabpot/goutte/.travis.yml +++ b/vendor/fabpot/goutte/.travis.yml @@ -1,8 +1,18 @@ language: php + php: - - "5.4" - - "5.3" + - '5.6' + - '5.5' + - '5.4' + - '5.3' + - hhvm + before_script: - - composer install -n --dev + - composer install -n + script: - - phpunit + - phpunit + +matrix: + allow_failures: + - php: hhvm diff --git a/vendor/fabpot/goutte/CHANGELOG b/vendor/fabpot/goutte/CHANGELOG deleted file mode 100644 index 791013c..0000000 --- a/vendor/fabpot/goutte/CHANGELOG +++ /dev/null @@ -1,7 +0,0 @@ -CHANGELOG -========= - -* 0.2 - - * The first argument to Client has been removed - * Zend libraries have been replaced with Guzzle diff --git a/vendor/fabpot/goutte/Goutte/Client.php b/vendor/fabpot/goutte/Goutte/Client.php index f69e40a..b962c55 100644 --- a/vendor/fabpot/goutte/Goutte/Client.php +++ b/vendor/fabpot/goutte/Goutte/Client.php @@ -46,7 +46,7 @@ public function setClient(GuzzleClientInterface $client) public function getClient() { if (!$this->client) { - $this->client = new GuzzleClient('', array('redirect.disable' => true)); + $this->client = new GuzzleClient('', array(GuzzleClient::DISABLE_REDIRECTS => true)); } return $this->client; @@ -59,6 +59,11 @@ public function setHeader($name, $value) return $this; } + public function removeHeader($name) + { + unset($this->headers[$name]); + } + public function setAuth($user, $password = '', $type = CURLAUTH_BASIC) { $this->auth = array( @@ -70,11 +75,18 @@ public function setAuth($user, $password = '', $type = CURLAUTH_BASIC) return $this; } + public function resetAuth() + { + $this->auth = null; + + return $this; + } + protected function doRequest($request) { $headers = array(); foreach ($request->getServer() as $key => $val) { - $key = ucfirst(strtolower(str_replace(array('_', 'HTTP-'), array('-', ''), $key))); + $key = implode('-', array_map('ucfirst', explode('-', strtolower(str_replace(array('_', 'HTTP-'), array('-', ''), $key))))); if (!isset($headers[$key])) { $headers[$key] = $val; } @@ -112,7 +124,7 @@ protected function doRequest($request) $guzzleRequest->addCookie($name, $value); } - if ('POST' == $request->getMethod()) { + if ('POST' == $request->getMethod() || 'PUT' == $request->getMethod()) { $this->addPostFiles($guzzleRequest, $request->getFiles()); } @@ -153,7 +165,7 @@ protected function addPostFiles($request, array $files, $arrayName = '') if (is_array($info)) { if (isset($info['tmp_name'])) { if ('' !== $info['tmp_name']) { - $request->addPostFile($name, $info['tmp_name']); + $request->addPostFile($name, $info['tmp_name'], null, isset($info['name']) ? $info['name'] : null); } else { continue; } @@ -168,6 +180,8 @@ protected function addPostFiles($request, array $files, $arrayName = '') protected function createResponse(GuzzleResponse $response) { - return new Response($response->getBody(true), $response->getStatusCode(), $response->getHeaders()->getAll()); + $headers = $response->getHeaders()->toArray(); + + return new Response($response->getBody(true), $response->getStatusCode(), $headers); } } diff --git a/vendor/fabpot/goutte/Goutte/Compiler.php b/vendor/fabpot/goutte/Goutte/Compiler.php deleted file mode 100644 index 5e1b875..0000000 --- a/vendor/fabpot/goutte/Goutte/Compiler.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Goutte; - -use Symfony\Component\Finder\Finder; - -/** - * The Compiler class compiles the Goutte utility. - * - * @author Fabien Potencier - */ -class Compiler -{ - public function compile($pharFile = 'goutte.phar') - { - if (file_exists($pharFile)) { - unlink($pharFile); - } - - $phar = new \Phar($pharFile, 0, 'Goutte'); - $phar->setSignatureAlgorithm(\Phar::SHA1); - - $phar->startBuffering(); - - // CLI Component files - foreach ($this->getFiles() as $file) { - $path = str_replace(__DIR__.'/', '', $file); - $phar->addFromString($path, file_get_contents($file)); - } - - // Stubs - $phar['_cli_stub.php'] = $this->getCliStub(); - $phar['_web_stub.php'] = $this->getWebStub(); - $phar->setDefaultStub('_cli_stub.php', '_web_stub.php'); - - $phar->stopBuffering(); - - // $phar->compressFiles(\Phar::GZ); - - unset($phar); - } - - protected function getCliStub() - { - return "getLicense()." require_once __DIR__.'/vendor/autoload.php'; __HALT_COMPILER();"; - } - - protected function getWebStub() - { - return " - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */'; - } - - protected function getFiles() - { - $files = array( - 'LICENSE', - 'vendor/autoload.php', - 'Goutte/Client.php', - ); - - $dirs = array( - 'vendor/composer', - 'vendor/symfony', - 'vendor/guzzle' - ); - - $iterator = Finder::create()->files()->name('*.php')->in($dirs); - - return array_merge($files, iterator_to_array($iterator)); - } -} diff --git a/vendor/fabpot/goutte/Goutte/Resources/phar-stub.php b/vendor/fabpot/goutte/Goutte/Resources/phar-stub.php new file mode 100644 index 0000000..b9c3b44 --- /dev/null +++ b/vendor/fabpot/goutte/Goutte/Resources/phar-stub.php @@ -0,0 +1,14 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +require_once 'phar://'.__FILE__.'/vendor/autoload.php'; + +__HALT_COMPILER(); diff --git a/vendor/fabpot/goutte/Goutte/Tests/ClientTest.php b/vendor/fabpot/goutte/Goutte/Tests/ClientTest.php index db0a5d5..654dd9d 100644 --- a/vendor/fabpot/goutte/Goutte/Tests/ClientTest.php +++ b/vendor/fabpot/goutte/Goutte/Tests/ClientTest.php @@ -15,6 +15,7 @@ use Symfony\Component\BrowserKit\Cookie; use Guzzle\Http\Message\Response as GuzzleResponse; +use Guzzle\Http\Message\Header as GuzzleHeader; use Guzzle\Http\Client as GuzzleClient; use Guzzle\Plugin\Mock\MockPlugin; use Guzzle\Plugin\History\HistoryPlugin; @@ -28,7 +29,7 @@ */ class ClientTest extends \PHPUnit_Framework_TestCase { - protected $history; + protected $historyPlugin; protected $mockPlugin; protected function getGuzzle() @@ -89,6 +90,19 @@ public function testUsesAuth() $this->assertEquals('**', $request->getPassword()); } + public function testResetsAuth() + { + $guzzle = $this->getGuzzle(); + $client = new Client(); + $client->setClient($guzzle); + $client->setAuth('me', '**'); + $client->resetAuth(); + $crawler = $client->request('GET', 'http://www.example.com/'); + $request = $this->historyPlugin->getLastRequest(); + $this->assertNull($request->getUsername()); + $this->assertNull($request->getPassword()); + } + public function testUsesCookies() { $guzzle = $this->getGuzzle(); @@ -117,7 +131,7 @@ public function testUsesPostFiles() $this->assertEquals(array( 'test' => array( - new PostFile('test', __FILE__, 'text/x-php') + new PostFile('test', __FILE__, 'text/x-php', 'test.txt') ) ), $request->getPostFiles()); } @@ -160,7 +174,7 @@ public function testUsesPostFilesNestedFields() $this->assertEquals(array( 'form[test]' => array( - new PostFile('form[test]', __FILE__, 'text/x-php') + new PostFile('form[test]', __FILE__, 'text/x-php', 'test.txt') ) ), $request->getPostFiles()); } @@ -244,4 +258,26 @@ public function testHandlesRedirectsCorrectly() // Ensure that two requests were sent $this->assertEquals(2, count($this->historyPlugin)); } + + public function testConvertsGuzzleHeadersToArrays() + { + if (!class_exists("Guzzle\Http\Message\Header")) { + $this->markTestSkipped("Guzzle ~3.6 required"); + } + + $guzzle = $this->getGuzzle(); + + $this->mockPlugin->clearQueue(); + $this->mockPlugin->addResponse(new GuzzleResponse(200, array( + new GuzzleHeader('Date', 'Tue, 04 Jun 2013 13:22:41 GMT'), + ))); + + $client = new Client(); + $client->setClient($guzzle); + $client->request('GET', 'http://www.example.com/'); + $response = $client->getResponse(); + $headers = $response->getHeaders(); + + $this->assertInternalType("array", array_shift($headers), "Header not converted from Guzzle\Http\Message\Header to array"); + } } diff --git a/vendor/fabpot/goutte/README.md b/vendor/fabpot/goutte/README.md deleted file mode 100644 index 53997f1..0000000 --- a/vendor/fabpot/goutte/README.md +++ /dev/null @@ -1,83 +0,0 @@ -Goutte, a simple PHP Web Scraper -================================ - -Goutte is a screen scraping and web crawling library for PHP. - -Goutte provides a nice API to crawl websites and extract data from the -HTML/XML responses. - -Requirements ------------- - -Goutte works with PHP 5.3.3 or later. - -Installation ------------- - -Installing Goutte is as easy as it can get. Download the [`Goutte.phar`][1] -file and you're done! - -Usage ------ - -Require the Goutte phar file to use Goutte in a script: - - require_once '/path/to/goutte.phar'; - -Create a Goutte Client instance (which extends -`Symfony\Component\BrowserKit\Client`): - - use Goutte\Client; - - $client = new Client(); - -Make requests with the `request()` method: - - $crawler = $client->request('GET', 'http://www.symfony-project.org/'); - -The method returns a `Crawler` object -(`Symfony\Component\DomCrawler\Crawler`). - -Click on links: - - $link = $crawler->selectLink('Plugins')->link(); - $crawler = $client->click($link); - -Submit forms: - - $form = $crawler->selectButton('sign in')->form(); - $crawler = $client->submit($form, array('signin[username]' => 'fabien', 'signin[password]' => 'xxxxxx')); - -Extract data: - - $nodes = $crawler->filter('.error_list'); - if ($nodes->count()) - { - die(sprintf("Authentication error: %s\n", $nodes->text())); - } - - printf("Nb tasks: %d\n", $crawler->filter('#nb_tasks')->text()); - -More Information ----------------- - -Read the documentation of the BrowserKit and DomCrawler Symfony Components for -more information about what you can do with Goutte. - -Technical Information ---------------------- - -Goutte is a thin wrapper around the following fine PHP libraries: - - * Symfony Components: BrowserKit, ClassLoader, CssSelector, DomCrawler, - Finder, and Process - - * [Guzzle](http://www.guzzlephp.org) - -License -------- - -Goutte is licensed under the MIT license. - -[1]: https://raw.github.com/fabpot/Goutte/master/goutte.phar - diff --git a/vendor/fabpot/goutte/README.rst b/vendor/fabpot/goutte/README.rst new file mode 100644 index 0000000..1fc247c --- /dev/null +++ b/vendor/fabpot/goutte/README.rst @@ -0,0 +1,105 @@ +Goutte, a simple PHP Web Scraper +================================ + +Goutte is a screen scraping and web crawling library for PHP. + +Goutte provides a nice API to crawl websites and extract data from the HTML/XML +responses. + +Requirements +------------ + +Goutte works with PHP 5.3.3 or later. + +Installation +------------ + +Add ``fabpot/goutte`` as a require dependency in your ``composer.json`` file: + +.. code-block:: bash + + php composer.phar require fabpot/goutte:~1.0 + +.. tip:: + + You can also download the `Goutte.phar`_ file: + + .. code-block:: php + + require_once '/path/to/goutte.phar'; + +Usage +----- + +Create a Goutte Client instance (which extends +``Symfony\Component\BrowserKit\Client``): + +.. code-block:: php + + use Goutte\Client; + + $client = new Client(); + +Make requests with the ``request()`` method: + +.. code-block:: php + + // Go to the symfony.com website + $crawler = $client->request('GET', 'http://www.symfony.com/blog/'); + +The method returns a ``Crawler`` object +(``Symfony\Component\DomCrawler\Crawler``). + +Click on links: + +.. code-block:: php + + // Click on the "Security Advisories" link + $link = $crawler->selectLink('Security Advisories')->link(); + $crawler = $client->click($link); + +Extract data: + +.. code-block:: php + + // Get the latest post in this category and display the titles + $crawler->filter('h2.post > a')->each(function ($node) { + print $node->text()."\n"; + }); + +Submit forms: + +.. code-block:: php + + $crawler = $client->request('GET', 'http://github.com/'); + $crawler = $client->click($crawler->selectLink('Sign in')->link()); + $form = $crawler->selectButton('Sign in')->form(); + $crawler = $client->submit($form, array('login' => 'fabpot', 'password' => 'xxxxxx')); + $crawler->filter('.flash-error')->each(function ($node) { + print $node->text()."\n"; + }); + +More Information +---------------- + +Read the documentation of the BrowserKit and DomCrawler Symfony Components for +more information about what you can do with Goutte. + +Technical Information +--------------------- + +Goutte is a thin wrapper around the following fine PHP libraries: + +* Symfony Components: BrowserKit, ClassLoader, CssSelector, DomCrawler, Finder, + and Process; + +* `Guzzle`_ HTTP Component. + +License +------- + +Goutte is licensed under the MIT license. + +.. _`Composer`: http://getcomposer.org +.. _`Goutte.phar`: http://get.sensiolabs.org/goutte.phar +.. _`Guzzle`: http://docs.guzzlephp.org diff --git a/vendor/fabpot/goutte/box.json b/vendor/fabpot/goutte/box.json new file mode 100644 index 0000000..943c61e --- /dev/null +++ b/vendor/fabpot/goutte/box.json @@ -0,0 +1,21 @@ +{ + "output": "goutte.phar", + "chmod": "0755", + "compactors": [ + "Herrera\\Box\\Compactor\\Php" + ], + "extract": false, + "files": [ + "LICENSE", + "Goutte/Client.php" + ], + "finder": [ + { + "name": ["*.php", "*.pem*"], + "exclude": ["Tests", "tests"], + "in": "vendor" + } + ], + "stub": "Goutte/Resources/phar-stub.php", + "web": false +} diff --git a/vendor/fabpot/goutte/compile b/vendor/fabpot/goutte/compile deleted file mode 100755 index 710f8e8..0000000 --- a/vendor/fabpot/goutte/compile +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env php -compile(); diff --git a/vendor/fabpot/goutte/composer.json b/vendor/fabpot/goutte/composer.json index 1c5e470..7f24635 100644 --- a/vendor/fabpot/goutte/composer.json +++ b/vendor/fabpot/goutte/composer.json @@ -19,7 +19,11 @@ "symfony/dom-crawler": "~2.1", "symfony/finder": "~2.1", "symfony/process": "~2.1", - "guzzle/guzzle": ">=3.0, <3.4" + "guzzle/http": "~3.1" + }, + "require-dev": { + "guzzle/plugin-history": "~3.1", + "guzzle/plugin-mock": "~3.1" }, "autoload": { "psr-0": { "Goutte": "." } diff --git a/vendor/fabpot/goutte/composer.lock b/vendor/fabpot/goutte/composer.lock deleted file mode 100644 index 28c91b3..0000000 --- a/vendor/fabpot/goutte/composer.lock +++ /dev/null @@ -1,418 +0,0 @@ -{ - "hash": "62ed4b74fc5e6c55b519cc3fa45208f1", - "packages": [ - { - "name": "guzzle/guzzle", - "version": "v3.3.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "v3.3.0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/v3.3.0", - "reference": "v3.3.0", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.2", - "symfony/event-dispatcher": ">=2.1" - }, - "replace": { - "guzzle/batch": "self.version", - "guzzle/cache": "self.version", - "guzzle/common": "self.version", - "guzzle/http": "self.version", - "guzzle/inflection": "self.version", - "guzzle/iterator": "self.version", - "guzzle/log": "self.version", - "guzzle/parser": "self.version", - "guzzle/plugin": "self.version", - "guzzle/plugin-async": "self.version", - "guzzle/plugin-backoff": "self.version", - "guzzle/plugin-cache": "self.version", - "guzzle/plugin-cookie": "self.version", - "guzzle/plugin-curlauth": "self.version", - "guzzle/plugin-error-response": "self.version", - "guzzle/plugin-history": "self.version", - "guzzle/plugin-log": "self.version", - "guzzle/plugin-md5": "self.version", - "guzzle/plugin-mock": "self.version", - "guzzle/plugin-oauth": "self.version", - "guzzle/service": "self.version", - "guzzle/stream": "self.version" - }, - "require-dev": { - "doctrine/cache": "*", - "monolog/monolog": "1.*", - "phpunit/phpunit": "3.7.*", - "symfony/class-loader": "*", - "zend/zend-cache1": "1.12", - "zend/zend-log1": "1.12", - "zendframework/zend-cache": "2.0.*", - "zendframework/zend-log": "2.0.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-0": { - "Guzzle\\Tests": "tests/", - "Guzzle": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Guzzle Community", - "homepage": "https://github.com/guzzle/guzzle/contributors" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2013-03-04 00:41:45" - }, - { - "name": "symfony/browser-kit", - "version": "v2.2.0", - "target-dir": "Symfony/Component/BrowserKit", - "source": { - "type": "git", - "url": "https://github.com/symfony/BrowserKit.git", - "reference": "v2.2.0-RC3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/v2.2.0-RC3", - "reference": "v2.2.0-RC3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/dom-crawler": ">=2.0,<3.0" - }, - "require-dev": { - "symfony/css-selector": ">=2.0,<3.0", - "symfony/process": ">=2.0,<3.0" - }, - "suggest": { - "symfony/process": "2.2.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\BrowserKit\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony BrowserKit Component", - "homepage": "http://symfony.com", - "time": "2013-02-23 06:46:07" - }, - { - "name": "symfony/css-selector", - "version": "v2.2.0", - "target-dir": "Symfony/Component/CssSelector", - "source": { - "type": "git", - "url": "https://github.com/symfony/CssSelector.git", - "reference": "v2.2.0-RC3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.2.0-RC3", - "reference": "v2.2.0-RC3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\CssSelector\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony CssSelector Component", - "homepage": "http://symfony.com", - "time": "2013-01-17 15:25:59" - }, - { - "name": "symfony/dom-crawler", - "version": "v2.2.0", - "target-dir": "Symfony/Component/DomCrawler", - "source": { - "type": "git", - "url": "https://github.com/symfony/DomCrawler.git", - "reference": "v2.2.0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/v2.2.0", - "reference": "v2.2.0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/css-selector": ">=2.0,<3.0" - }, - "suggest": { - "symfony/css-selector": "2.2.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\DomCrawler\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony DomCrawler Component", - "homepage": "http://symfony.com", - "time": "2013-03-01 06:43:14" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.2.0", - "target-dir": "Symfony/Component/EventDispatcher", - "source": { - "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.0-RC3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.0-RC3", - "reference": "v2.2.0-RC3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/dependency-injection": ">=2.0,<3.0" - }, - "suggest": { - "symfony/dependency-injection": "2.2.*", - "symfony/http-kernel": "2.2.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com", - "time": "2013-02-11 11:26:43" - }, - { - "name": "symfony/finder", - "version": "v2.2.0", - "target-dir": "Symfony/Component/Finder", - "source": { - "type": "git", - "url": "https://github.com/symfony/Finder.git", - "reference": "v2.2.0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.2.0", - "reference": "v2.2.0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Finder\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "http://symfony.com", - "time": "2013-02-28 14:06:36" - }, - { - "name": "symfony/process", - "version": "v2.2.0", - "target-dir": "Symfony/Component/Process", - "source": { - "type": "git", - "url": "https://github.com/symfony/Process.git", - "reference": "v2.2.0-RC3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.2.0-RC3", - "reference": "v2.2.0-RC3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Process\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "http://symfony.com", - "time": "2013-02-18 21:28:10" - } - ], - "packages-dev": [ - - ], - "aliases": [ - - ], - "minimum-stability": "stable", - "stability-flags": [ - - ], - "platform": { - "php": ">=5.3.0", - "ext-curl": "*" - }, - "platform-dev": [ - - ] -} diff --git a/vendor/fabpot/goutte/goutte.phar b/vendor/fabpot/goutte/goutte.phar deleted file mode 100644 index 8a4278a..0000000 Binary files a/vendor/fabpot/goutte/goutte.phar and /dev/null differ diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/.gitignore b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/.gitignore index 44de97a..c49a5d8 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/.gitignore +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/.gitignore @@ -1,4 +1,3 @@ vendor/ composer.lock phpunit.xml - diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CHANGELOG.md b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CHANGELOG.md index 42d32a7..d2b1074 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CHANGELOG.md +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CHANGELOG.md @@ -1,6 +1,16 @@ CHANGELOG ========= +2.3.0 +----- + + * [BC BREAK] `Client::followRedirect()` won't redirect responses with + a non-3xx Status Code and `Location` header anymore, as per + http://tools.ietf.org/html/rfc2616#section-14.30 + + * added `Client::getInternalRequest()` and `Client::getInternalResponse()` to + have access to the BrowserKit internal request and response objects + 2.1.0 ----- diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php index c57b9e3..90df108 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php @@ -32,13 +32,19 @@ abstract class Client { protected $history; protected $cookieJar; - protected $server; + protected $server = array(); + protected $internalRequest; protected $request; + protected $internalResponse; protected $response; protected $crawler; - protected $insulated; + protected $insulated = false; protected $redirect; - protected $followRedirects; + protected $followRedirects = true; + + private $maxRedirects = -1; + private $redirectCount = 0; + private $isMainRequest = true; /** * Constructor. @@ -52,28 +58,37 @@ abstract class Client public function __construct(array $server = array(), History $history = null, CookieJar $cookieJar = null) { $this->setServerParameters($server); - $this->history = null === $history ? new History() : $history; - $this->cookieJar = null === $cookieJar ? new CookieJar() : $cookieJar; - $this->insulated = false; - $this->followRedirects = true; + $this->history = $history ?: new History(); + $this->cookieJar = $cookieJar ?: new CookieJar(); } /** * Sets whether to automatically follow redirects or not. * - * @param Boolean $followRedirect Whether to follow redirects + * @param bool $followRedirect Whether to follow redirects * * @api */ public function followRedirects($followRedirect = true) { - $this->followRedirects = (Boolean) $followRedirect; + $this->followRedirects = (bool) $followRedirect; + } + + /** + * Sets the maximum number of requests that crawler can follow. + * + * @param int $maxRedirects + */ + public function setMaxRedirects($maxRedirects) + { + $this->maxRedirects = $maxRedirects < 0 ? -1 : $maxRedirects; + $this->followRedirects = -1 != $this->maxRedirects; } /** * Sets the insulated flag. * - * @param Boolean $insulated Whether to insulate the requests or not + * @param bool $insulated Whether to insulate the requests or not * * @throws \RuntimeException When Symfony Process Component is not installed * @@ -82,12 +97,10 @@ public function followRedirects($followRedirect = true) public function insulate($insulated = true) { if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) { - // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to isolate requests as the Symfony Process Component is not installed.'); - // @codeCoverageIgnoreEnd } - $this->insulated = (Boolean) $insulated; + $this->insulated = (bool) $insulated; } /** @@ -100,7 +113,7 @@ public function insulate($insulated = true) public function setServerParameters(array $server) { $this->server = array_merge(array( - 'HTTP_HOST' => 'localhost', + 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', ), $server); } @@ -156,7 +169,7 @@ public function getCookieJar() /** * Returns the current Crawler instance. * - * @return Crawler A Crawler instance + * @return Crawler|null A Crawler instance * * @api */ @@ -166,9 +179,26 @@ public function getCrawler() } /** - * Returns the current Response instance. + * Returns the current BrowserKit Response instance. + * + * @return Response|null A BrowserKit Response instance + * + * @api + */ + public function getInternalResponse() + { + return $this->internalResponse; + } + + /** + * Returns the current origin response instance. + * + * The origin response is the response instance that is returned + * by the code that handles requests. + * + * @return object|null A response instance * - * @return Response A Response instance + * @see doRequest() * * @api */ @@ -178,9 +208,26 @@ public function getResponse() } /** - * Returns the current Request instance. + * Returns the current BrowserKit Request instance. * - * @return Request A Request instance + * @return Request|null A BrowserKit Request instance + * + * @api + */ + public function getInternalRequest() + { + return $this->internalRequest; + } + + /** + * Returns the current origin Request instance. + * + * The origin request is the request instance that is sent + * to the code that handles requests. + * + * @return object|null A Request instance + * + * @see doRequest() * * @api */ @@ -227,13 +274,13 @@ public function submit(Form $form, array $values = array()) /** * Calls a URI. * - * @param string $method The request method - * @param string $uri The URI to fetch - * @param array $parameters The Request parameters - * @param array $files The files - * @param array $server The server parameters (HTTP headers are referenced with a HTTP_ prefix as PHP does) - * @param string $content The raw body data - * @param Boolean $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) + * @param string $method The request method + * @param string $uri The URI to fetch + * @param array $parameters The Request parameters + * @param array $files The files + * @param array $server The server parameters (HTTP headers are referenced with a HTTP_ prefix as PHP does) + * @param string $content The raw body data + * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) * * @return Crawler * @@ -241,21 +288,37 @@ public function submit(Form $form, array $values = array()) */ public function request($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) { + if ($this->isMainRequest) { + $this->redirectCount = 0; + } else { + ++$this->redirectCount; + } + $uri = $this->getAbsoluteUri($uri); + if (!empty($server['HTTP_HOST'])) { + $uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri); + } + + if (isset($server['HTTPS'])) { + $uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); + } + $server = array_merge($this->server, $server); + if (!$this->history->isEmpty()) { $server['HTTP_REFERER'] = $this->history->current()->getUri(); } - $server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST); + + $server['HTTP_HOST'] = $this->extractHost($uri); $server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME); - $request = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content); + $this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content); - $this->request = $this->filterRequest($request); + $this->request = $this->filterRequest($this->internalRequest); if (true === $changeHistory) { - $this->history->add($request); + $this->history->add($this->internalRequest); } if ($this->insulated) { @@ -264,25 +327,31 @@ public function request($method, $uri, array $parameters = array(), array $files $this->response = $this->doRequest($this->request); } - $response = $this->filterResponse($this->response); + $this->internalResponse = $this->filterResponse($this->response); - $this->cookieJar->updateFromResponse($response); + $this->cookieJar->updateFromResponse($this->internalResponse, $uri); - $this->redirect = $response->getHeader('Location'); + $status = $this->internalResponse->getStatus(); + + if ($status >= 300 && $status < 400) { + $this->redirect = $this->internalResponse->getHeader('Location'); + } else { + $this->redirect = null; + } if ($this->followRedirects && $this->redirect) { return $this->crawler = $this->followRedirect(); } - return $this->crawler = $this->createCrawlerFromContent($request->getUri(), $response->getContent(), $response->getHeader('Content-Type')); + return $this->crawler = $this->createCrawlerFromContent($this->internalRequest->getUri(), $this->internalResponse->getContent(), $this->internalResponse->getHeader('Content-Type')); } /** * Makes a request in another process. * - * @param Request $request A Request instance + * @param object $request An origin request instance * - * @return Response A Response instance + * @return object An origin response instance * * @throws \RuntimeException When processing returns exit code */ @@ -293,7 +362,7 @@ protected function doRequestInProcess($request) $process->run(); if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) { - throw new \RuntimeException('OUTPUT: '.$process->getOutput().' ERROR OUTPUT: '.$process->getErrorOutput()); + throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput())); } return unserialize($process->getOutput()); @@ -302,32 +371,30 @@ protected function doRequestInProcess($request) /** * Makes a request. * - * @param Request $request A Request instance + * @param object $request An origin request instance * - * @return Response A Response instance + * @return object An origin response instance */ abstract protected function doRequest($request); /** * Returns the script to execute when the request must be insulated. * - * @param Request $request A Request instance + * @param object $request An origin request instance * * @throws \LogicException When this abstract class is not implemented */ protected function getScript($request) { - // @codeCoverageIgnoreStart throw new \LogicException('To insulate requests, you need to override the getScript() method.'); - // @codeCoverageIgnoreEnd } /** - * Filters the request. + * Filters the BrowserKit request to the origin one. * - * @param Request $request The request to filter + * @param Request $request The BrowserKit Request to filter * - * @return Request + * @return object An origin request instance */ protected function filterRequest(Request $request) { @@ -335,11 +402,11 @@ protected function filterRequest(Request $request) } /** - * Filters the Response. + * Filters the origin response to the BrowserKit one. * - * @param Response $response The Response to filter + * @param object $response The origin response to filter * - * @return Response + * @return Response An BrowserKit Response instance */ protected function filterResponse($response) { @@ -351,7 +418,7 @@ protected function filterResponse($response) * * This method returns null if the DomCrawler component is not available. * - * @param string $uri A uri + * @param string $uri A URI * @param string $content Content for the crawler to use * @param string $type Content type * @@ -360,7 +427,7 @@ protected function filterResponse($response) protected function createCrawlerFromContent($uri, $content, $type) { if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { - return null; + return; } $crawler = new Crawler(null, $uri); @@ -420,7 +487,41 @@ public function followRedirect() throw new \LogicException('The request was not redirected.'); } - return $this->request('get', $this->redirect); + if (-1 !== $this->maxRedirects) { + if ($this->redirectCount > $this->maxRedirects) { + throw new \LogicException(sprintf('The maximum number (%d) of redirections was reached.', $this->maxRedirects)); + } + } + + $request = $this->internalRequest; + + if (in_array($this->internalResponse->getStatus(), array(302, 303))) { + $method = 'get'; + $files = array(); + $content = null; + } else { + $method = $request->getMethod(); + $files = $request->getFiles(); + $content = $request->getContent(); + } + + if ('get' === strtolower($method)) { + // Don't forward parameters for GET request as it should reach the redirection URI + $parameters = array(); + } else { + $parameters = $request->getParameters(); + } + + $server = $request->getServer(); + $server = $this->updateServerFromUri($server, $this->redirect); + + $this->isMainRequest = false; + + $response = $this->request($method, $this->redirect, $parameters, $files, $server, $content); + + $this->isMainRequest = true; + + return $response; } /** @@ -439,9 +540,9 @@ public function restart() /** * Takes a URI and converts it to absolute if it is not already absolute. * - * @param string $uri A uri + * @param string $uri A URI * - * @return string An absolute uri + * @return string An absolute URI */ protected function getAbsoluteUri($uri) { @@ -459,6 +560,11 @@ protected function getAbsoluteUri($uri) ); } + // protocol relative URL + if (0 === strpos($uri, '//')) { + return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri; + } + // anchor? if (!$uri || '#' == $uri[0]) { return preg_replace('/#.*?$/', '', $currentUri).$uri; @@ -481,7 +587,7 @@ protected function getAbsoluteUri($uri) * Makes a request from a Request object directly. * * @param Request $request A Request instance - * @param Boolean $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) + * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) * * @return Crawler */ @@ -489,4 +595,25 @@ protected function requestFromRequest(Request $request, $changeHistory = true) { return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), $request->getFiles(), $request->getServer(), $request->getContent(), $changeHistory); } + + private function updateServerFromUri($server, $uri) + { + $server['HTTP_HOST'] = $this->extractHost($uri); + $scheme = parse_url($uri, PHP_URL_SCHEME); + $server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme; + unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']); + + return $server; + } + + private function extractHost($uri) + { + $host = parse_url($uri, PHP_URL_HOST); + + if ($port = parse_url($uri, PHP_URL_PORT)) { + return $host.':'.$port; + } + + return $host; + } } diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Cookie.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Cookie.php index b4c3385..b8d9dff 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Cookie.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Cookie.php @@ -48,32 +48,32 @@ class Cookie /** * Sets a cookie. * - * @param string $name The cookie name - * @param string $value The value of the cookie - * @param string $expires The time the cookie expires - * @param string $path The path on the server in which the cookie will be available on - * @param string $domain The domain that the cookie is available - * @param Boolean $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client - * @param Boolean $httponly The cookie httponly flag - * @param Boolean $encodedValue Whether the value is encoded or not + * @param string $name The cookie name + * @param string $value The value of the cookie + * @param string $expires The time the cookie expires + * @param string $path The path on the server in which the cookie will be available on + * @param string $domain The domain that the cookie is available + * @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client + * @param bool $httponly The cookie httponly flag + * @param bool $encodedValue Whether the value is encoded or not * * @api */ public function __construct($name, $value, $expires = null, $path = null, $domain = '', $secure = false, $httponly = true, $encodedValue = false) { if ($encodedValue) { - $this->value = urldecode($value); + $this->value = urldecode($value); $this->rawValue = $value; } else { - $this->value = $value; + $this->value = $value; $this->rawValue = urlencode($value); } - $this->name = $name; - $this->expires = null === $expires ? null : (integer) $expires; - $this->path = empty($path) ? '/' : $path; - $this->domain = $domain; - $this->secure = (Boolean) $secure; - $this->httponly = (Boolean) $httponly; + $this->name = $name; + $this->expires = null === $expires ? null : (int) $expires; + $this->path = empty($path) ? '/' : $path; + $this->domain = $domain; + $this->secure = (bool) $secure; + $this->httponly = (bool) $httponly; } /** @@ -81,6 +81,8 @@ public function __construct($name, $value, $expires = null, $path = null, $domai * * @return string The HTTP representation of the Cookie * + * @throws \UnexpectedValueException + * * @api */ public function __toString() @@ -88,14 +90,20 @@ public function __toString() $cookie = sprintf('%s=%s', $this->name, $this->rawValue); if (null !== $this->expires) { - $cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('GMT'))->format(self::$dateFormats[0]), 0, -5); + $dateTime = \DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('GMT')); + + if ($dateTime === false) { + throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.'), $this->expires); + } + + $cookie .= '; expires='.str_replace('+0000', '', $dateTime->format(self::$dateFormats[0])); } if ('' !== $this->domain) { $cookie .= '; domain='.$this->domain; } - if ('/' !== $this->path) { + if ($this->path) { $cookie .= '; path='.$this->path; } @@ -127,30 +135,29 @@ public static function fromString($cookie, $url = null) $parts = explode(';', $cookie); if (false === strpos($parts[0], '=')) { - throw new \InvalidArgumentException('The cookie string "%s" is not valid.'); + throw new \InvalidArgumentException(sprintf('The cookie string "%s" is not valid.', $parts[0])); } list($name, $value) = explode('=', array_shift($parts), 2); $values = array( - 'name' => trim($name), - 'value' => trim($value), - 'expires' => null, - 'path' => '/', - 'domain' => '', - 'secure' => false, + 'name' => trim($name), + 'value' => trim($value), + 'expires' => null, + 'path' => '/', + 'domain' => '', + 'secure' => false, 'httponly' => false, 'passedRawValue' => true, ); if (null !== $url) { - if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host']) || !isset($urlParts['path'])) { + if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) { throw new \InvalidArgumentException(sprintf('The URL "%s" is not valid.', $url)); } - $parts = array_merge($urlParts, $parts); - $values['domain'] = $parts['host']; - $values['path'] = substr($parts['path'], 0, strrpos($parts['path'], '/')); + $values['domain'] = $urlParts['host']; + $values['path'] = isset($urlParts['path']) ? substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')) : ''; } foreach ($parts as $part) { @@ -197,7 +204,7 @@ public static function fromString($cookie, $url = null) private static function parseDate($dateValue) { // trim single quotes around date if present - if (($length = strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length-1]) { + if (($length = strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) { $dateValue = substr($dateValue, 1, -1); } @@ -290,7 +297,7 @@ public function getDomain() /** * Returns the secure flag of the cookie. * - * @return Boolean The cookie secure flag + * @return bool The cookie secure flag * * @api */ @@ -302,7 +309,7 @@ public function isSecure() /** * Returns the httponly flag of the cookie. * - * @return Boolean The cookie httponly flag + * @return bool The cookie httponly flag * * @api */ @@ -314,7 +321,7 @@ public function isHttpOnly() /** * Returns true if the cookie has expired. * - * @return Boolean true if the cookie has expired, false otherwise + * @return bool true if the cookie has expired, false otherwise * * @api */ diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CookieJar.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CookieJar.php index 0f115f8..1a36818 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CookieJar.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CookieJar.php @@ -37,6 +37,11 @@ public function set(Cookie $cookie) /** * Gets a cookie by name. * + * You should never use an empty domain, but if you do so, + * this method returns the first cookie for the given name/path + * (this behavior ensures a BC behavior with previous versions of + * Symfony). + * * @param string $name The cookie name * @param string $path The cookie path * @param string $domain The cookie domain @@ -49,12 +54,43 @@ public function get($name, $path = '/', $domain = null) { $this->flushExpiredCookies(); - return isset($this->cookieJar[$domain][$path][$name]) ? $this->cookieJar[$domain][$path][$name] : null; + if (!empty($domain)) { + foreach ($this->cookieJar as $cookieDomain => $pathCookies) { + if ($cookieDomain) { + $cookieDomain = '.'.ltrim($cookieDomain, '.'); + if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) { + continue; + } + } + + foreach ($pathCookies as $cookiePath => $namedCookies) { + if ($cookiePath != substr($path, 0, strlen($cookiePath))) { + continue; + } + if (isset($namedCookies[$name])) { + return $namedCookies[$name]; + } + } + } + + return; + } + + // avoid relying on this behavior that is mainly here for BC reasons + foreach ($this->cookieJar as $cookies) { + if (isset($cookies[$path][$name])) { + return $cookies[$path][$name]; + } + } } /** * Removes a cookie by name. * + * You should never use an empty domain, but if you do so, + * all cookies for the given name/path expire (this behavior + * ensures a BC behavior with previous versions of Symfony). + * * @param string $name The cookie name * @param string $path The cookie path * @param string $domain The cookie domain @@ -67,13 +103,23 @@ public function expire($name, $path = '/', $domain = null) $path = '/'; } - unset($this->cookieJar[$domain][$path][$name]); + if (empty($domain)) { + // an empty domain means any domain + // this should never happen but it allows for a better BC + $domains = array_keys($this->cookieJar); + } else { + $domains = array($domain); + } + + foreach ($domains as $domain) { + unset($this->cookieJar[$domain][$path][$name]); - if (empty($this->cookieJar[$domain][$path])) { - unset($this->cookieJar[$domain][$path]); + if (empty($this->cookieJar[$domain][$path])) { + unset($this->cookieJar[$domain][$path]); - if (empty($this->cookieJar[$domain])) { - unset($this->cookieJar[$domain]); + if (empty($this->cookieJar[$domain])) { + unset($this->cookieJar[$domain]); + } } } } @@ -152,8 +198,8 @@ public function all() /** * Returns not yet expired cookie values for the given URI. * - * @param string $uri A URI - * @param Boolean $returnsRawValue Returns raw value or urldecoded value + * @param string $uri A URI + * @param bool $returnsRawValue Returns raw value or urldecoded value * * @return array An array of cookie values */ @@ -165,8 +211,8 @@ public function allValues($uri, $returnsRawValue = false) $cookies = array(); foreach ($this->cookieJar as $domain => $pathCookies) { if ($domain) { - $domain = ltrim($domain, '.'); - if ($domain != substr($parts['host'], -strlen($domain))) { + $domain = '.'.ltrim($domain, '.'); + if ($domain != substr('.'.$parts['host'], -strlen($domain))) { continue; } } diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/History.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/History.php index a22847e..8e38fe5 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/History.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/History.php @@ -21,14 +21,6 @@ class History protected $stack = array(); protected $position = -1; - /** - * Constructor. - */ - public function __construct() - { - $this->clear(); - } - /** * Clears the history. */ @@ -53,7 +45,7 @@ public function add(Request $request) /** * Returns true if the history is empty. * - * @return Boolean true if the history is empty, false otherwise + * @return bool true if the history is empty, false otherwise */ public function isEmpty() { diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/LICENSE b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/LICENSE index 88a57f8..43028bc 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/LICENSE +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +Copyright (c) 2004-2015 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/README.md b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/README.md index da19188..3c0ee3a 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/README.md +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/README.md @@ -19,5 +19,5 @@ provided by the HttpKernel component. You can run the unit tests with the following command: $ cd path/to/Symfony/Component/BrowserKit/ - $ composer.phar install --dev + $ composer install $ phpunit diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Response.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Response.php index 182fdda..7a7130b 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Response.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Response.php @@ -30,16 +30,16 @@ class Response * The headers array is a set of key/value pairs. If a header is present multiple times * then the value is an array of all the values. * - * @param string $content The content of the response - * @param integer $status The response status code - * @param array $headers An array of headers + * @param string $content The content of the response + * @param int $status The response status code + * @param array $headers An array of headers * * @api */ public function __construct($content = '', $status = 200, array $headers = array()) { $this->content = $content; - $this->status = $status; + $this->status = $status; $this->headers = $headers; } @@ -92,7 +92,7 @@ public function getContent() /** * Gets the response status code. * - * @return integer The response status code + * @return int The response status code * * @api */ @@ -116,15 +116,16 @@ public function getHeaders() /** * Gets a response header. * - * @param string $header The header name - * @param Boolean $first Whether to return the first value or all header values + * @param string $header The header name + * @param bool $first Whether to return the first value or all header values * * @return string|array The first header value if $first is true, an array of values otherwise */ public function getHeader($header, $first = true) { + $normalizedHeader = str_replace('-', '_', strtolower($header)); foreach ($this->headers as $key => $value) { - if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header))) { + if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) { if ($first) { return is_array($value) ? (count($value) ? $value[0] : '') : $value; } diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ClientTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ClientTest.php index 32a3889..a6e5ba9 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -14,9 +14,12 @@ use Symfony\Component\BrowserKit\Client; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\CookieJar; -use Symfony\Component\BrowserKit\Request; use Symfony\Component\BrowserKit\Response; +class SpecialResponse extends Response +{ +} + class TestClient extends Client { protected $nextResponse = null; @@ -44,6 +47,15 @@ protected function doRequest($request) return $response; } + protected function filterResponse($response) + { + if ($response instanceof SpecialResponse) { + return new Response($response->getContent(), $response->getStatus(), $response->getHeaders()); + } + + return $response; + } + protected function getScript($request) { $r = new \ReflectionClass('Symfony\Component\BrowserKit\Response'); @@ -90,9 +102,14 @@ public function testGetRequest() $this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request'); } - /** - * @covers Symfony\Component\BrowserKit\Client::getResponse - */ + public function testGetRequestWithIpAsHost() + { + $client = new TestClient(); + $client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1')); + + $this->assertEquals('https://127.0.0.1/foo', $client->getRequest()->getUri()); + } + public function testGetResponse() { $client = new TestClient(); @@ -100,6 +117,18 @@ public function testGetResponse() $client->request('GET', 'http://example.com/'); $this->assertEquals('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request'); + $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request'); + } + + public function testGetInternalResponse() + { + $client = new TestClient(); + $client->setNextResponse(new SpecialResponse('foo')); + $client->request('GET', 'http://example.com/'); + + $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse()); + $this->assertNotInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getInternalResponse()); + $this->assertInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getResponse()); } public function testGetContent() @@ -138,6 +167,11 @@ public function testRequestHttpHeaders() $client->request('GET', 'https://www.example.com'); $headers = $client->getRequest()->getServer(); $this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com:8080'); + $headers = $client->getRequest()->getServer(); + $this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port'); } public function testRequestURIConversion() @@ -175,6 +209,24 @@ public function testRequestURIConversion() $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); } + public function testRequestURIConversionByServerHost() + { + $client = new TestClient(); + + $server = array('HTTP_HOST' => 'www.exampl+e.com:8000'); + $parameters = array(); + $files = array(); + + $client->request('GET', 'http://exampl+e.com', $parameters, $files, $server); + $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to add port'); + + $client->request('GET', 'http://exampl+e.com:8888', $parameters, $files, $server); + $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to modify existing port'); + + $client->request('GET', 'http://exampl+e.com:8000', $parameters, $files, $server); + $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST respects correct set port'); + } + public function testRequestReferer() { $client = new TestClient(); @@ -205,16 +257,17 @@ public function testRequestCookies() $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); } - public function testClick() + public function testRequestSecureCookies() { - if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { - $this->markTestSkipped('The "DomCrawler" component is not available'); - } + $client = new TestClient(); + $client->setNextResponse(new Response('foo', 200, array('Set-Cookie' => 'foo=bar; path=/; secure'))); + $client->request('GET', 'https://www.example.com/foo/foobar'); - if (!class_exists('Symfony\Component\CssSelector\CssSelector')) { - $this->markTestSkipped('The "CssSelector" component is not available'); - } + $this->assertTrue($client->getCookieJar()->get('foo', '/', 'www.example.com')->isSecure()); + } + public function testClick() + { $client = new TestClient(); $client->setNextResponse(new Response('foo')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); @@ -226,14 +279,6 @@ public function testClick() public function testClickForm() { - if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { - $this->markTestSkipped('The "DomCrawler" component is not available'); - } - - if (!class_exists('Symfony\Component\CssSelector\CssSelector')) { - $this->markTestSkipped('The "CssSelector" component is not available'); - } - $client = new TestClient(); $client->setNextResponse(new Response('
')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); @@ -245,14 +290,6 @@ public function testClickForm() public function testSubmit() { - if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { - $this->markTestSkipped('The "DomCrawler" component is not available'); - } - - if (!class_exists('Symfony\Component\CssSelector\CssSelector')) { - $this->markTestSkipped('The "CssSelector" component is not available'); - } - $client = new TestClient(); $client->setNextResponse(new Response('
')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); @@ -264,14 +301,6 @@ public function testSubmit() public function testSubmitPreserveAuth() { - if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { - $this->markTestSkipped('The "DomCrawler" component is not available'); - } - - if (!class_exists('Symfony\Component\CssSelector\CssSelector')) { - $this->markTestSkipped('The "CssSelector" component is not available'); - } - $client = new TestClient(array('PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar')); $client->setNextResponse(new Response('
')); $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); @@ -317,6 +346,76 @@ public function testFollowRedirect() $client->request('GET', 'http://www.example.com/foo/foobar'); $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected'))); + $client->followRedirects(false); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + try { + $client->followRedirect(); + $this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); + } catch (\Exception $e) { + $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); + } + } + + public function testFollowRelativeRedirect() + { + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => '/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => '/redirected:1234'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls'); + } + + public function testFollowRedirectWithMaxRedirects() + { + $client = new TestClient(); + $client->setMaxRedirects(1); + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected2'))); + try { + $client->followRedirect(); + $this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); + } catch (\Exception $e) { + $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); + } + + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + + $client->setNextResponse(new Response('', 302, array('Location' => '/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => '//www.example.org/'))); + $client->request('GET', 'https://www.example.com/'); + + $this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->request('POST', 'http://www.example.com/foo/foobar', array('name' => 'bar')); + + $this->assertEquals('get', $client->getRequest()->getMethod(), '->followRedirect() uses a get for 302'); + $this->assertEquals(array(), $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method'); } public function testFollowRedirectWithCookies() @@ -324,7 +423,7 @@ public function testFollowRedirectWithCookies() $client = new TestClient(); $client->followRedirects(false); $client->setNextResponse(new Response('', 302, array( - 'Location' => 'http://www.example.com/redirected', + 'Location' => 'http://www.example.com/redirected', 'Set-Cookie' => 'foo=bar', ))); $client->request('GET', 'http://www.example.com/'); @@ -333,6 +432,51 @@ public function testFollowRedirectWithCookies() $this->assertEquals(array('foo' => 'bar'), $client->getRequest()->getCookies()); } + public function testFollowRedirectWithHeaders() + { + $headers = array( + 'HTTP_HOST' => 'www.example.com', + 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', + 'CONTENT_TYPE' => 'application/vnd.custom+xml', + 'HTTPS' => false, + ); + + $client = new TestClient(); + $client->followRedirects(false); + $client->setNextResponse(new Response('', 302, array( + 'Location' => 'http://www.example.com/redirected', + ))); + $client->request('GET', 'http://www.example.com/', array(), array(), array( + 'CONTENT_TYPE' => 'application/vnd.custom+xml', + )); + + $this->assertEquals($headers, $client->getRequest()->getServer()); + + $client->followRedirect(); + + $headers['HTTP_REFERER'] = 'http://www.example.com/'; + + $this->assertEquals($headers, $client->getRequest()->getServer()); + } + + public function testFollowRedirectWithPort() + { + $headers = array( + 'HTTP_HOST' => 'www.example.com:8080', + 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', + 'HTTPS' => false, + 'HTTP_REFERER' => 'http://www.example.com:8080/', + ); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array( + 'Location' => 'http://www.example.com:8080/redirected', + ))); + $client->request('GET', 'http://www.example.com:8080/'); + + $this->assertEquals($headers, $client->getRequest()->getServer()); + } + public function testBack() { $client = new TestClient(); @@ -405,10 +549,6 @@ public function testRestart() public function testInsulatedRequests() { - if (!class_exists('Symfony\Component\Process\Process')) { - $this->markTestSkipped('The "Process" component is not available'); - } - $client = new TestClient(); $client->insulate(); $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar')"); @@ -447,4 +587,38 @@ public function testSetServerParameter() $client->setServerParameter('HTTP_USER_AGENT', 'testua'); $this->assertEquals('testua', $client->getServerParameter('HTTP_USER_AGENT')); } + + public function testSetServerParameterInRequest() + { + $client = new TestClient(); + + $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + + $client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array( + 'HTTP_HOST' => 'testhost', + 'HTTP_USER_AGENT' => 'testua', + 'HTTPS' => false, + 'NEW_SERVER_KEY' => 'new-server-key-value', + )); + + $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + + $this->assertEquals('http://testhost/https/www.example.com', $client->getRequest()->getUri()); + + $server = $client->getRequest()->getServer(); + + $this->assertArrayHasKey('HTTP_USER_AGENT', $server); + $this->assertEquals('testua', $server['HTTP_USER_AGENT']); + + $this->assertArrayHasKey('HTTP_HOST', $server); + $this->assertEquals('testhost', $server['HTTP_HOST']); + + $this->assertArrayHasKey('NEW_SERVER_KEY', $server); + $this->assertEquals('new-server-key-value', $server['NEW_SERVER_KEY']); + + $this->assertArrayHasKey('HTTPS', $server); + $this->assertFalse($server['HTTPS']); + } } diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieJarTest.php index bdbd40e..4da4404 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieJarTest.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -195,4 +195,37 @@ public function testCookieWithSameNameButDifferentDomains() $this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://foo.example.com/')); $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://bar.example.com/')); } + + public function testCookieGetWithSubdomain() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/', '.example.com')); + $cookieJar->set($cookie2 = new Cookie('foo1', 'bar', null, '/', 'test.example.com')); + + $this->assertEquals($cookie1, $cookieJar->get('foo', '/', 'foo.example.com')); + $this->assertEquals($cookie1, $cookieJar->get('foo', '/', 'example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'test.example.com')); + } + + public function testCookieGetWithSubdirectory() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/test', '.example.com')); + $cookieJar->set($cookie2 = new Cookie('foo1', 'bar1', null, '/', '.example.com')); + + $this->assertNull($cookieJar->get('foo', '/', '.example.com')); + $this->assertNull($cookieJar->get('foo', '/bar', '.example.com')); + $this->assertEquals($cookie1, $cookieJar->get('foo', '/test', 'example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1', '/bar', 'example.com')); + } + + public function testCookieWithWildcardDomain() + { + $cookieJar = new CookieJar(); + $cookieJar->set(new Cookie('foo', 'bar', null, '/', '.example.com')); + + $this->assertEquals(array('foo' => 'bar'), $cookieJar->allValues('http://www.example.com')); + $this->assertEmpty($cookieJar->allValues('http://wwwexample.com')); + } } diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieTest.php index be53eea..8e3578a 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -26,14 +26,14 @@ public function testToFromString($cookie, $url = null) public function getTestsForToFromString() { return array( - array('foo=bar'), + array('foo=bar; path=/'), array('foo=bar; path=/foo'), - array('foo=bar; domain=google.com'), - array('foo=bar; domain=example.com; secure', 'https://example.com/'), - array('foo=bar; httponly'), + array('foo=bar; domain=google.com; path=/'), + array('foo=bar; domain=example.com; path=/; secure', 'https://example.com/'), + array('foo=bar; path=/; httponly'), array('foo=bar; domain=google.com; path=/foo; secure; httponly', 'https://google.com/'), - array('foo=bar=baz'), - array('foo=bar%3Dbaz'), + array('foo=bar=baz; path=/'), + array('foo=bar%3Dbaz; path=/'), ); } @@ -67,17 +67,19 @@ public function getExpireCookieStrings() public function testFromStringWithCapitalization() { - $this->assertEquals('Foo=Bar', (string) Cookie::fromString('Foo=Bar')); - $this->assertEquals('foo=bar; expires=Fri, 31 Dec 2010 23:59:59 GMT', (string) Cookie::fromString('foo=bar; Expires=Fri, 31 Dec 2010 23:59:59 GMT')); - $this->assertEquals('foo=bar; domain=www.example.org; httponly', (string) Cookie::fromString('foo=bar; DOMAIN=www.example.org; HttpOnly')); + $this->assertEquals('Foo=Bar; path=/', (string) Cookie::fromString('Foo=Bar')); + $this->assertEquals('foo=bar; expires=Fri, 31 Dec 2010 23:59:59 GMT; path=/', (string) Cookie::fromString('foo=bar; Expires=Fri, 31 Dec 2010 23:59:59 GMT')); + $this->assertEquals('foo=bar; domain=www.example.org; path=/; httponly', (string) Cookie::fromString('foo=bar; DOMAIN=www.example.org; HttpOnly')); } public function testFromStringWithUrl() { - $this->assertEquals('foo=bar; domain=www.example.com', (string) Cookie::FromString('foo=bar', 'http://www.example.com/')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com/')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com?foo')); $this->assertEquals('foo=bar; domain=www.example.com; path=/foo', (string) Cookie::FromString('foo=bar', 'http://www.example.com/foo/bar')); - $this->assertEquals('foo=bar; domain=www.example.com', (string) Cookie::FromString('foo=bar; path=/', 'http://www.example.com/foo/bar')); - $this->assertEquals('foo=bar; domain=www.myotherexample.com', (string) Cookie::FromString('foo=bar; domain=www.myotherexample.com', 'http://www.example.com/')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar; path=/', 'http://www.example.com/foo/bar')); + $this->assertEquals('foo=bar; domain=www.myotherexample.com; path=/', (string) Cookie::FromString('foo=bar; domain=www.myotherexample.com', 'http://www.example.com/')); } public function testFromStringThrowsAnExceptionIfCookieIsNotValid() diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ResponseTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ResponseTest.php index 878752c..bfe3cd5 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ResponseTest.php +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ResponseTest.php @@ -37,7 +37,7 @@ public function testGetHeader() { $response = new Response('foo', 200, array( 'Content-Type' => 'text/html', - 'Set-Cookie' => array('foo=bar', 'bar=foo'), + 'Set-Cookie' => array('foo=bar', 'bar=foo'), )); $this->assertEquals('text/html', $response->getHeader('Content-Type'), '->getHeader() returns a header of the response'); @@ -61,13 +61,13 @@ public function testMagicToStringWithMultipleSetCookieHeader() { $headers = array( 'content-type' => 'text/html; charset=utf-8', - 'set-cookie' => array('foo=bar', 'bar=foo') + 'set-cookie' => array('foo=bar', 'bar=foo'), ); $expected = 'content-type: text/html; charset=utf-8'."\n"; - $expected.= 'set-cookie: foo=bar'."\n"; - $expected.= 'set-cookie: bar=foo'."\n\n"; - $expected.= 'foo'; + $expected .= 'set-cookie: foo=bar'."\n"; + $expected .= 'set-cookie: bar=foo'."\n\n"; + $expected .= 'foo'; $response = new Response('foo', 304, $headers); diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/composer.json b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/composer.json index c237db4..4c98b0a 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/composer.json +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/composer.json @@ -17,14 +17,15 @@ ], "require": { "php": ">=5.3.3", - "symfony/dom-crawler": "~2.0" + "symfony/dom-crawler": "~2.0,>=2.0.5" }, "require-dev": { - "symfony/process": "~2.0", - "symfony/css-selector": "~2.0" + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.0,>=2.0.5", + "symfony/css-selector": "~2.0,>=2.0.5" }, "suggest": { - "symfony/process": "2.2.*" + "symfony/process": "" }, "autoload": { "psr-0": { "Symfony\\Component\\BrowserKit\\": "" } @@ -33,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } } } diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/phpunit.xml.dist b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/phpunit.xml.dist index 8dff1ea..d6ca28b 100644 --- a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/phpunit.xml.dist +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/phpunit.xml.dist @@ -1,16 +1,14 @@ - + + + ./Tests/ diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/.gitignore b/vendor/symfony/css-selector/Symfony/Component/CssSelector/.gitignore index 44de97a..c49a5d8 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/.gitignore +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/.gitignore @@ -1,4 +1,3 @@ vendor/ composer.lock phpunit.xml - diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php index f624fff..82c9283 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php @@ -11,7 +11,12 @@ namespace Symfony\Component\CssSelector; -use Symfony\Component\CssSelector\Exception\ParseException; +use Symfony\Component\CssSelector\Parser\Shortcut\ClassParser; +use Symfony\Component\CssSelector\Parser\Shortcut\ElementParser; +use Symfony\Component\CssSelector\Parser\Shortcut\EmptyStringParser; +use Symfony\Component\CssSelector\Parser\Shortcut\HashParser; +use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension; +use Symfony\Component\CssSelector\XPath\Translator; /** * CssSelector is the main entry point of the component and can convert CSS @@ -19,8 +24,41 @@ * * $xpath = CssSelector::toXpath('h1.foo'); * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * Copyright (c) 2007-2012 Ian Bicking and contributors. See AUTHORS + * for more details. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. Neither the name of Ian Bicking nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * 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 IAN BICKING 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. * * @author Fabien Potencier * @@ -28,6 +66,8 @@ */ class CssSelector { + private static $html = true; + /** * Translates a CSS expression to its XPath equivalent. * Optionally, a prefix can be added to the resulting XPath @@ -38,285 +78,39 @@ class CssSelector * * @return string * - * @throws ParseException When got None for xpath expression - * * @api */ public static function toXPath($cssExpr, $prefix = 'descendant-or-self::') { - if (is_string($cssExpr)) { - if (!$cssExpr) { - return $prefix.'*'; - } - - if (preg_match('#^\w+\s*$#u', $cssExpr, $match)) { - return $prefix.trim($match[0]); - } - - if (preg_match('~^(\w*)#(\w+)\s*$~u', $cssExpr, $match)) { - return sprintf("%s%s[@id = '%s']", $prefix, $match[1] ? $match[1] : '*', $match[2]); - } - - if (preg_match('#^(\w*)\.(\w+)\s*$#u', $cssExpr, $match)) { - return sprintf("%s%s[contains(concat(' ', normalize-space(@class), ' '), ' %s ')]", $prefix, $match[1] ? $match[1] : '*', $match[2]); - } - - $parser = new self(); - $cssExpr = $parser->parse($cssExpr); - } - - $expr = $cssExpr->toXpath(); - - // @codeCoverageIgnoreStart - if (!$expr) { - throw new ParseException(sprintf('Got None for xpath expression from %s.', $cssExpr)); - } - // @codeCoverageIgnoreEnd - - if ($prefix) { - $expr->addPrefix($prefix); - } - - return (string) $expr; - } - - /** - * Parses an expression and returns the Node object that represents - * the parsed expression. - * - * @param string $string The expression to parse - * - * @return Node\NodeInterface - * - * @throws \Exception When tokenizer throws it while parsing - */ - public function parse($string) - { - $tokenizer = new Tokenizer(); - - $stream = new TokenStream($tokenizer->tokenize($string), $string); - - try { - return $this->parseSelectorGroup($stream); - } catch (\Exception $e) { - $class = get_class($e); - - throw new $class(sprintf('%s at %s -> %s', $e->getMessage(), implode($stream->getUsed(), ''), $stream->peek()), 0, $e); - } - } - - /** - * Parses a selector group contained in $stream and returns - * the Node object that represents the expression. - * - * @param TokenStream $stream The stream to parse. - * - * @return Node\NodeInterface - */ - private function parseSelectorGroup($stream) - { - $result = array(); - while (true) { - $result[] = $this->parseSelector($stream); - if ($stream->peek() == ',') { - $stream->next(); - } else { - break; - } - } + $translator = new Translator(); - if (count($result) == 1) { - return $result[0]; + if (self::$html) { + $translator->registerExtension(new HtmlExtension($translator)); } - return new Node\OrNode($result); - } - - /** - * Parses a selector contained in $stream and returns the Node - * object that represents it. - * - * @param TokenStream $stream The stream containing the selector. - * - * @return Node\NodeInterface - * - * @throws ParseException When expected selector but got something else - */ - private function parseSelector($stream) - { - $result = $this->parseSimpleSelector($stream); - - while (true) { - $peek = $stream->peek(); - if (',' == $peek || null === $peek) { - return $result; - } elseif (in_array($peek, array('+', '>', '~'))) { - // A combinator - $combinator = (string) $stream->next(); + $translator + ->registerParserShortcut(new EmptyStringParser()) + ->registerParserShortcut(new ElementParser()) + ->registerParserShortcut(new ClassParser()) + ->registerParserShortcut(new HashParser()) + ; - // Ignore optional whitespace after a combinator - while (' ' == $stream->peek()) { - $stream->next(); - } - } else { - $combinator = ' '; - } - $consumed = count($stream->getUsed()); - $nextSelector = $this->parseSimpleSelector($stream); - if ($consumed == count($stream->getUsed())) { - throw new ParseException(sprintf("Expected selector, got '%s'", $stream->peek())); - } - - $result = new Node\CombinedSelectorNode($result, $combinator, $nextSelector); - } - - return $result; + return $translator->cssToXPath($cssExpr, $prefix); } /** - * Parses a simple selector (the current token) from $stream and returns - * the resulting Node object. - * - * @param TokenStream $stream The stream containing the selector. - * - * @return Node\NodeInterface - * - * @throws ParseException When expected symbol but got something else + * Enables the HTML extension. */ - private function parseSimpleSelector($stream) + public static function enableHtmlExtension() { - $peek = $stream->peek(); - if ('*' != $peek && !$peek->isType('Symbol')) { - $element = $namespace = '*'; - } else { - $next = $stream->next(); - if ('*' != $next && !$next->isType('Symbol')) { - throw new ParseException(sprintf("Expected symbol, got '%s'", $next)); - } - - if ($stream->peek() == '|') { - $namespace = $next; - $stream->next(); - $element = $stream->next(); - if ('*' != $element && !$next->isType('Symbol')) { - throw new ParseException(sprintf("Expected symbol, got '%s'", $next)); - } - } else { - $namespace = '*'; - $element = $next; - } - } - - $result = new Node\ElementNode($namespace, $element); - $hasHash = false; - while (true) { - $peek = $stream->peek(); - if ('#' == $peek) { - if ($hasHash) { - /* You can't have two hashes - (FIXME: is there some more general rule I'm missing?) */ - // @codeCoverageIgnoreStart - break; - // @codeCoverageIgnoreEnd - } - $stream->next(); - $result = new Node\HashNode($result, $stream->next()); - $hasHash = true; - - continue; - } elseif ('.' == $peek) { - $stream->next(); - $result = new Node\ClassNode($result, $stream->next()); - - continue; - } elseif ('[' == $peek) { - $stream->next(); - $result = $this->parseAttrib($result, $stream); - $next = $stream->next(); - if (']' != $next) { - throw new ParseException(sprintf("] expected, got '%s'", $next)); - } - - continue; - } elseif (':' == $peek || '::' == $peek) { - $type = $stream->next(); - $ident = $stream->next(); - if (!$ident || !$ident->isType('Symbol')) { - throw new ParseException(sprintf("Expected symbol, got '%s'", $ident)); - } - - if ($stream->peek() == '(') { - $stream->next(); - $peek = $stream->peek(); - if ($peek->isType('String')) { - $selector = $stream->next(); - } elseif ($peek->isType('Symbol') && is_int($peek)) { - $selector = intval($stream->next()); - } else { - // FIXME: parseSimpleSelector, or selector, or...? - $selector = $this->parseSimpleSelector($stream); - } - $next = $stream->next(); - if (')' != $next) { - throw new ParseException(sprintf("Expected ')', got '%s' and '%s'", $next, $selector)); - } - - $result = new Node\FunctionNode($result, $type, $ident, $selector); - } else { - $result = new Node\PseudoNode($result, $type, $ident); - } - - continue; - } else { - if (' ' == $peek) { - $stream->next(); - } - - break; - } - // FIXME: not sure what "negation" is - } - - return $result; + self::$html = true; } /** - * Parses an attribute from a selector contained in $stream and returns - * the resulting AttribNode object. - * - * @param Node\NodeInterface $selector The selector object whose attribute - * is to be parsed. - * @param TokenStream $stream The container token stream. - * - * @return Node\AttribNode - * - * @throws ParseException When encountered unexpected selector + * Disables the HTML extension. */ - private function parseAttrib($selector, $stream) + public static function disableHtmlExtension() { - $attrib = $stream->next(); - if ($stream->peek() == '|') { - $namespace = $attrib; - $stream->next(); - $attrib = $stream->next(); - } else { - $namespace = '*'; - } - - if ($stream->peek() == ']') { - return new Node\AttribNode($selector, $namespace, $attrib, 'exists', null); - } - - $op = $stream->next(); - if (!in_array($op, array('^=', '$=', '*=', '=', '~=', '|=', '!='))) { - throw new ParseException(sprintf("Operator expected, got '%s'", $op)); - } - - $value = $stream->next(); - if (!$value->isType('Symbol') && !$value->isType('String')) { - throw new ParseException(sprintf("Expected string or symbol, got '%s'", $value)); - } - - return new Node\AttribNode($selector, $namespace, $attrib, $op, $value); + self::$html = false; } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExceptionInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExceptionInterface.php new file mode 100644 index 0000000..e4c5ae1 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExceptionInterface.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +/** + * Interface for exceptions. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface ExceptionInterface +{ +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExpressionErrorException.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExpressionErrorException.php new file mode 100644 index 0000000..fd5deea --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExpressionErrorException.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +/** + * ParseException is thrown when a CSS selector syntax is not valid. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class ExpressionErrorException extends ParseException +{ +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/InternalErrorException.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/InternalErrorException.php new file mode 100644 index 0000000..e60e5ed --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/InternalErrorException.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +/** + * ParseException is thrown when a CSS selector syntax is not valid. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class InternalErrorException extends ParseException +{ +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ParseException.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ParseException.php index 38206c2..3b0b0ee 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ParseException.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ParseException.php @@ -14,11 +14,11 @@ /** * ParseException is thrown when a CSS selector syntax is not valid. * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. * * @author Fabien Potencier */ -class ParseException extends \Exception +class ParseException extends \Exception implements ExceptionInterface { } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php new file mode 100644 index 0000000..418bc30 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +use Symfony\Component\CssSelector\Parser\Token; + +/** + * ParseException is thrown when a CSS selector syntax is not valid. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class SyntaxErrorException extends ParseException +{ + /** + * @param string $expectedValue + * @param Token $foundToken + * + * @return SyntaxErrorException + */ + public static function unexpectedToken($expectedValue, Token $foundToken) + { + return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken)); + } + + /** + * @param string $pseudoElement + * @param string $unexpectedLocation + * + * @return SyntaxErrorException + */ + public static function pseudoElementFound($pseudoElement, $unexpectedLocation) + { + return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation)); + } + + /** + * @param int $position + * + * @return SyntaxErrorException + */ + public static function unclosedString($position) + { + return new self(sprintf('Unclosed/invalid string at %s.', $position)); + } + + /** + * @return SyntaxErrorException + */ + public static function nestedNot() + { + return new self('Got nested ::not().'); + } + + /** + * @return SyntaxErrorException + */ + public static function stringAsFunctionArgument() + { + return new self('String not allowed as function argument.'); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE b/vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE index 88a57f8..43028bc 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +Copyright (c) 2004-2015 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AbstractNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AbstractNode.php new file mode 100644 index 0000000..b1c8e95 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AbstractNode.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Abstract base node class. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +abstract class AbstractNode implements NodeInterface +{ + /** + * @var string + */ + private $nodeName; + + /** + * @return string + */ + public function getNodeName() + { + if (null === $this->nodeName) { + $this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', get_called_class()); + } + + return $this->nodeName; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttribNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttribNode.php deleted file mode 100644 index b89606e..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttribNode.php +++ /dev/null @@ -1,131 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector\Node; - -use Symfony\Component\CssSelector\XPathExpr; -use Symfony\Component\CssSelector\Exception\ParseException; - -/** - * AttribNode represents a "selector[namespace|attrib operator value]" node. - * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. - * - * @author Fabien Potencier - */ -class AttribNode implements NodeInterface -{ - protected $selector; - protected $namespace; - protected $attrib; - protected $operator; - protected $value; - - /** - * Constructor. - * - * @param NodeInterface $selector The XPath selector - * @param string $namespace The namespace - * @param string $attrib The attribute - * @param string $operator The operator - * @param string $value The value - */ - public function __construct($selector, $namespace, $attrib, $operator, $value) - { - $this->selector = $selector; - $this->namespace = $namespace; - $this->attrib = $attrib; - $this->operator = $operator; - $this->value = $value; - } - - /** - * {@inheritDoc} - */ - public function __toString() - { - if ($this->operator == 'exists') { - return sprintf('%s[%s[%s]]', __CLASS__, $this->selector, $this->formatAttrib()); - } - - return sprintf('%s[%s[%s %s %s]]', __CLASS__, $this->selector, $this->formatAttrib(), $this->operator, $this->value); - } - - /** - * {@inheritDoc} - */ - public function toXpath() - { - $path = $this->selector->toXpath(); - $attrib = $this->xpathAttrib(); - $value = $this->value; - if ($this->operator == 'exists') { - $path->addCondition($attrib); - } elseif ($this->operator == '=') { - $path->addCondition(sprintf('%s = %s', $attrib, XPathExpr::xpathLiteral($value))); - } elseif ($this->operator == '!=') { - // FIXME: this seems like a weird hack... - if ($value) { - $path->addCondition(sprintf('not(%s) or %s != %s', $attrib, $attrib, XPathExpr::xpathLiteral($value))); - } else { - $path->addCondition(sprintf('%s != %s', $attrib, XPathExpr::xpathLiteral($value))); - } - // path.addCondition('%s != %s' % (attrib, xpathLiteral(value))) - } elseif ($this->operator == '~=') { - $path->addCondition(sprintf("contains(concat(' ', normalize-space(%s), ' '), %s)", $attrib, XPathExpr::xpathLiteral(' '.$value.' '))); - } elseif ($this->operator == '|=') { - // Weird, but true... - $path->addCondition(sprintf('%s = %s or starts-with(%s, %s)', $attrib, XPathExpr::xpathLiteral($value), $attrib, XPathExpr::xpathLiteral($value.'-'))); - } elseif ($this->operator == '^=') { - $path->addCondition(sprintf('starts-with(%s, %s)', $attrib, XPathExpr::xpathLiteral($value))); - } elseif ($this->operator == '$=') { - // Oddly there is a starts-with in XPath 1.0, but not ends-with - $path->addCondition(sprintf('substring(%s, string-length(%s)-%s) = %s', $attrib, $attrib, strlen($value) - 1, XPathExpr::xpathLiteral($value))); - } elseif ($this->operator == '*=') { - // FIXME: case sensitive? - $path->addCondition(sprintf('contains(%s, %s)', $attrib, XPathExpr::xpathLiteral($value))); - } else { - throw new ParseException(sprintf('Unknown operator: %s', $this->operator)); - } - - return $path; - } - - /** - * Returns the XPath Attribute - * - * @return string The XPath attribute - */ - protected function xpathAttrib() - { - // FIXME: if attrib is *? - if ($this->namespace == '*') { - return '@'.$this->attrib; - } - - return sprintf('@%s:%s', $this->namespace, $this->attrib); - } - - /** - * Returns a formatted attribute - * - * @return string The formatted attribute - */ - protected function formatAttrib() - { - if ($this->namespace == '*') { - return $this->attrib; - } - - return sprintf('%s|%s', $this->namespace, $this->attrib); - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttributeNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttributeNode.php new file mode 100644 index 0000000..b10a4dd --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttributeNode.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a "[| ]" node. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class AttributeNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var string + */ + private $namespace; + + /** + * @var string + */ + private $attribute; + + /** + * @var string + */ + private $operator; + + /** + * @var string + */ + private $value; + + /** + * @param NodeInterface $selector + * @param string $namespace + * @param string $attribute + * @param string $operator + * @param string $value + */ + public function __construct(NodeInterface $selector, $namespace, $attribute, $operator, $value) + { + $this->selector = $selector; + $this->namespace = $namespace; + $this->attribute = $attribute; + $this->operator = $operator; + $this->value = $value; + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return string + */ + public function getNamespace() + { + return $this->namespace; + } + + /** + * @return string + */ + public function getAttribute() + { + return $this->attribute; + } + + /** + * @return string + */ + public function getOperator() + { + return $this->operator; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; + + return 'exists' === $this->operator + ? sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute) + : sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ClassNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ClassNode.php index 014aa80..544342f 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ClassNode.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ClassNode.php @@ -11,49 +11,65 @@ namespace Symfony\Component\CssSelector\Node; -use Symfony\Component\CssSelector\XPathExpr; - /** - * ClassNode represents a "selector.className" node. + * Represents a "." node. * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. * - * @author Fabien Potencier + * @author Jean-François Simon */ -class ClassNode implements NodeInterface +class ClassNode extends AbstractNode { - protected $selector; - protected $className; + /** + * @var NodeInterface + */ + private $selector; /** - * The constructor. - * - * @param NodeInterface $selector The XPath Selector - * @param string $className The class name + * @var string */ - public function __construct($selector, $className) + private $name; + + /** + * @param NodeInterface $selector + * @param string $name + */ + public function __construct(NodeInterface $selector, $name) { $this->selector = $selector; - $this->className = $className; + $this->name = $name; } /** - * {@inheritDoc} + * @return NodeInterface */ - public function __toString() + public function getSelector() { - return sprintf('%s[%s.%s]', __CLASS__, $this->selector, $this->className); + return $this->selector; } /** - * {@inheritDoc} + * @return string */ - public function toXpath() + public function getName() { - $selXpath = $this->selector->toXpath(); - $selXpath->addCondition(sprintf("contains(concat(' ', normalize-space(@class), ' '), %s)", XPathExpr::xpathLiteral(' '.$this->className.' '))); + return $this->name; + } - return $selXpath; + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php index 13e3927..6d00db4 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php @@ -11,132 +11,82 @@ namespace Symfony\Component\CssSelector\Node; -use Symfony\Component\CssSelector\Exception\ParseException; - /** - * CombinedSelectorNode represents a combinator node. + * Represents a combined node. * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. * - * @author Fabien Potencier + * @author Jean-François Simon */ -class CombinedSelectorNode implements NodeInterface +class CombinedSelectorNode extends AbstractNode { - protected static $methodMapping = array( - ' ' => 'descendant', - '>' => 'child', - '+' => 'direct_adjacent', - '~' => 'indirect_adjacent', - ); + /** + * @var NodeInterface + */ + private $selector; - protected $selector; - protected $combinator; - protected $subselector; + /** + * @var string + */ + private $combinator; /** - * The constructor. - * - * @param NodeInterface $selector The XPath selector - * @param string $combinator The combinator - * @param NodeInterface $subselector The sub XPath selector + * @var NodeInterface */ - public function __construct($selector, $combinator, $subselector) - { - $this->selector = $selector; - $this->combinator = $combinator; - $this->subselector = $subselector; - } + private $subSelector; /** - * {@inheritDoc} + * @param NodeInterface $selector + * @param string $combinator + * @param NodeInterface $subSelector */ - public function __toString() + public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector) { - $comb = $this->combinator == ' ' ? '' : $this->combinator; - - return sprintf('%s[%s %s %s]', __CLASS__, $this->selector, $comb, $this->subselector); + $this->selector = $selector; + $this->combinator = $combinator; + $this->subSelector = $subSelector; } /** - * {@inheritDoc} - * @throws ParseException When unknown combinator is found + * @return NodeInterface */ - public function toXpath() + public function getSelector() { - if (!isset(self::$methodMapping[$this->combinator])) { - throw new ParseException(sprintf('Unknown combinator: %s', $this->combinator)); - } - - $method = '_xpath_'.self::$methodMapping[$this->combinator]; - $path = $this->selector->toXpath(); - - return $this->$method($path, $this->subselector); + return $this->selector; } /** - * Joins a NodeInterface into the XPath of this object. - * - * @param XPathExpr $xpath The XPath expression for this object - * @param NodeInterface $sub The NodeInterface object to add - * - * @return XPathExpr An XPath instance + * @return string */ - protected function _xpath_descendant($xpath, $sub) + public function getCombinator() { - // when sub is a descendant in any way of xpath - $xpath->join('/descendant::', $sub->toXpath()); - - return $xpath; + return $this->combinator; } /** - * Joins a NodeInterface as a child of this object. - * - * @param XPathExpr $xpath The parent XPath expression - * @param NodeInterface $sub The NodeInterface object to add - * - * @return XPathExpr An XPath instance + * @return NodeInterface */ - protected function _xpath_child($xpath, $sub) + public function getSubSelector() { - // when sub is an immediate child of xpath - $xpath->join('/', $sub->toXpath()); - - return $xpath; + return $this->subSelector; } /** - * Joins an XPath expression as an adjacent of another. - * - * @param XPathExpr $xpath The parent XPath expression - * @param NodeInterface $sub The adjacent XPath expression - * - * @return XPathExpr An XPath instance + * {@inheritdoc} */ - protected function _xpath_direct_adjacent($xpath, $sub) + public function getSpecificity() { - // when sub immediately follows xpath - $xpath->join('/following-sibling::', $sub->toXpath()); - $xpath->addNameTest(); - $xpath->addCondition('position() = 1'); - - return $xpath; + return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); } /** - * Joins an XPath expression as an indirect adjacent of another. - * - * @param XPathExpr $xpath The parent XPath expression - * @param NodeInterface $sub The indirect adjacent NodeInterface object - * - * @return XPathExpr An XPath instance + * {@inheritdoc} */ - protected function _xpath_indirect_adjacent($xpath, $sub) + public function __toString() { - // when sub comes somewhere after xpath as a sibling - $xpath->join('/following-sibling::', $sub->toXpath()); + $combinator = ' ' === $this->combinator ? '' : $this->combinator; - return $xpath; + return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ElementNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ElementNode.php index 5cc7d4b..71ef121 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ElementNode.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ElementNode.php @@ -11,67 +11,67 @@ namespace Symfony\Component\CssSelector\Node; -use Symfony\Component\CssSelector\XPathExpr; - /** - * ElementNode represents a "namespace|element" node. + * Represents a "|" node. * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. * - * @author Fabien Potencier + * @author Jean-François Simon */ -class ElementNode implements NodeInterface +class ElementNode extends AbstractNode { - protected $namespace; - protected $element; + /** + * @var string|null + */ + private $namespace; + + /** + * @var string|null + */ + private $element; /** - * Constructor. - * - * @param string $namespace Namespace - * @param string $element Element + * @param string|null $namespace + * @param string|null $element */ - public function __construct($namespace, $element) + public function __construct($namespace = null, $element = null) { $this->namespace = $namespace; $this->element = $element; } /** - * {@inheritDoc} + * @return null|string */ - public function __toString() + public function getNamespace() { - return sprintf('%s[%s]', __CLASS__, $this->formatElement()); + return $this->namespace; } /** - * Formats the element into a string. - * - * @return string Element as an XPath string + * @return null|string */ - public function formatElement() + public function getElement() { - if ($this->namespace == '*') { - return $this->element; - } + return $this->element; + } - return sprintf('%s|%s', $this->namespace, $this->element); + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return new Specificity(0, 0, $this->element ? 1 : 0); } /** - * {@inheritDoc} + * {@inheritdoc} */ - public function toXpath() + public function __toString() { - if ($this->namespace == '*') { - $el = strtolower($this->element); - } else { - // FIXME: Should we lowercase here? - $el = sprintf('%s:%s', $this->namespace, $this->element); - } + $element = $this->element ?: '*'; - return new XPathExpr(null, null, $el); + return sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/FunctionNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/FunctionNode.php index 8736c27..f94af8d 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/FunctionNode.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/FunctionNode.php @@ -11,280 +11,86 @@ namespace Symfony\Component\CssSelector\Node; -use Symfony\Component\CssSelector\Exception\ParseException; -use Symfony\Component\CssSelector\XPathExpr; +use Symfony\Component\CssSelector\Parser\Token; /** - * FunctionNode represents a "selector:name(expr)" node. + * Represents a ":()" node. * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. * - * @author Fabien Potencier + * @author Jean-François Simon */ -class FunctionNode implements NodeInterface +class FunctionNode extends AbstractNode { - protected static $unsupported = array('target', 'lang', 'enabled', 'disabled'); - - protected $selector; - protected $type; - protected $name; - protected $expr; - /** - * Constructor. - * - * @param NodeInterface $selector The XPath expression - * @param string $type - * @param string $name - * @param XPathExpr $expr + * @var NodeInterface */ - public function __construct($selector, $type, $name, $expr) - { - $this->selector = $selector; - $this->type = $type; - $this->name = $name; - $this->expr = $expr; - } + private $selector; /** - * {@inheritDoc} + * @var string */ - public function __toString() - { - return sprintf('%s[%s%s%s(%s)]', __CLASS__, $this->selector, $this->type, $this->name, $this->expr); - } + private $name; /** - * {@inheritDoc} - * @throws ParseException When unsupported or unknown pseudo-class is found + * @var Token[] */ - public function toXpath() - { - $selPath = $this->selector->toXpath(); - if (in_array($this->name, self::$unsupported)) { - throw new ParseException(sprintf('The pseudo-class %s is not supported', $this->name)); - } - $method = '_xpath_'.str_replace('-', '_', $this->name); - if (!method_exists($this, $method)) { - throw new ParseException(sprintf('The pseudo-class %s is unknown', $this->name)); - } - - return $this->$method($selPath, $this->expr); - } + private $arguments; /** - * undocumented function - * - * @param XPathExpr $xpath - * @param mixed $expr - * @param Boolean $last - * @param Boolean $addNameTest - * - * @return XPathExpr - */ - protected function _xpath_nth_child($xpath, $expr, $last = false, $addNameTest = true) - { - list($a, $b) = $this->parseSeries($expr); - if (!$a && !$b && !$last) { - // a=0 means nothing is returned... - $xpath->addCondition('false() and position() = 0'); - - return $xpath; - } - - if ($addNameTest) { - $xpath->addNameTest(); - } - - $xpath->addStarPrefix(); - if ($a == 0) { - if ($last) { - $b = sprintf('last() - %s', $b); - } - $xpath->addCondition(sprintf('position() = %s', $b)); - - return $xpath; - } - - if ($last) { - // FIXME: I'm not sure if this is right - $a = -$a; - $b = -$b; - } - - if ($b > 0) { - $bNeg = -$b; - } else { - $bNeg = sprintf('+%s', -$b); - } - - if ($a != 1) { - $expr = array(sprintf('(position() %s) mod %s = 0', $bNeg, $a)); - } else { - $expr = array(); - } - - if ($b >= 0) { - $expr[] = sprintf('position() >= %s', $b); - } elseif ($b < 0 && $last) { - $expr[] = sprintf('position() < (last() %s)', $b); - } - $expr = implode($expr, ' and '); - - if ($expr) { - $xpath->addCondition($expr); - } - - return $xpath; - /* FIXME: handle an+b, odd, even - an+b means every-a, plus b, e.g., 2n+1 means odd - 0n+b means b - n+0 means a=1, i.e., all elements - an means every a elements, i.e., 2n means even - -n means -1n - -1n+6 means elements 6 and previous */ - } - - /** - * undocumented function - * - * @param XPathExpr $xpath - * @param XPathExpr $expr - * - * @return XPathExpr + * @param NodeInterface $selector + * @param string $name + * @param Token[] $arguments */ - protected function _xpath_nth_last_child($xpath, $expr) + public function __construct(NodeInterface $selector, $name, array $arguments = array()) { - return $this->_xpath_nth_child($xpath, $expr, true); + $this->selector = $selector; + $this->name = strtolower($name); + $this->arguments = $arguments; } /** - * undocumented function - * - * @param XPathExpr $xpath - * @param XPathExpr $expr - * - * @return XPathExpr - * - * @throws ParseException + * @return NodeInterface */ - protected function _xpath_nth_of_type($xpath, $expr) + public function getSelector() { - if ($xpath->getElement() == '*') { - throw new ParseException('*:nth-of-type() is not implemented'); - } - - return $this->_xpath_nth_child($xpath, $expr, false, false); + return $this->selector; } /** - * undocumented function - * - * @param XPathExpr $xpath - * @param XPathExpr $expr - * - * @return XPathExpr + * @return string */ - protected function _xpath_nth_last_of_type($xpath, $expr) + public function getName() { - return $this->_xpath_nth_child($xpath, $expr, true, false); + return $this->name; } /** - * undocumented function - * - * @param XPathExpr $xpath - * @param XPathExpr $expr - * - * @return XPathExpr + * @return Token[] */ - protected function _xpath_contains($xpath, $expr) + public function getArguments() { - // text content, minus tags, must contain expr - if ($expr instanceof ElementNode) { - $expr = $expr->formatElement(); - } - - // FIXME: lower-case is only available with XPath 2 - //$xpath->addCondition(sprintf('contains(lower-case(string(.)), %s)', XPathExpr::xpathLiteral(strtolower($expr)))); - $xpath->addCondition(sprintf('contains(string(.), %s)', XPathExpr::xpathLiteral($expr))); - - // FIXME: Currently case insensitive matching doesn't seem to be happening - return $xpath; + return $this->arguments; } /** - * undocumented function - * - * @param XPathExpr $xpath - * @param XPathExpr $expr - * - * @return XPathExpr + * {@inheritdoc} */ - protected function _xpath_not($xpath, $expr) + public function getSpecificity() { - // everything for which not expr applies - $expr = $expr->toXpath(); - $cond = $expr->getCondition(); - // FIXME: should I do something about element_path? - $xpath->addCondition(sprintf('not(%s)', $cond)); - - return $xpath; + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } /** - * Parses things like '1n+2', or 'an+b' generally, returning (a, b) - * - * @param mixed $s - * - * @return array + * {@inheritdoc} */ - protected function parseSeries($s) + public function __toString() { - if ($s instanceof ElementNode) { - $s = $s->formatElement(); - } - - if (!$s || '*' == $s) { - // Happens when there's nothing, which the CSS parser thinks of as * - return array(0, 0); - } - - if ('odd' == $s) { - return array(2, 1); - } - - if ('even' == $s) { - return array(2, 0); - } - - if ('n' == $s) { - return array(1, 0); - } - - if (false === strpos($s, 'n')) { - // Just a b - return array(0, intval((string) $s)); - } - - list($a, $b) = explode('n', $s); - if (!$a) { - $a = 1; - } elseif ('-' == $a || '+' == $a) { - $a = intval($a.'1'); - } else { - $a = intval($a); - } - - if (!$b) { - $b = 0; - } elseif ('-' == $b || '+' == $b) { - $b = intval($b.'1'); - } else { - $b = intval($b); - } + $arguments = implode(', ', array_map(function (Token $token) { + return "'".$token->getValue()."'"; + }, $this->arguments)); - return array($a, $b); + return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : ''); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/HashNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/HashNode.php index 87a6590..ddbe764 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/HashNode.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/HashNode.php @@ -11,49 +11,65 @@ namespace Symfony\Component\CssSelector\Node; -use Symfony\Component\CssSelector\XPathExpr; - /** - * HashNode represents a "selector#id" node. + * Represents a "#" node. * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. * - * @author Fabien Potencier + * @author Jean-François Simon */ -class HashNode implements NodeInterface +class HashNode extends AbstractNode { - protected $selector; - protected $id; + /** + * @var NodeInterface + */ + private $selector; /** - * Constructor. - * - * @param NodeInterface $selector The NodeInterface object - * @param string $id The ID + * @var string */ - public function __construct($selector, $id) + private $id; + + /** + * @param NodeInterface $selector + * @param string $id + */ + public function __construct(NodeInterface $selector, $id) { $this->selector = $selector; $this->id = $id; } /** - * {@inheritDoc} + * @return NodeInterface */ - public function __toString() + public function getSelector() { - return sprintf('%s[%s#%s]', __CLASS__, $this->selector, $this->id); + return $this->selector; } /** - * {@inheritDoc} + * @return string */ - public function toXpath() + public function getId() { - $path = $this->selector->toXpath(); - $path->addCondition(sprintf('@id = %s', XPathExpr::xpathLiteral($this->id))); + return $this->id; + } - return $path; + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NegationNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NegationNode.php new file mode 100644 index 0000000..0fafb0a --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NegationNode.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a ":not()" node. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class NegationNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var NodeInterface + */ + private $subSelector; + + /** + * @param NodeInterface $selector + * @param NodeInterface $subSelector + */ + public function __construct(NodeInterface $selector, NodeInterface $subSelector) + { + $this->selector = $selector; + $this->subSelector = $subSelector; + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return NodeInterface + */ + public function getSubSelector() + { + return $this->subSelector; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NodeInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NodeInterface.php index 113b1b7..dd300e2 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NodeInterface.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NodeInterface.php @@ -12,26 +12,33 @@ namespace Symfony\Component\CssSelector\Node; /** - * ClassNode represents a "selector.className" node. + * Interface for nodes. * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. * - * @author Fabien Potencier + * @author Jean-François Simon */ interface NodeInterface { /** - * Returns a string representation of the object. + * Returns node's name. * - * @return string The string representation + * @return string */ - public function __toString(); + public function getNodeName(); + + /** + * Returns node's specificity. + * + * @return Specificity + */ + public function getSpecificity(); /** - * @return XPathExpr The XPath expression + * Returns node's string representation. * - * @throws ParseException When unknown operator is found + * @return string */ - public function toXpath(); + public function __toString(); } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/OrNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/OrNode.php deleted file mode 100644 index 374a577..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/OrNode.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector\Node; - -use Symfony\Component\CssSelector\XPathExprOr; - -/** - * OrNode represents a "Or" node. - * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. - * - * @author Fabien Potencier - */ -class OrNode implements NodeInterface -{ - /** - * @var NodeInterface[] - */ - protected $items; - - /** - * Constructor. - * - * @param NodeInterface[] $items An array of NodeInterface objects - */ - public function __construct($items) - { - $this->items = $items; - } - - /** - * {@inheritDoc} - */ - public function __toString() - { - return sprintf('%s(%s)', __CLASS__, $this->items); - } - - /** - * {@inheritDoc} - */ - public function toXpath() - { - $paths = array(); - foreach ($this->items as $item) { - $paths[] = $item->toXpath(); - } - - return new XPathExprOr($paths); - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/PseudoNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/PseudoNode.php index 2aa4c65..0e413ad 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/PseudoNode.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/PseudoNode.php @@ -11,221 +11,65 @@ namespace Symfony\Component\CssSelector\Node; -use Symfony\Component\CssSelector\Exception\ParseException; -use Symfony\Component\CssSelector\XPathExpr; - /** - * PseudoNode represents a "selector:ident" node. + * Represents a ":" node. * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. * - * @author Fabien Potencier + * @author Jean-François Simon */ -class PseudoNode implements NodeInterface +class PseudoNode extends AbstractNode { - protected static $unsupported = array( - 'indeterminate', 'first-line', 'first-letter', - 'selection', 'before', 'after', 'link', 'visited', - 'active', 'focus', 'hover', - ); - - protected $element; - protected $type; - protected $ident; - - /** - * Constructor. - * - * @param NodeInterface $element The NodeInterface element - * @param string $type Node type - * @param string $ident The ident - * - * @throws ParseException When incorrect PseudoNode type is given - */ - public function __construct($element, $type, $ident) - { - $this->element = $element; - - if (!in_array($type, array(':', '::'))) { - throw new ParseException(sprintf('The PseudoNode type can only be : or :: (%s given).', $type)); - } - - $this->type = $type; - $this->ident = $ident; - } - - /** - * {@inheritDoc} - */ - public function __toString() - { - return sprintf('%s[%s%s%s]', __CLASS__, $this->element, $this->type, $this->ident); - } - - /** - * {@inheritDoc} - * @throws ParseException When unsupported or unknown pseudo-class is found - */ - public function toXpath() - { - $elXpath = $this->element->toXpath(); - - if (in_array($this->ident, self::$unsupported)) { - throw new ParseException(sprintf('The pseudo-class %s is unsupported', $this->ident)); - } - $method = 'xpath_'.str_replace('-', '_', $this->ident); - if (!method_exists($this, $method)) { - throw new ParseException(sprintf('The pseudo-class %s is unknown', $this->ident)); - } - - return $this->$method($elXpath); - } - /** - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified XPath expression + * @var NodeInterface */ - protected function xpath_checked($xpath) - { - // FIXME: is this really all the elements? - $xpath->addCondition("(@selected or @checked) and (name(.) = 'input' or name(.) = 'option')"); - - return $xpath; - } + private $selector; /** - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified XPath expression - * - * @throws ParseException If this element is the root element + * @var string */ - protected function xpath_root($xpath) - { - // if this element is the root element - throw new ParseException(); - } + private $identifier; /** - * Marks this XPath expression as the first child. - * - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified expression + * @param NodeInterface $selector + * @param string $identifier */ - protected function xpath_first_child($xpath) + public function __construct(NodeInterface $selector, $identifier) { - $xpath->addStarPrefix(); - $xpath->addNameTest(); - $xpath->addCondition('position() = 1'); - - return $xpath; + $this->selector = $selector; + $this->identifier = strtolower($identifier); } /** - * Sets the XPath to be the last child. - * - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified expression + * @return NodeInterface */ - protected function xpath_last_child($xpath) + public function getSelector() { - $xpath->addStarPrefix(); - $xpath->addNameTest(); - $xpath->addCondition('position() = last()'); - - return $xpath; + return $this->selector; } /** - * Sets the XPath expression to be the first of type. - * - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified expression - * - * @throws ParseException + * @return string */ - protected function xpath_first_of_type($xpath) + public function getIdentifier() { - if ($xpath->getElement() == '*') { - throw new ParseException('*:first-of-type is not implemented'); - } - $xpath->addStarPrefix(); - $xpath->addCondition('position() = 1'); - - return $xpath; + return $this->identifier; } /** - * Sets the XPath expression to be the last of type. - * - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified expression - * - * @throws ParseException Because *:last-of-type is not implemented + * {@inheritdoc} */ - protected function xpath_last_of_type($xpath) + public function getSpecificity() { - if ($xpath->getElement() == '*') { - throw new ParseException('*:last-of-type is not implemented'); - } - $xpath->addStarPrefix(); - $xpath->addCondition('position() = last()'); - - return $xpath; + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } /** - * Sets the XPath expression to be the only child. - * - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified expression + * {@inheritdoc} */ - protected function xpath_only_child($xpath) - { - $xpath->addNameTest(); - $xpath->addStarPrefix(); - $xpath->addCondition('last() = 1'); - - return $xpath; - } - - /** - * Sets the XPath expression to be only of type. - * - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified expression - * - * @throws ParseException Because *:only-of-type is not implemented - */ - protected function xpath_only_of_type($xpath) - { - if ($xpath->getElement() == '*') { - throw new ParseException('*:only-of-type is not implemented'); - } - $xpath->addCondition('last() = 1'); - - return $xpath; - } - - /** - * undocumented function - * - * @param XPathExpr $xpath The XPath expression - * - * @return XPathExpr The modified expression - */ - protected function xpath_empty($xpath) + public function __toString() { - $xpath->addCondition('not(*) and not(normalize-space())'); - - return $xpath; + return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/SelectorNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/SelectorNode.php new file mode 100644 index 0000000..4958da5 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/SelectorNode.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a "(::|:)" node. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class SelectorNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $tree; + + /** + * @var null|string + */ + private $pseudoElement; + + /** + * @param NodeInterface $tree + * @param null|string $pseudoElement + */ + public function __construct(NodeInterface $tree, $pseudoElement = null) + { + $this->tree = $tree; + $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null; + } + + /** + * @return NodeInterface + */ + public function getTree() + { + return $this->tree; + } + + /** + * @return null|string + */ + public function getPseudoElement() + { + return $this->pseudoElement; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : ''); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/Specificity.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/Specificity.php new file mode 100644 index 0000000..0dfec3b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/Specificity.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a node specificity. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @see http://www.w3.org/TR/selectors/#specificity + * + * @author Jean-François Simon + */ +class Specificity +{ + const A_FACTOR = 100; + const B_FACTOR = 10; + const C_FACTOR = 1; + + /** + * @var int + */ + private $a; + + /** + * @var int + */ + private $b; + + /** + * @var int + */ + private $c; + + /** + * Constructor. + * + * @param int $a + * @param int $b + * @param int $c + */ + public function __construct($a, $b, $c) + { + $this->a = $a; + $this->b = $b; + $this->c = $c; + } + + /** + * @param Specificity $specificity + * + * @return Specificity + */ + public function plus(Specificity $specificity) + { + return new self($this->a + $specificity->a, $this->b + $specificity->b, $this->c + $specificity->c); + } + + /** + * Returns global specificity value. + * + * @return int + */ + public function getValue() + { + return $this->a * self::A_FACTOR + $this->b * self::B_FACTOR + $this->c * self::C_FACTOR; + } + + /** + * Returns -1 if the object specificity is lower than the argument, + * 0 if they are equal, and 1 if the argument is lower + * + * @param Specificity $specificity + * + * @return int + */ + public function compareTo(Specificity $specificity) + { + if ($this->a !== $specificity->a) { + return $this->a > $specificity->a ? 1 : -1; + } + + if ($this->b !== $specificity->b) { + return $this->b > $specificity->b ? 1 : -1; + } + + if ($this->c !== $specificity->c) { + return $this->c > $specificity->c ? 1 : -1; + } + + return 0; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/CommentHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/CommentHandler.php new file mode 100644 index 0000000..f480776 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/CommentHandler.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class CommentHandler implements HandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + if ('/*' !== $reader->getSubstring(2)) { + return false; + } + + $offset = $reader->getOffset('*/'); + + if (false === $offset) { + $reader->moveToEnd(); + } else { + $reader->moveForward($offset + 2); + } + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HandlerInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HandlerInterface.php new file mode 100644 index 0000000..049ddd3 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HandlerInterface.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * CSS selector handler interface. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface HandlerInterface +{ + /** + * @param Reader $reader + * @param TokenStream $stream + * + * @return bool + */ + public function handle(Reader $reader, TokenStream $stream); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HashHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HashHandler.php new file mode 100644 index 0000000..b144223 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HashHandler.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class HashHandler implements HandlerInterface +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @var TokenizerEscaping + */ + private $escaping; + + /** + * @param TokenizerPatterns $patterns + * @param TokenizerEscaping $escaping + */ + public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) + { + $this->patterns = $patterns; + $this->escaping = $escaping; + } + + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $match = $reader->findPattern($this->patterns->getHashPattern()); + + if (!$match) { + return false; + } + + $value = $this->escaping->escapeUnicode($match[1]); + $stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition())); + $reader->moveForward(strlen($match[0])); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/IdentifierHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/IdentifierHandler.php new file mode 100644 index 0000000..86739ea --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/IdentifierHandler.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class IdentifierHandler implements HandlerInterface +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @var TokenizerEscaping + */ + private $escaping; + + /** + * @param TokenizerPatterns $patterns + * @param TokenizerEscaping $escaping + */ + public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) + { + $this->patterns = $patterns; + $this->escaping = $escaping; + } + + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $match = $reader->findPattern($this->patterns->getIdentifierPattern()); + + if (!$match) { + return false; + } + + $value = $this->escaping->escapeUnicode($match[0]); + $stream->push(new Token(Token::TYPE_IDENTIFIER, $value, $reader->getPosition())); + $reader->moveForward(strlen($match[0])); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/NumberHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/NumberHandler.php new file mode 100644 index 0000000..97a9387 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/NumberHandler.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class NumberHandler implements HandlerInterface +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @param TokenizerPatterns $patterns + */ + public function __construct(TokenizerPatterns $patterns) + { + $this->patterns = $patterns; + } + + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $match = $reader->findPattern($this->patterns->getNumberPattern()); + + if (!$match) { + return false; + } + + $stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition())); + $reader->moveForward(strlen($match[0])); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php new file mode 100644 index 0000000..9f7a594 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Exception\InternalErrorException; +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class StringHandler implements HandlerInterface +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @var TokenizerEscaping + */ + private $escaping; + + /** + * @param TokenizerPatterns $patterns + * @param TokenizerEscaping $escaping + */ + public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) + { + $this->patterns = $patterns; + $this->escaping = $escaping; + } + + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $quote = $reader->getSubstring(1); + + if (!in_array($quote, array("'", '"'))) { + return false; + } + + $reader->moveForward(1); + $match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote)); + + if (!$match) { + throw new InternalErrorException(sprintf('Should have found at least an empty match at %s.', $reader->getPosition())); + } + + // check unclosed strings + if (strlen($match[0]) === $reader->getRemainingLength()) { + throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); + } + + // check quotes pairs validity + if ($quote !== $reader->getSubstring(1, strlen($match[0]))) { + throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); + } + + $string = $this->escaping->escapeUnicodeAndNewLine($match[0]); + $stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition())); + $reader->moveForward(strlen($match[0]) + 1); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/WhitespaceHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/WhitespaceHandler.php new file mode 100644 index 0000000..234bbd8 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/WhitespaceHandler.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * CSS selector whitespace handler. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class WhitespaceHandler implements HandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $match = $reader->findPattern('~^[ \t\r\n\f]+~'); + + if (false === $match) { + return false; + } + + $stream->push(new Token(Token::TYPE_WHITESPACE, $match[0], $reader->getPosition())); + $reader->moveForward(strlen($match[0])); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php new file mode 100644 index 0000000..9625e3e --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php @@ -0,0 +1,399 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use Symfony\Component\CssSelector\Node; +use Symfony\Component\CssSelector\Parser\Tokenizer\Tokenizer; + +/** + * CSS selector parser. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Parser implements ParserInterface +{ + /** + * @var Tokenizer + */ + private $tokenizer; + + /** + * Constructor. + * + * @param null|Tokenizer $tokenizer + */ + public function __construct(Tokenizer $tokenizer = null) + { + $this->tokenizer = $tokenizer ?: new Tokenizer(); + } + + /** + * {@inheritdoc} + */ + public function parse($source) + { + $reader = new Reader($source); + $stream = $this->tokenizer->tokenize($reader); + + return $this->parseSelectorList($stream); + } + + /** + * Parses the arguments for ":nth-child()" and friends. + * + * @param Token[] $tokens + * + * @throws SyntaxErrorException + * + * @return array + */ + public static function parseSeries(array $tokens) + { + foreach ($tokens as $token) { + if ($token->isString()) { + throw SyntaxErrorException::stringAsFunctionArgument(); + } + } + + $joined = trim(implode('', array_map(function (Token $token) { + return $token->getValue(); + }, $tokens))); + + $int = function ($string) { + if (!is_numeric($string)) { + throw SyntaxErrorException::stringAsFunctionArgument(); + } + + return (int) $string; + }; + + switch (true) { + case 'odd' === $joined: + return array(2, 1); + case 'even' === $joined: + return array(2, 0); + case 'n' === $joined: + return array(1, 0); + case false === strpos($joined, 'n'): + return array(0, $int($joined)); + } + + $split = explode('n', $joined); + $first = isset($split[0]) ? $split[0] : null; + + return array( + $first ? ('-' === $first || '+' === $first ? $int($first.'1') : $int($first)) : 1, + isset($split[1]) && $split[1] ? $int($split[1]) : 0, + ); + } + + /** + * Parses selector nodes. + * + * @param TokenStream $stream + * + * @return array + */ + private function parseSelectorList(TokenStream $stream) + { + $stream->skipWhitespace(); + $selectors = array(); + + while (true) { + $selectors[] = $this->parserSelectorNode($stream); + + if ($stream->getPeek()->isDelimiter(array(','))) { + $stream->getNext(); + $stream->skipWhitespace(); + } else { + break; + } + } + + return $selectors; + } + + /** + * Parses next selector or combined node. + * + * @param TokenStream $stream + * + * @throws SyntaxErrorException + * + * @return Node\SelectorNode + */ + private function parserSelectorNode(TokenStream $stream) + { + list($result, $pseudoElement) = $this->parseSimpleSelector($stream); + + while (true) { + $stream->skipWhitespace(); + $peek = $stream->getPeek(); + + if ($peek->isFileEnd() || $peek->isDelimiter(array(','))) { + break; + } + + if (null !== $pseudoElement) { + throw SyntaxErrorException::pseudoElementFound($pseudoElement, 'not at the end of a selector'); + } + + if ($peek->isDelimiter(array('+', '>', '~'))) { + $combinator = $stream->getNext()->getValue(); + $stream->skipWhitespace(); + } else { + $combinator = ' '; + } + + list($nextSelector, $pseudoElement) = $this->parseSimpleSelector($stream); + $result = new Node\CombinedSelectorNode($result, $combinator, $nextSelector); + } + + return new Node\SelectorNode($result, $pseudoElement); + } + + /** + * Parses next simple node (hash, class, pseudo, negation). + * + * @param TokenStream $stream + * @param bool $insideNegation + * + * @throws SyntaxErrorException + * + * @return array + */ + private function parseSimpleSelector(TokenStream $stream, $insideNegation = false) + { + $stream->skipWhitespace(); + + $selectorStart = count($stream->getUsed()); + $result = $this->parseElementNode($stream); + $pseudoElement = null; + + while (true) { + $peek = $stream->getPeek(); + if ($peek->isWhitespace() + || $peek->isFileEnd() + || $peek->isDelimiter(array(',', '+', '>', '~')) + || ($insideNegation && $peek->isDelimiter(array(')'))) + ) { + break; + } + + if (null !== $pseudoElement) { + throw SyntaxErrorException::pseudoElementFound($pseudoElement, 'not at the end of a selector'); + } + + if ($peek->isHash()) { + $result = new Node\HashNode($result, $stream->getNext()->getValue()); + } elseif ($peek->isDelimiter(array('.'))) { + $stream->getNext(); + $result = new Node\ClassNode($result, $stream->getNextIdentifier()); + } elseif ($peek->isDelimiter(array('['))) { + $stream->getNext(); + $result = $this->parseAttributeNode($result, $stream); + } elseif ($peek->isDelimiter(array(':'))) { + $stream->getNext(); + + if ($stream->getPeek()->isDelimiter(array(':'))) { + $stream->getNext(); + $pseudoElement = $stream->getNextIdentifier(); + + continue; + } + + $identifier = $stream->getNextIdentifier(); + if (in_array(strtolower($identifier), array('first-line', 'first-letter', 'before', 'after'))) { + // Special case: CSS 2.1 pseudo-elements can have a single ':'. + // Any new pseudo-element must have two. + $pseudoElement = $identifier; + + continue; + } + + if (!$stream->getPeek()->isDelimiter(array('('))) { + $result = new Node\PseudoNode($result, $identifier); + + continue; + } + + $stream->getNext(); + $stream->skipWhitespace(); + + if ('not' === strtolower($identifier)) { + if ($insideNegation) { + throw SyntaxErrorException::nestedNot(); + } + + list($argument, $argumentPseudoElement) = $this->parseSimpleSelector($stream, true); + $next = $stream->getNext(); + + if (null !== $argumentPseudoElement) { + throw SyntaxErrorException::pseudoElementFound($argumentPseudoElement, 'inside ::not()'); + } + + if (!$next->isDelimiter(array(')'))) { + throw SyntaxErrorException::unexpectedToken('")"', $next); + } + + $result = new Node\NegationNode($result, $argument); + } else { + $arguments = array(); + $next = null; + + while (true) { + $stream->skipWhitespace(); + $next = $stream->getNext(); + + if ($next->isIdentifier() + || $next->isString() + || $next->isNumber() + || $next->isDelimiter(array('+', '-')) + ) { + $arguments[] = $next; + } elseif ($next->isDelimiter(array(')'))) { + break; + } else { + throw SyntaxErrorException::unexpectedToken('an argument', $next); + } + } + + if (empty($arguments)) { + throw SyntaxErrorException::unexpectedToken('at least one argument', $next); + } + + $result = new Node\FunctionNode($result, $identifier, $arguments); + } + } else { + throw SyntaxErrorException::unexpectedToken('selector', $peek); + } + } + + if (count($stream->getUsed()) === $selectorStart) { + throw SyntaxErrorException::unexpectedToken('selector', $stream->getPeek()); + } + + return array($result, $pseudoElement); + } + + /** + * Parses next element node. + * + * @param TokenStream $stream + * + * @return Node\ElementNode + */ + private function parseElementNode(TokenStream $stream) + { + $peek = $stream->getPeek(); + + if ($peek->isIdentifier() || $peek->isDelimiter(array('*'))) { + if ($peek->isIdentifier()) { + $namespace = $stream->getNext()->getValue(); + } else { + $stream->getNext(); + $namespace = null; + } + + if ($stream->getPeek()->isDelimiter(array('|'))) { + $stream->getNext(); + $element = $stream->getNextIdentifierOrStar(); + } else { + $element = $namespace; + $namespace = null; + } + } else { + $element = $namespace = null; + } + + return new Node\ElementNode($namespace, $element); + } + + /** + * Parses next attribute node. + * + * @param Node\NodeInterface $selector + * @param TokenStream $stream + * + * @throws SyntaxErrorException + * + * @return Node\AttributeNode + */ + private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $stream) + { + $stream->skipWhitespace(); + $attribute = $stream->getNextIdentifierOrStar(); + + if (null === $attribute && !$stream->getPeek()->isDelimiter(array('|'))) { + throw SyntaxErrorException::unexpectedToken('"|"', $stream->getPeek()); + } + + if ($stream->getPeek()->isDelimiter(array('|'))) { + $stream->getNext(); + + if ($stream->getPeek()->isDelimiter(array('='))) { + $namespace = null; + $stream->getNext(); + $operator = '|='; + } else { + $namespace = $attribute; + $attribute = $stream->getNextIdentifier(); + $operator = null; + } + } else { + $namespace = $operator = null; + } + + if (null === $operator) { + $stream->skipWhitespace(); + $next = $stream->getNext(); + + if ($next->isDelimiter(array(']'))) { + return new Node\AttributeNode($selector, $namespace, $attribute, 'exists', null); + } elseif ($next->isDelimiter(array('='))) { + $operator = '='; + } elseif ($next->isDelimiter(array('^', '$', '*', '~', '|', '!')) + && $stream->getPeek()->isDelimiter(array('=')) + ) { + $operator = $next->getValue().'='; + $stream->getNext(); + } else { + throw SyntaxErrorException::unexpectedToken('operator', $next); + } + } + + $stream->skipWhitespace(); + $value = $stream->getNext(); + + if ($value->isNumber()) { + // if the value is a number, it's casted into a string + $value = new Token(Token::TYPE_STRING, (string) $value->getValue(), $value->getPosition()); + } + + if (!($value->isIdentifier() || $value->isString())) { + throw SyntaxErrorException::unexpectedToken('string or identifier', $value); + } + + $stream->skipWhitespace(); + $next = $stream->getNext(); + + if (!$next->isDelimiter(array(']'))) { + throw SyntaxErrorException::unexpectedToken('"]"', $next); + } + + return new Node\AttributeNode($selector, $namespace, $attribute, $operator, $value->getValue()); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/ParserInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/ParserInterface.php new file mode 100644 index 0000000..3b43a52 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/ParserInterface.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +use Symfony\Component\CssSelector\Node\SelectorNode; + +/** + * CSS selector parser interface. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface ParserInterface +{ + /** + * Parses given selector source into an array of tokens. + * + * @param string $source + * + * @return SelectorNode[] + */ + public function parse($source); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Reader.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Reader.php new file mode 100644 index 0000000..ba2a7f0 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Reader.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +/** + * CSS selector reader. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Reader +{ + /** + * @var string + */ + private $source; + + /** + * @var int + */ + private $length; + + /** + * @var int + */ + private $position = 0; + + /** + * @param string $source + */ + public function __construct($source) + { + $this->source = $source; + $this->length = strlen($source); + } + + /** + * @return bool + */ + public function isEOF() + { + return $this->position >= $this->length; + } + + /** + * @return int + */ + public function getPosition() + { + return $this->position; + } + + /** + * @return int + */ + public function getRemainingLength() + { + return $this->length - $this->position; + } + + /** + * @param int $length + * @param int $offset + * + * @return string + */ + public function getSubstring($length, $offset = 0) + { + return substr($this->source, $this->position + $offset, $length); + } + + /** + * @param string $string + * + * @return int + */ + public function getOffset($string) + { + $position = strpos($this->source, $string, $this->position); + + return false === $position ? false : $position - $this->position; + } + + /** + * @param string $pattern + * + * @return bool + */ + public function findPattern($pattern) + { + $source = substr($this->source, $this->position); + + if (preg_match($pattern, $source, $matches)) { + return $matches; + } + + return false; + } + + /** + * @param int $length + */ + public function moveForward($length) + { + $this->position += $length; + } + + /** + */ + public function moveToEnd() + { + $this->position = $this->length; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php new file mode 100644 index 0000000..142bd16 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\ClassNode; +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * CSS selector class parser shortcut. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class ClassParser implements ParserInterface +{ + /** + * {@inheritdoc} + */ + public function parse($source) + { + // Matches an optional namespace, optional element, and required class + // $source = 'test|input.ab6bd_field'; + // $matches = array (size=5) + // 0 => string 'test:input.ab6bd_field' (length=22) + // 1 => string 'test:' (length=5) + // 2 => string 'test' (length=4) + // 3 => string 'input' (length=5) + // 4 => string 'ab6bd_field' (length=11) + if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?\.([\w-]+)$/i', trim($source), $matches)) { + return array( + new SelectorNode(new ClassNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])), + ); + } + + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ElementParser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ElementParser.php new file mode 100644 index 0000000..f62d259 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ElementParser.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * CSS selector element parser shortcut. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class ElementParser implements ParserInterface +{ + /** + * {@inheritdoc} + */ + public function parse($source) + { + // Matches an optional namespace, required element or `*` + // $source = 'testns|testel'; + // $matches = array (size=4) + // 0 => string 'testns:testel' (length=13) + // 1 => string 'testns:' (length=7) + // 2 => string 'testns' (length=6) + // 3 => string 'testel' (length=6) + if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)$/i', trim($source), $matches)) { + return array(new SelectorNode(new ElementNode($matches[2] ?: null, $matches[3]))); + } + + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php new file mode 100644 index 0000000..98a08fd --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * CSS selector class parser shortcut. + * + * This shortcut ensure compatibility with previous version. + * - The parser fails to parse an empty string. + * - In the previous version, an empty string matches each tags. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class EmptyStringParser implements ParserInterface +{ + /** + * {@inheritdoc} + */ + public function parse($source) + { + // Matches an empty string + if ($source == '') { + return array(new SelectorNode(new ElementNode(null, '*'))); + } + + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php new file mode 100644 index 0000000..fde6141 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\HashNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * CSS selector hash parser shortcut. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class HashParser implements ParserInterface +{ + /** + * {@inheritdoc} + */ + public function parse($source) + { + // Matches an optional namespace, optional element, and required id + // $source = 'test|input#ab6bd_field'; + // $matches = array (size=5) + // 0 => string 'test:input#ab6bd_field' (length=22) + // 1 => string 'test:' (length=5) + // 2 => string 'test' (length=4) + // 3 => string 'input' (length=5) + // 4 => string 'ab6bd_field' (length=11) + if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?#([\w-]+)$/i', trim($source), $matches)) { + return array( + new SelectorNode(new HashNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])), + ); + } + + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Token.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Token.php new file mode 100644 index 0000000..6f7586f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Token.php @@ -0,0 +1,160 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +/** + * CSS selector token. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Token +{ + const TYPE_FILE_END = 'eof'; + const TYPE_DELIMITER = 'delimiter'; + const TYPE_WHITESPACE = 'whitespace'; + const TYPE_IDENTIFIER = 'identifier'; + const TYPE_HASH = 'hash'; + const TYPE_NUMBER = 'number'; + const TYPE_STRING = 'string'; + + /** + * @var int + */ + private $type; + + /** + * @var string + */ + private $value; + + /** + * @var int + */ + private $position; + + /** + * @param int $type + * @param string $value + * @param int $position + */ + public function __construct($type, $value, $position) + { + $this->type = $type; + $this->value = $value; + $this->position = $position; + } + + /** + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * @return int + */ + public function getPosition() + { + return $this->position; + } + + /** + * @return bool + */ + public function isFileEnd() + { + return self::TYPE_FILE_END === $this->type; + } + + /** + * @param array $values + * + * @return bool + */ + public function isDelimiter(array $values = array()) + { + if (self::TYPE_DELIMITER !== $this->type) { + return false; + } + + if (empty($values)) { + return true; + } + + return in_array($this->value, $values); + } + + /** + * @return bool + */ + public function isWhitespace() + { + return self::TYPE_WHITESPACE === $this->type; + } + + /** + * @return bool + */ + public function isIdentifier() + { + return self::TYPE_IDENTIFIER === $this->type; + } + + /** + * @return bool + */ + public function isHash() + { + return self::TYPE_HASH === $this->type; + } + + /** + * @return bool + */ + public function isNumber() + { + return self::TYPE_NUMBER === $this->type; + } + + /** + * @return bool + */ + public function isString() + { + return self::TYPE_STRING === $this->type; + } + + /** + * @return string + */ + public function __toString() + { + if ($this->value) { + return sprintf('<%s "%s" at %s>', $this->type, $this->value, $this->position); + } + + return sprintf('<%s at %s>', $this->type, $this->position); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/TokenStream.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/TokenStream.php new file mode 100644 index 0000000..8184b83 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/TokenStream.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +use Symfony\Component\CssSelector\Exception\InternalErrorException; +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; + +/** + * CSS selector token stream. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class TokenStream +{ + /** + * @var Token[] + */ + private $tokens = array(); + + /** + * @var bool + */ + private $frozen = false; + + /** + * @var Token[] + */ + private $used = array(); + + /** + * @var int + */ + private $cursor = 0; + + /** + * @var Token|null + */ + private $peeked = null; + + /** + * @var bool + */ + private $peeking = false; + + /** + * Pushes a token. + * + * @param Token $token + * + * @return TokenStream + */ + public function push(Token $token) + { + $this->tokens[] = $token; + + return $this; + } + + /** + * Freezes stream. + * + * @return TokenStream + */ + public function freeze() + { + $this->frozen = true; + + return $this; + } + + /** + * Returns next token. + * + * @throws InternalErrorException If there is no more token + * + * @return Token + */ + public function getNext() + { + if ($this->peeking) { + $this->peeking = false; + $this->used[] = $this->peeked; + + return $this->peeked; + } + + if (!isset($this->tokens[$this->cursor])) { + throw new InternalErrorException('Unexpected token stream end.'); + } + + return $this->tokens[$this->cursor ++]; + } + + /** + * Returns peeked token. + * + * @return Token + */ + public function getPeek() + { + if (!$this->peeking) { + $this->peeked = $this->getNext(); + $this->peeking = true; + } + + return $this->peeked; + } + + /** + * Returns used tokens. + * + * @return Token[] + */ + public function getUsed() + { + return $this->used; + } + + /** + * Returns nex identifier token. + * + * @throws SyntaxErrorException If next token is not an identifier + * + * @return string The identifier token value + */ + public function getNextIdentifier() + { + $next = $this->getNext(); + + if (!$next->isIdentifier()) { + throw SyntaxErrorException::unexpectedToken('identifier', $next); + } + + return $next->getValue(); + } + + /** + * Returns nex identifier or star delimiter token. + * + * @throws SyntaxErrorException If next token is not an identifier or a star delimiter + * + * @return null|string The identifier token value or null if star found + */ + public function getNextIdentifierOrStar() + { + $next = $this->getNext(); + + if ($next->isIdentifier()) { + return $next->getValue(); + } + + if ($next->isDelimiter(array('*'))) { + return; + } + + throw SyntaxErrorException::unexpectedToken('identifier or "*"', $next); + } + + /** + * Skips next whitespace if any. + */ + public function skipWhitespace() + { + $peek = $this->getPeek(); + + if ($peek->isWhitespace()) { + $this->getNext(); + } + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php new file mode 100644 index 0000000..79fa7b7 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Tokenizer; + +use Symfony\Component\CssSelector\Parser\Handler; +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * CSS selector tokenizer. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Tokenizer +{ + /** + * @var Handler\HandlerInterface[] + */ + private $handlers; + + /** + * Constructor. + */ + public function __construct() + { + $patterns = new TokenizerPatterns(); + $escaping = new TokenizerEscaping($patterns); + + $this->handlers = array( + new Handler\WhitespaceHandler(), + new Handler\IdentifierHandler($patterns, $escaping), + new Handler\HashHandler($patterns, $escaping), + new Handler\StringHandler($patterns, $escaping), + new Handler\NumberHandler($patterns), + new Handler\CommentHandler(), + ); + } + + /** + * Tokenize selector source code. + * + * @param Reader $reader + * + * @return TokenStream + */ + public function tokenize(Reader $reader) + { + $stream = new TokenStream(); + + while (!$reader->isEOF()) { + foreach ($this->handlers as $handler) { + if ($handler->handle($reader, $stream)) { + continue 2; + } + } + + $stream->push(new Token(Token::TYPE_DELIMITER, $reader->getSubstring(1), $reader->getPosition())); + $reader->moveForward(1); + } + + return $stream + ->push(new Token(Token::TYPE_FILE_END, null, $reader->getPosition())) + ->freeze(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php new file mode 100644 index 0000000..bf5096b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Tokenizer; + +/** + * CSS selector tokenizer escaping applier. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class TokenizerEscaping +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @param TokenizerPatterns $patterns + */ + public function __construct(TokenizerPatterns $patterns) + { + $this->patterns = $patterns; + } + + /** + * @param string $value + * + * @return string + */ + public function escapeUnicode($value) + { + $value = $this->replaceUnicodeSequences($value); + + return preg_replace($this->patterns->getSimpleEscapePattern(), '$1', $value); + } + + /** + * @param string $value + * + * @return string + */ + public function escapeUnicodeAndNewLine($value) + { + $value = preg_replace($this->patterns->getNewLineEscapePattern(), '', $value); + + return $this->escapeUnicode($value); + } + + /** + * @param string $value + * + * @return string + */ + private function replaceUnicodeSequences($value) + { + return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function ($match) { + $c = hexdec($match[1]); + + if (0x80 > $c %= 0x200000) { + return chr($c); + } + if (0x800 > $c) { + return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F); + } + if (0x10000 > $c) { + return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); + } + }, $value); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php new file mode 100644 index 0000000..326f020 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php @@ -0,0 +1,160 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Tokenizer; + +/** + * CSS selector tokenizer patterns builder. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class TokenizerPatterns +{ + /** + * @var string + */ + private $unicodeEscapePattern; + + /** + * @var string + */ + private $simpleEscapePattern; + + /** + * @var string + */ + private $newLineEscapePattern; + + /** + * @var string + */ + private $escapePattern; + + /** + * @var string + */ + private $stringEscapePattern; + + /** + * @var string + */ + private $nonAsciiPattern; + + /** + * @var string + */ + private $nmCharPattern; + + /** + * @var string + */ + private $nmStartPattern; + + /** + * @var string + */ + private $identifierPattern; + + /** + * @var string + */ + private $hashPattern; + + /** + * @var string + */ + private $numberPattern; + + /** + * @var string + */ + private $quotedStringPattern; + + /** + * Constructor. + */ + public function __construct() + { + $this->unicodeEscapePattern = '\\\\([0-9a-f]{1,6})(?:\r\n|[ \n\r\t\f])?'; + $this->simpleEscapePattern = '\\\\(.)'; + $this->newLineEscapePattern = '\\\\(?:\n|\r\n|\r|\f)'; + $this->escapePattern = $this->unicodeEscapePattern.'|\\\\[^\n\r\f0-9a-f]'; + $this->stringEscapePattern = $this->newLineEscapePattern.'|'.$this->escapePattern; + $this->nonAsciiPattern = '[^\x00-\x7F]'; + $this->nmCharPattern = '[_a-z0-9-]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; + $this->nmStartPattern = '[_a-z]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; + $this->identifierPattern = '(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*'; + $this->hashPattern = '#((?:'.$this->nmCharPattern.')+)'; + $this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)'; + $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*'; + } + + /** + * @return string + */ + public function getNewLineEscapePattern() + { + return '~^'.$this->newLineEscapePattern.'~'; + } + + /** + * @return string + */ + public function getSimpleEscapePattern() + { + return '~^'.$this->simpleEscapePattern.'~'; + } + + /** + * @return string + */ + public function getUnicodeEscapePattern() + { + return '~^'.$this->unicodeEscapePattern.'~i'; + } + + /** + * @return string + */ + public function getIdentifierPattern() + { + return '~^'.$this->identifierPattern.'~i'; + } + + /** + * @return string + */ + public function getHashPattern() + { + return '~^'.$this->hashPattern.'~i'; + } + + /** + * @return string + */ + public function getNumberPattern() + { + return '~^'.$this->numberPattern.'~'; + } + + /** + * @param string $quote + * + * @return string + */ + public function getQuotedStringPattern($quote) + { + return '~^'.sprintf($this->quotedStringPattern, $quote).'~i'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md b/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md index 2424bea..ffe6c89 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md @@ -6,20 +6,42 @@ CssSelector converts CSS selectors to XPath expressions. The component only goal is to convert CSS selectors to their XPath equivalents: - use Symfony\Component\CssSelector\CssSelector; +```php +use Symfony\Component\CssSelector\CssSelector; - print CssSelector::toXPath('div.item > h4 > a'); +print CssSelector::toXPath('div.item > h4 > a'); +``` + +HTML and XML are different +-------------------------- + +The `CssSelector` component comes with an `HTML` extension which is enabled by +default. If you need to use this component with `XML` documents, you have to +disable this `HTML` extension. That's because, `HTML` tag & attribute names +are always lower-cased, but case-sensitive in `XML`: + +```php +// disable `HTML` extension: +CssSelector::disableHtmlExtension(); + +// re-enable `HTML` extension: +CssSelector::enableHtmlExtension(); +``` + +When the `HTML` extension is enabled, tag names are lower-cased, attribute +names are lower-cased, the following extra pseudo-classes are supported: +`checked`, `link`, `disabled`, `enabled`, `selected`, `invalid`, `hover`, +`visited`, and the `lang()` function is also added. Resources --------- -This component is a port of the Python lxml library, which is copyright Infrae -and distributed under the BSD license. - -Current code is a port of https://github.com/SimonSapin/cssselect@fd2e70 +This component is a port of the Python cssselect library +[v0.7.1](https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1), +which is distributed under the BSD license. You can run the unit tests with the following command: $ cd path/to/Symfony/Component/CssSelector/ - $ composer.phar install --dev + $ composer install $ phpunit diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/CssSelectorTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/CssSelectorTest.php index 0d9ca85..61ab80e 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/CssSelectorTest.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/CssSelectorTest.php @@ -15,57 +15,50 @@ class CssSelectorTest extends \PHPUnit_Framework_TestCase { - public function testCsstoXPath() + public function testCssToXPath() { $this->assertEquals('descendant-or-self::*', CssSelector::toXPath('')); $this->assertEquals('descendant-or-self::h1', CssSelector::toXPath('h1')); $this->assertEquals("descendant-or-self::h1[@id = 'foo']", CssSelector::toXPath('h1#foo')); - $this->assertEquals("descendant-or-self::h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", CssSelector::toXPath('h1.foo')); - + $this->assertEquals("descendant-or-self::h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", CssSelector::toXPath('h1.foo')); $this->assertEquals('descendant-or-self::foo:h1', CssSelector::toXPath('foo|h1')); } - /** - * @dataProvider getCssSelectors - */ - public function testParse($css, $xpath) + /** @dataProvider getCssToXPathWithoutPrefixTestData */ + public function testCssToXPathWithoutPrefix($css, $xpath) { - $parser = new CssSelector(); - - $this->assertEquals($xpath, (string) $parser->parse($css)->toXPath(), '->parse() parses an input string and returns a node'); + $this->assertEquals($xpath, CssSelector::toXPath($css, ''), '->parse() parses an input string and returns a node'); } public function testParseExceptions() { - $parser = new CssSelector(); - try { - $parser->parse('h1:'); + CssSelector::toXPath('h1:'); $this->fail('->parse() throws an Exception if the css selector is not valid'); } catch (\Exception $e) { $this->assertInstanceOf('\Symfony\Component\CssSelector\Exception\ParseException', $e, '->parse() throws an Exception if the css selector is not valid'); - $this->assertEquals("Expected symbol, got '' at h1: -> ", $e->getMessage(), '->parse() throws an Exception if the css selector is not valid'); + $this->assertEquals('Expected identifier, but found.', $e->getMessage(), '->parse() throws an Exception if the css selector is not valid'); } } - public function getCssSelectors() + public function getCssToXPathWithoutPrefixTestData() { return array( - array('h1', "h1"), - array('foo|h1', "foo:h1"), - array('h1, h2, h3', "h1 | h2 | h3"), - array('h1:nth-child(3n+1)', "*/*[name() = 'h1' and ((position() -1) mod 3 = 0 and position() >= 1)]"), - array('h1 > p', "h1/p"), + array('h1', 'h1'), + array('foo|h1', 'foo:h1'), + array('h1, h2, h3', 'h1 | h2 | h3'), + array('h1:nth-child(3n+1)', "*/*[name() = 'h1' and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"), + array('h1 > p', 'h1/p'), array('h1#foo', "h1[@id = 'foo']"), - array('h1.foo', "h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), - array('h1[class*="foo bar"]', "h1[contains(@class, 'foo bar')]"), - array('h1[foo|class*="foo bar"]', "h1[contains(@foo:class, 'foo bar')]"), - array('h1[class]', "h1[@class]"), - array('h1 .foo', "h1/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), - array('h1 #foo', "h1/descendant::*[@id = 'foo']"), - array('h1 [class*=foo]', "h1/descendant::*[contains(@class, 'foo')]"), - array('div>.foo', "div/*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), - array('div > .foo', "div/*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"), + array('h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"), + array('h1[class]', 'h1[@class]'), + array('h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"), + array('h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"), + array('div>.foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('div > .foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), ); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php new file mode 100644 index 0000000..16a3a34 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\NodeInterface; + +abstract class AbstractNodeTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getToStringConversionTestData */ + public function testToStringConversion(NodeInterface $node, $representation) + { + $this->assertEquals($representation, (string) $node); + } + + /** @dataProvider getSpecificityValueTestData */ + public function testSpecificityValue(NodeInterface $node, $value) + { + $this->assertEquals($value, $node->getSpecificity()->getValue()); + } + + abstract public function getToStringConversionTestData(); + abstract public function getSpecificityValueTestData(); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttribNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttribNodeTest.php deleted file mode 100644 index 2f19fe2..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttribNodeTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector\Tests\Node; - -use Symfony\Component\CssSelector\Node\AttribNode; -use Symfony\Component\CssSelector\Node\ElementNode; - -class AttribNodeTest extends \PHPUnit_Framework_TestCase -{ - public function testToXpath() - { - $element = new ElementNode('*', 'h1'); - - $operators = array( - '^=' => "h1[starts-with(@class, 'foo')]", - '$=' => "h1[substring(@class, string-length(@class)-2) = 'foo']", - '*=' => "h1[contains(@class, 'foo')]", - '=' => "h1[@class = 'foo']", - '~=' => "h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", - '|=' => "h1[@class = 'foo' or starts-with(@class, 'foo-')]", - '!=' => "h1[not(@class) or @class != 'foo']", - ); - - // h1[class??foo] - foreach ($operators as $op => $xpath) { - $attrib = new AttribNode($element, '*', 'class', $op, 'foo'); - $this->assertEquals($xpath, (string) $attrib->toXpath(), '->toXpath() returns the xpath representation of the node'); - } - - // h1[class] - $attrib = new AttribNode($element, '*', 'class', 'exists', 'foo'); - $this->assertEquals('h1[@class]', (string) $attrib->toXpath(), '->toXpath() returns the xpath representation of the node'); - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php new file mode 100644 index 0000000..1fd090f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\AttributeNode; +use Symfony\Component\CssSelector\Node\ElementNode; + +class AttributeNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 'Attribute[Element[*][attribute]]'), + array(new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), "Attribute[Element[*][attribute $= 'value']]"), + array(new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), "Attribute[Element[*][namespace|attribute $= 'value']]"), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 10), + array(new AttributeNode(new ElementNode(null, 'element'), null, 'attribute', 'exists', null), 11), + array(new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), 10), + array(new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), 10), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php index c0a96f1..e0ab45a 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php @@ -14,14 +14,20 @@ use Symfony\Component\CssSelector\Node\ClassNode; use Symfony\Component\CssSelector\Node\ElementNode; -class ClassNodeTest extends \PHPUnit_Framework_TestCase +class ClassNodeTest extends AbstractNodeTest { - public function testToXpath() + public function getToStringConversionTestData() { - // h1.foo - $element = new ElementNode('*', 'h1'); - $class = new ClassNode($element, 'foo'); + return array( + array(new ClassNode(new ElementNode(), 'class'), 'Class[Element[*].class]'), + ); + } - $this->assertEquals("h1[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", (string) $class->toXpath(), '->toXpath() returns the xpath representation of the node'); + public function getSpecificityValueTestData() + { + return array( + array(new ClassNode(new ElementNode(), 'class'), 10), + array(new ClassNode(new ElementNode(null, 'element'), 'class'), 11), + ); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php index 28f4e28..9547298 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php @@ -14,23 +14,22 @@ use Symfony\Component\CssSelector\Node\CombinedSelectorNode; use Symfony\Component\CssSelector\Node\ElementNode; -class CombinedSelectorNodeTest extends \PHPUnit_Framework_TestCase +class CombinedSelectorNodeTest extends AbstractNodeTest { - public function testToXpath() + public function getToStringConversionTestData() { - $combinators = array( - ' ' => "h1/descendant::p", - '>' => "h1/p", - '+' => "h1/following-sibling::*[name() = 'p' and (position() = 1)]", - '~' => "h1/following-sibling::p", + return array( + array(new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 'CombinedSelector[Element[*] > Element[*]]'), + array(new CombinedSelectorNode(new ElementNode(), ' ', new ElementNode()), 'CombinedSelector[Element[*] Element[*]]'), ); + } - // h1 ?? p - $element1 = new ElementNode('*', 'h1'); - $element2 = new ElementNode('*', 'p'); - foreach ($combinators as $combinator => $xpath) { - $combinator = new CombinedSelectorNode($element1, $combinator, $element2); - $this->assertEquals($xpath, (string) $combinator->toXpath(), '->toXpath() returns the xpath representation of the node'); - } + public function getSpecificityValueTestData() + { + return array( + array(new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 0), + array(new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode()), 1), + array(new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode(null, 'element')), 2), + ); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php index 5d23e3f..1db6a59 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php @@ -13,18 +13,23 @@ use Symfony\Component\CssSelector\Node\ElementNode; -class ElementNodeTest extends \PHPUnit_Framework_TestCase +class ElementNodeTest extends AbstractNodeTest { - public function testToXpath() + public function getToStringConversionTestData() { - // h1 - $element = new ElementNode('*', 'h1'); - - $this->assertEquals('h1', (string) $element->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // foo|h1 - $element = new ElementNode('foo', 'h1'); + return array( + array(new ElementNode(), 'Element[*]'), + array(new ElementNode(null, 'element'), 'Element[element]'), + array(new ElementNode('namespace', 'element'), 'Element[namespace|element]'), + ); + } - $this->assertEquals('foo:h1', (string) $element->toXpath(), '->toXpath() returns the xpath representation of the node'); + public function getSpecificityValueTestData() + { + return array( + array(new ElementNode(), 0), + array(new ElementNode(null, 'element'), 1), + array(new ElementNode('namespace', 'element'),1), + ); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php index 9654402..ee3ce51 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php @@ -11,86 +11,37 @@ namespace Symfony\Component\CssSelector\Tests\Node; -use Symfony\Component\CssSelector\Node\FunctionNode; use Symfony\Component\CssSelector\Node\ElementNode; -use Symfony\Component\CssSelector\Token; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\Parser\Token; -class FunctionNodeTest extends \PHPUnit_Framework_TestCase +class FunctionNodeTest extends AbstractNodeTest { - public function testToXpath() + public function getToStringConversionTestData() { - $element = new ElementNode('*', 'h1'); - - // h1:contains("foo") - $function = new FunctionNode($element, ':', 'contains', 'foo'); - $this->assertEquals("h1[contains(string(.), 'foo')]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(1) - $function = new FunctionNode($element, ':', 'nth-child', 1); - $this->assertEquals("*/*[name() = 'h1' and (position() = 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child() - $function = new FunctionNode($element, ':', 'nth-child', ''); - $this->assertEquals("h1[false() and position() = 0]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(odd) - $element2 = new ElementNode('*', new Token('Symbol', 'odd', -1)); - $function = new FunctionNode($element, ':', 'nth-child', $element2); - $this->assertEquals("*/*[name() = 'h1' and ((position() -1) mod 2 = 0 and position() >= 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(even) - $element2 = new ElementNode('*', new Token('Symbol', 'even', -1)); - $function = new FunctionNode($element, ':', 'nth-child', $element2); - $this->assertEquals("*/*[name() = 'h1' and ((position() +0) mod 2 = 0 and position() >= 0)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(n) - $element2 = new ElementNode('*', new Token('Symbol', 'n', -1)); - $function = new FunctionNode($element, ':', 'nth-child', $element2); - $this->assertEquals("*/*[name() = 'h1' and (position() >= 0)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(3n+1) - $element2 = new ElementNode('*', new Token('Symbol', '3n+1', -1)); - $function = new FunctionNode($element, ':', 'nth-child', $element2); - $this->assertEquals("*/*[name() = 'h1' and ((position() -1) mod 3 = 0 and position() >= 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(n+1) - $element2 = new ElementNode('*', new Token('Symbol', 'n+1', -1)); - $function = new FunctionNode($element, ':', 'nth-child', $element2); - $this->assertEquals("*/*[name() = 'h1' and (position() >= 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(1) - $element2 = new ElementNode('*', new Token('Symbol', '2', -1)); - $function = new FunctionNode($element, ':', 'nth-child', $element2); - $this->assertEquals("*/*[name() = 'h1' and (position() = 2)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(2n) - $element2 = new ElementNode('*', new Token('Symbol', '2n', -1)); - $function = new FunctionNode($element, ':', 'nth-child', $element2); - $this->assertEquals("*/*[name() = 'h1' and ((position() +0) mod 2 = 0 and position() >= 0)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-child(-n) - $element2 = new ElementNode('*', new Token('Symbol', '-n', -1)); - $function = new FunctionNode($element, ':', 'nth-child', $element2); - $this->assertEquals("*/*[name() = 'h1' and ((position() +0) mod -1 = 0 and position() >= 0)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-last-child(2) - $function = new FunctionNode($element, ':', 'nth-last-child', 2); - $this->assertEquals("*/*[name() = 'h1' and (position() = last() - 2)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-of-type(2) - $function = new FunctionNode($element, ':', 'nth-of-type', 2); - $this->assertEquals("*/h1[position() = 2]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:nth-last-of-type(2) - $function = new FunctionNode($element, ':', 'nth-last-of-type', 2); - $this->assertEquals("*/h1[position() = last() - 2]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - - /* - // h1:not(p) - $element2 = new ElementNode('*', 'p'); - $function = new FunctionNode($element, ':', 'not', $element2); + return array( + array(new FunctionNode(new ElementNode(), 'function'), 'Function[Element[*]:function()]'), + array(new FunctionNode(new ElementNode(), 'function', array( + new Token(Token::TYPE_IDENTIFIER, 'value', 0), + )), "Function[Element[*]:function(['value'])]"), + array(new FunctionNode(new ElementNode(), 'function', array( + new Token(Token::TYPE_STRING, 'value1', 0), + new Token(Token::TYPE_NUMBER, 'value2', 0), + )), "Function[Element[*]:function(['value1', 'value2'])]"), + ); + } - $this->assertEquals("h1[not()]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); - */ + public function getSpecificityValueTestData() + { + return array( + array(new FunctionNode(new ElementNode(), 'function'), 10), + array(new FunctionNode(new ElementNode(), 'function', array( + new Token(Token::TYPE_IDENTIFIER, 'value', 0), + )), 10), + array(new FunctionNode(new ElementNode(), 'function', array( + new Token(Token::TYPE_STRING, 'value1', 0), + new Token(Token::TYPE_NUMBER, 'value2', 0), + )), 10), + ); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php index d919747..8554b22 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php @@ -14,14 +14,20 @@ use Symfony\Component\CssSelector\Node\HashNode; use Symfony\Component\CssSelector\Node\ElementNode; -class HashNodeTest extends \PHPUnit_Framework_TestCase +class HashNodeTest extends AbstractNodeTest { - public function testToXpath() + public function getToStringConversionTestData() { - // h1#foo - $element = new ElementNode('*', 'h1'); - $hash = new HashNode($element, 'foo'); + return array( + array(new HashNode(new ElementNode(), 'id'), 'Hash[Element[*]#id]'), + ); + } - $this->assertEquals("h1[@id = 'foo']", (string) $hash->toXpath(), '->toXpath() returns the xpath representation of the node'); + public function getSpecificityValueTestData() + { + return array( + array(new HashNode(new ElementNode(), 'id'), 100), + array(new HashNode(new ElementNode(null, 'id'), 'class'), 101), + ); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php new file mode 100644 index 0000000..edf4552 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\ClassNode; +use Symfony\Component\CssSelector\Node\NegationNode; +use Symfony\Component\CssSelector\Node\ElementNode; + +class NegationNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 'Negation[Element[*]:not(Class[Element[*].class])]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 10), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/OrNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/OrNodeTest.php deleted file mode 100644 index 9b9e6e3..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/OrNodeTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector\Tests\Node; - -use Symfony\Component\CssSelector\Node\OrNode; -use Symfony\Component\CssSelector\Node\ElementNode; - -class OrNodeTest extends \PHPUnit_Framework_TestCase -{ - public function testToXpath() - { - // h1, h2, h3 - $element1 = new ElementNode('*', 'h1'); - $element2 = new ElementNode('*', 'h2'); - $element3 = new ElementNode('*', 'h3'); - $or = new OrNode(array($element1, $element2, $element3)); - - $this->assertEquals("h1 | h2 | h3", (string) $or->toXpath(), '->toXpath() returns the xpath representation of the node'); - } - - public function testIssueMissingPrefix() - { - // h1, h2, h3 - $element1 = new ElementNode('*', 'h1'); - $element2 = new ElementNode('*', 'h2'); - $element3 = new ElementNode('*', 'h3'); - $or = new OrNode(array($element1, $element2, $element3)); - - $xPath = $or->toXPath(); - $xPath->addPrefix('descendant-or-self::'); - - $this->assertEquals("descendant-or-self::h1 | descendant-or-self::h2 | descendant-or-self::h3", (string) $xPath); - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php index 8bd0cec..bc57813 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php @@ -11,45 +11,22 @@ namespace Symfony\Component\CssSelector\Tests\Node; -use Symfony\Component\CssSelector\Node\PseudoNode; use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\PseudoNode; -class PseudoNodeTest extends \PHPUnit_Framework_TestCase +class PseudoNodeTest extends AbstractNodeTest { - public function testToXpath() + public function getToStringConversionTestData() { - $element = new ElementNode('*', 'h1'); - - // h1:checked - $pseudo = new PseudoNode($element, ':', 'checked'); - $this->assertEquals("h1[(@selected or @checked) and (name(.) = 'input' or name(.) = 'option')]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:first-child - $pseudo = new PseudoNode($element, ':', 'first-child'); - $this->assertEquals("*/*[name() = 'h1' and (position() = 1)]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:last-child - $pseudo = new PseudoNode($element, ':', 'last-child'); - $this->assertEquals("*/*[name() = 'h1' and (position() = last())]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:first-of-type - $pseudo = new PseudoNode($element, ':', 'first-of-type'); - $this->assertEquals("*/h1[position() = 1]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:last-of-type - $pseudo = new PseudoNode($element, ':', 'last-of-type'); - $this->assertEquals("*/h1[position() = last()]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:only-child - $pseudo = new PseudoNode($element, ':', 'only-child'); - $this->assertEquals("*/*[name() = 'h1' and (last() = 1)]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); - - // h1:only-of-type - $pseudo = new PseudoNode($element, ':', 'only-of-type'); - $this->assertEquals("h1[last() = 1]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + return array( + array(new PseudoNode(new ElementNode(), 'pseudo'), 'Pseudo[Element[*]:pseudo]'), + ); + } - // h1:empty - $pseudo = new PseudoNode($element, ':', 'empty'); - $this->assertEquals("h1[not(*) and not(normalize-space())]", (string) $pseudo->toXpath(), '->toXpath() returns the xpath representation of the node'); + public function getSpecificityValueTestData() + { + return array( + array(new PseudoNode(new ElementNode(), 'pseudo'), 10), + ); } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php new file mode 100644 index 0000000..5badf71 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\SelectorNode; + +class SelectorNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new SelectorNode(new ElementNode()), 'Selector[Element[*]]'), + array(new SelectorNode(new ElementNode(), 'pseudo'), 'Selector[Element[*]::pseudo]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new SelectorNode(new ElementNode()), 0), + array(new SelectorNode(new ElementNode(), 'pseudo'), 1), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php new file mode 100644 index 0000000..c34fe5f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\Specificity; + +class SpecificityTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getValueTestData */ + public function testValue(Specificity $specificity, $value) + { + $this->assertEquals($value, $specificity->getValue()); + } + + /** @dataProvider getValueTestData */ + public function testPlusValue(Specificity $specificity, $value) + { + $this->assertEquals($value + 123, $specificity->plus(new Specificity(1, 2, 3))->getValue()); + } + + public function getValueTestData() + { + return array( + array(new Specificity(0, 0, 0), 0), + array(new Specificity(0, 0, 2), 2), + array(new Specificity(0, 3, 0), 30), + array(new Specificity(4, 0, 0), 400), + array(new Specificity(4, 3, 2), 432), + ); + } + + /** @dataProvider getCompareTestData */ + public function testCompareTo(Specificity $a, Specificity $b, $result) + { + $this->assertEquals($result, $a->compareTo($b)); + } + + public function getCompareTestData() + { + return array( + array(new Specificity(0, 0, 0), new Specificity(0, 0, 0), 0), + array(new Specificity(0, 0, 1), new Specificity(0, 0, 1), 0), + array(new Specificity(0, 0, 2), new Specificity(0, 0, 1), 1), + array(new Specificity(0, 0, 2), new Specificity(0, 0, 3), -1), + array(new Specificity(0, 4, 0), new Specificity(0, 4, 0), 0), + array(new Specificity(0, 6, 0), new Specificity(0, 5, 11), 1), + array(new Specificity(0, 7, 0), new Specificity(0, 8, 0), -1), + array(new Specificity(9, 0, 0), new Specificity(9, 0, 0), 0), + array(new Specificity(11, 0, 0), new Specificity(10, 11, 0), 1), + array(new Specificity(12, 11, 0), new Specificity(13, 0, 0), -1), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php new file mode 100644 index 0000000..a06dca0 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * @author Jean-François Simon + */ +abstract class AbstractHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getHandleValueTestData */ + public function testHandleValue($value, Token $expectedToken, $remainingContent) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertTrue($this->generateHandler()->handle($reader, $stream)); + $this->assertEquals($expectedToken, $stream->getNext()); + $this->assertRemainingContent($reader, $remainingContent); + } + + /** @dataProvider getDontHandleValueTestData */ + public function testDontHandleValue($value) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertFalse($this->generateHandler()->handle($reader, $stream)); + $this->assertStreamEmpty($stream); + $this->assertRemainingContent($reader, $value); + } + + abstract public function getHandleValueTestData(); + abstract public function getDontHandleValueTestData(); + abstract protected function generateHandler(); + + protected function assertStreamEmpty(TokenStream $stream) + { + $property = new \ReflectionProperty($stream, 'tokens'); + $property->setAccessible(true); + + $this->assertEquals(array(), $property->getValue($stream)); + } + + protected function assertRemainingContent(Reader $reader, $remainingContent) + { + if ('' === $remainingContent) { + $this->assertEquals(0, $reader->getRemainingLength()); + $this->assertTrue($reader->isEOF()); + } else { + $this->assertEquals(strlen($remainingContent), $reader->getRemainingLength()); + $this->assertEquals(0, $reader->getOffset($remainingContent)); + } + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php new file mode 100644 index 0000000..3961bf7 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\CommentHandler; +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +class CommentHandlerTest extends AbstractHandlerTest +{ + /** @dataProvider getHandleValueTestData */ + public function testHandleValue($value, Token $unusedArgument, $remainingContent) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertTrue($this->generateHandler()->handle($reader, $stream)); + // comments are ignored (not pushed as token in stream) + $this->assertStreamEmpty($stream); + $this->assertRemainingContent($reader, $remainingContent); + } + + public function getHandleValueTestData() + { + return array( + // 2nd argument only exists for inherited method compatibility + array('/* comment */', new Token(null, null, null), ''), + array('/* comment */foo', new Token(null, null, null), 'foo'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('>'), + array('+'), + array(' '), + ); + } + + protected function generateHandler() + { + return new CommentHandler(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php new file mode 100644 index 0000000..b7fa00a --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\HashHandler; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; + +class HashHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array('#id', new Token(Token::TYPE_HASH, 'id', 0), ''), + array('#123', new Token(Token::TYPE_HASH, '123', 0), ''), + + array('#id.class', new Token(Token::TYPE_HASH, 'id', 0), '.class'), + array('#id element', new Token(Token::TYPE_HASH, 'id', 0), ' element'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('id'), + array('123'), + array('<'), + array('<'), + array('#'), + ); + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new HashHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php new file mode 100644 index 0000000..44d3574 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; + +class IdentifierHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array('foo', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ''), + array('foo|bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '|bar'), + array('foo.class', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '.class'), + array('foo[attr]', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '[attr]'), + array('foo bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ' bar'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('>'), + array('+'), + array(' '), + array('*|foo'), + array('/* comment */'), + ); + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new IdentifierHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php new file mode 100644 index 0000000..675fd05 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\NumberHandler; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +class NumberHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array('12', new Token(Token::TYPE_NUMBER, '12', 0), ''), + array('12.34', new Token(Token::TYPE_NUMBER, '12.34', 0), ''), + array('+12.34', new Token(Token::TYPE_NUMBER, '+12.34', 0), ''), + array('-12.34', new Token(Token::TYPE_NUMBER, '-12.34', 0), ''), + + array('12 arg', new Token(Token::TYPE_NUMBER, '12', 0), ' arg'), + array('12]', new Token(Token::TYPE_NUMBER, '12', 0), ']'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('hello'), + array('>'), + array('+'), + array(' '), + array('/* comment */'), + ); + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new NumberHandler($patterns); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php new file mode 100644 index 0000000..89eff8b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\StringHandler; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; + +class StringHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array('"hello"', new Token(Token::TYPE_STRING, 'hello', 1), ''), + array('"1"', new Token(Token::TYPE_STRING, '1', 1), ''), + array('" "', new Token(Token::TYPE_STRING, ' ', 1), ''), + array('""', new Token(Token::TYPE_STRING, '', 1), ''), + array("'hello'", new Token(Token::TYPE_STRING, 'hello', 1), ''), + + array("'foo'bar", new Token(Token::TYPE_STRING, 'foo', 1), 'bar'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('hello'), + array('>'), + array('1'), + array(' '), + ); + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new StringHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php new file mode 100644 index 0000000..f5f9e71 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\WhitespaceHandler; +use Symfony\Component\CssSelector\Parser\Token; + +class WhitespaceHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array(' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''), + array("\n", new Token(Token::TYPE_WHITESPACE, "\n", 0), ''), + array("\t", new Token(Token::TYPE_WHITESPACE, "\t", 0), ''), + + array(' foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), 'foo'), + array(' .foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), '.foo'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('>'), + array('1'), + array('a'), + ); + } + + protected function generateHandler() + { + return new WhitespaceHandler(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php new file mode 100644 index 0000000..0454d9f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php @@ -0,0 +1,248 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser; + +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Parser; +use Symfony\Component\CssSelector\Parser\Token; + +class ParserTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getParserTestData */ + public function testParser($source, $representation) + { + $parser = new Parser(); + + $this->assertEquals($representation, array_map(function (SelectorNode $node) { + return (string) $node->getTree(); + }, $parser->parse($source))); + } + + /** @dataProvider getParserExceptionTestData */ + public function testParserException($source, $message) + { + $parser = new Parser(); + + try { + $parser->parse($source); + $this->fail('Parser should throw a SyntaxErrorException.'); + } catch (SyntaxErrorException $e) { + $this->assertEquals($message, $e->getMessage()); + } + } + + /** @dataProvider getPseudoElementsTestData */ + public function testPseudoElements($source, $element, $pseudo) + { + $parser = new Parser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($element, (string) $selector->getTree()); + $this->assertEquals($pseudo, (string) $selector->getPseudoElement()); + } + + /** @dataProvider getSpecificityTestData */ + public function testSpecificity($source, $value) + { + $parser = new Parser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($value, $selector->getSpecificity()->getValue()); + } + + /** @dataProvider getParseSeriesTestData */ + public function testParseSeries($series, $a, $b) + { + $parser = new Parser(); + $selectors = $parser->parse(sprintf(':nth-child(%s)', $series)); + $this->assertCount(1, $selectors); + + /** @var FunctionNode $function */ + $function = $selectors[0]->getTree(); + $this->assertEquals(array($a, $b), Parser::parseSeries($function->getArguments())); + } + + /** @dataProvider getParseSeriesExceptionTestData */ + public function testParseSeriesException($series) + { + $parser = new Parser(); + $selectors = $parser->parse(sprintf(':nth-child(%s)', $series)); + $this->assertCount(1, $selectors); + + /** @var FunctionNode $function */ + $function = $selectors[0]->getTree(); + $this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + Parser::parseSeries($function->getArguments()); + } + + public function getParserTestData() + { + return array( + array('*', array('Element[*]')), + array('*|*', array('Element[*]')), + array('*|foo', array('Element[foo]')), + array('foo|*', array('Element[foo|*]')), + array('foo|bar', array('Element[foo|bar]')), + array('#foo#bar', array('Hash[Hash[Element[*]#foo]#bar]')), + array('div>.foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array('div> .foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array('div >.foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array('div > .foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array("div \n> \t \t .foo", array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array('td.foo,.bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array('td.foo, .bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array("td.foo\t\r\n\f ,\t\r\n\f .bar", array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array('td.foo,.bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array('td.foo, .bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array("td.foo\t\r\n\f ,\t\r\n\f .bar", array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array('div, td.foo, div.bar span', array('Element[div]', 'Class[Element[td].foo]', 'CombinedSelector[Class[Element[div].bar] Element[span]]')), + array('div > p', array('CombinedSelector[Element[div] > Element[p]]')), + array('td:first', array('Pseudo[Element[td]:first]')), + array('td :first', array('CombinedSelector[Element[td] Pseudo[Element[*]:first]]')), + array('a[name]', array('Attribute[Element[a][name]]')), + array("a[ name\t]", array('Attribute[Element[a][name]]')), + array('a [name]', array('CombinedSelector[Element[a] Attribute[Element[*][name]]]')), + array('a[rel="include"]', array("Attribute[Element[a][rel = 'include']]")), + array('a[rel = include]', array("Attribute[Element[a][rel = 'include']]")), + array("a[hreflang |= 'en']", array("Attribute[Element[a][hreflang |= 'en']]")), + array('a[hreflang|=en]', array("Attribute[Element[a][hreflang |= 'en']]")), + array('div:nth-child(10)', array("Function[Element[div]:nth-child(['10'])]")), + array(':nth-child(2n+2)', array("Function[Element[*]:nth-child(['2', 'n', '+2'])]")), + array('div:nth-of-type(10)', array("Function[Element[div]:nth-of-type(['10'])]")), + array('div div:nth-of-type(10) .aclass', array("CombinedSelector[CombinedSelector[Element[div] Function[Element[div]:nth-of-type(['10'])]] Class[Element[*].aclass]]")), + array('label:only', array('Pseudo[Element[label]:only]')), + array('a:lang(fr)', array("Function[Element[a]:lang(['fr'])]")), + array('div:contains("foo")', array("Function[Element[div]:contains(['foo'])]")), + array('div#foobar', array('Hash[Element[div]#foobar]')), + array('div:not(div.foo)', array('Negation[Element[div]:not(Class[Element[div].foo])]')), + array('td ~ th', array('CombinedSelector[Element[td] ~ Element[th]]')), + array('.foo[data-bar][data-baz=0]', array("Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]")), + ); + } + + public function getParserExceptionTestData() + { + return array( + array('attributes(href)/html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()), + array('attributes(href)', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()), + array('html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '/', 4))->getMessage()), + array(' ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 1))->getMessage()), + array('div, ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 5))->getMessage()), + array(' , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 1))->getMessage()), + array('p, , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 3))->getMessage()), + array('div > ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 6))->getMessage()), + array(' > div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '>', 2))->getMessage()), + array('foo|#bar', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_HASH, 'bar', 4))->getMessage()), + array('#.foo', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '#', 0))->getMessage()), + array('.#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()), + array(':#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()), + array('[*]', SyntaxErrorException::unexpectedToken('"|"', new Token(Token::TYPE_DELIMITER, ']', 2))->getMessage()), + array('[foo|]', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_DELIMITER, ']', 5))->getMessage()), + array('[#]', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_DELIMITER, '#', 1))->getMessage()), + array('[foo=#]', SyntaxErrorException::unexpectedToken('string or identifier', new Token(Token::TYPE_DELIMITER, '#', 5))->getMessage()), + array(':nth-child()', SyntaxErrorException::unexpectedToken('at least one argument', new Token(Token::TYPE_DELIMITER, ')', 11))->getMessage()), + array('[href]a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_IDENTIFIER, 'a', 6))->getMessage()), + array('[rel:stylesheet]', SyntaxErrorException::unexpectedToken('operator', new Token(Token::TYPE_DELIMITER, ':', 4))->getMessage()), + array('[rel=stylesheet', SyntaxErrorException::unexpectedToken('"]"', new Token(Token::TYPE_FILE_END, '', 15))->getMessage()), + array(':lang(fr', SyntaxErrorException::unexpectedToken('an argument', new Token(Token::TYPE_FILE_END, '', 8))->getMessage()), + array(':contains("foo', SyntaxErrorException::unclosedString(10)->getMessage()), + array('foo!', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '!', 3))->getMessage()), + ); + } + + public function getPseudoElementsTestData() + { + return array( + array('foo', 'Element[foo]', ''), + array('*', 'Element[*]', ''), + array(':empty', 'Pseudo[Element[*]:empty]', ''), + array(':BEfore', 'Element[*]', 'before'), + array(':aftER', 'Element[*]', 'after'), + array(':First-Line', 'Element[*]', 'first-line'), + array(':First-Letter', 'Element[*]', 'first-letter'), + array('::befoRE', 'Element[*]', 'before'), + array('::AFter', 'Element[*]', 'after'), + array('::firsT-linE', 'Element[*]', 'first-line'), + array('::firsT-letteR', 'Element[*]', 'first-letter'), + array('::Selection', 'Element[*]', 'selection'), + array('foo:after', 'Element[foo]', 'after'), + array('foo::selection', 'Element[foo]', 'selection'), + array('lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'), + ); + } + + public function getSpecificityTestData() + { + return array( + array('*', 0), + array(' foo', 1), + array(':empty ', 10), + array(':before', 1), + array('*:before', 1), + array(':nth-child(2)', 10), + array('.bar', 10), + array('[baz]', 10), + array('[baz="4"]', 10), + array('[baz^="4"]', 10), + array('#lipsum', 100), + array(':not(*)', 0), + array(':not(foo)', 1), + array(':not(.foo)', 10), + array(':not([foo])', 10), + array(':not(:empty)', 10), + array(':not(#foo)', 100), + array('foo:empty', 11), + array('foo:before', 2), + array('foo::before', 2), + array('foo:empty::before', 12), + array('#lorem + foo#ipsum:first-child > bar:first-line', 213), + ); + } + + public function getParseSeriesTestData() + { + return array( + array('1n+3', 1, 3), + array('1n +3', 1, 3), + array('1n + 3', 1, 3), + array('1n+ 3', 1, 3), + array('1n-3', 1, -3), + array('1n -3', 1, -3), + array('1n - 3', 1, -3), + array('1n- 3', 1, -3), + array('n-5', 1, -5), + array('odd', 2, 1), + array('even', 2, 0), + array('3n', 3, 0), + array('n', 1, 0), + array('+n', 1, 0), + array('-n', -1, 0), + array('5', 0, 5), + ); + } + + public function getParseSeriesExceptionTestData() + { + return array( + array('foo'), + array('n+'), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php new file mode 100644 index 0000000..03c054e --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php @@ -0,0 +1,101 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser; + +use Symfony\Component\CssSelector\Parser\Reader; + +class ReaderTest extends \PHPUnit_Framework_TestCase +{ + public function testIsEOF() + { + $reader = new Reader(''); + $this->assertTrue($reader->isEOF()); + + $reader = new Reader('hello'); + $this->assertFalse($reader->isEOF()); + + $this->assignPosition($reader, 2); + $this->assertFalse($reader->isEOF()); + + $this->assignPosition($reader, 5); + $this->assertTrue($reader->isEOF()); + } + + public function testGetRemainingLength() + { + $reader = new Reader('hello'); + $this->assertEquals(5, $reader->getRemainingLength()); + + $this->assignPosition($reader, 2); + $this->assertEquals(3, $reader->getRemainingLength()); + + $this->assignPosition($reader, 5); + $this->assertEquals(0, $reader->getRemainingLength()); + } + + public function testGetSubstring() + { + $reader = new Reader('hello'); + $this->assertEquals('he', $reader->getSubstring(2)); + $this->assertEquals('el', $reader->getSubstring(2, 1)); + + $this->assignPosition($reader, 2); + $this->assertEquals('ll', $reader->getSubstring(2)); + $this->assertEquals('lo', $reader->getSubstring(2, 1)); + } + + public function testGetOffset() + { + $reader = new Reader('hello'); + $this->assertEquals(2, $reader->getOffset('ll')); + $this->assertFalse($reader->getOffset('w')); + + $this->assignPosition($reader, 2); + $this->assertEquals(0, $reader->getOffset('ll')); + $this->assertFalse($reader->getOffset('he')); + } + + public function testFindPattern() + { + $reader = new Reader('hello'); + + $this->assertFalse($reader->findPattern('/world/')); + $this->assertEquals(array('hello', 'h'), $reader->findPattern('/^([a-z]).*/')); + + $this->assignPosition($reader, 2); + $this->assertFalse($reader->findPattern('/^h.*/')); + $this->assertEquals(array('llo'), $reader->findPattern('/^llo$/')); + } + + public function testMoveForward() + { + $reader = new Reader('hello'); + $this->assertEquals(0, $reader->getPosition()); + + $reader->moveForward(2); + $this->assertEquals(2, $reader->getPosition()); + } + + public function testToEnd() + { + $reader = new Reader('hello'); + $reader->moveToEnd(); + $this->assertTrue($reader->isEOF()); + } + + private function assignPosition(Reader $reader, $value) + { + $position = new \ReflectionProperty($reader, 'position'); + $position->setAccessible(true); + $position->setValue($reader, $value); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php new file mode 100644 index 0000000..6efdd67 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Shortcut\ClassParser; + +/** + * @author Jean-François Simon + */ +class ClassParserTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new ClassParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public function getParseTestData() + { + return array( + array('.testclass', 'Class[Element[*].testclass]'), + array('testel.testclass', 'Class[Element[testel].testclass]'), + array('testns|.testclass', 'Class[Element[testns|*].testclass]'), + array('testns|*.testclass', 'Class[Element[testns|*].testclass]'), + array('testns|testel.testclass', 'Class[Element[testns|testel].testclass]'), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php new file mode 100644 index 0000000..b30b5ee --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Shortcut\ElementParser; + +/** + * @author Jean-François Simon + */ +class ElementParserTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new ElementParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public function getParseTestData() + { + return array( + array('*', 'Element[*]'), + array('testel', 'Element[testel]'), + array('testns|*', 'Element[testns|*]'), + array('testns|testel', 'Element[testns|testel]'), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php new file mode 100644 index 0000000..b7c3539 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Shortcut\EmptyStringParser; + +/** + * @author Jean-François Simon + */ +class EmptyStringParserTest extends \PHPUnit_Framework_TestCase +{ + public function testParse() + { + $parser = new EmptyStringParser(); + $selectors = $parser->parse(''); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals('Element[*]', (string) $selector->getTree()); + + $selectors = $parser->parse('this will produce an empty array'); + $this->assertCount(0, $selectors); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php new file mode 100644 index 0000000..d2ce891 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Shortcut\HashParser; + +/** + * @author Jean-François Simon + */ +class HashParserTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new HashParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public function getParseTestData() + { + return array( + array('#testid', 'Hash[Element[*]#testid]'), + array('testel#testid', 'Hash[Element[testel]#testid]'), + array('testns|#testid', 'Hash[Element[testns|*]#testid]'), + array('testns|*#testid', 'Hash[Element[testns|*]#testid]'), + array('testns|testel#testid', 'Hash[Element[testns|testel]#testid]'), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php new file mode 100644 index 0000000..8f3253a --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser; + +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +class TokenStreamTest extends \PHPUnit_Framework_TestCase +{ + public function testGetNext() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3)); + + $this->assertSame($t1, $stream->getNext()); + $this->assertSame($t2, $stream->getNext()); + $this->assertSame($t3, $stream->getNext()); + } + + public function testGetPeek() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3)); + + $this->assertSame($t1, $stream->getPeek()); + $this->assertSame($t1, $stream->getNext()); + $this->assertSame($t2, $stream->getPeek()); + $this->assertSame($t2, $stream->getPeek()); + $this->assertSame($t2, $stream->getNext()); + } + + public function testGetNextIdentifier() + { + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + + $this->assertEquals('h1', $stream->getNextIdentifier()); + } + + public function testFailToGetNextIdentifier() + { + $this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->getNextIdentifier(); + } + + public function testGetNextIdentifierOrStar() + { + $stream = new TokenStream(); + + $stream->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $this->assertEquals('h1', $stream->getNextIdentifierOrStar()); + + $stream->push(new Token(Token::TYPE_DELIMITER, '*', 0)); + $this->assertNull($stream->getNextIdentifierOrStar()); + } + + public function testFailToGetNextIdentifierOrStar() + { + $this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->getNextIdentifierOrStar(); + } + + public function testSkipWhitespace() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_WHITESPACE, ' ', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'h1', 3)); + + $stream->skipWhitespace(); + $this->assertSame($t1, $stream->getNext()); + + $stream->skipWhitespace(); + $this->assertSame($t3, $stream->getNext()); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/TokenizerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/TokenizerTest.php deleted file mode 100644 index e0e00d8..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/TokenizerTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector\Tests; - -use Symfony\Component\CssSelector\Tokenizer; - -class TokenizerTest extends \PHPUnit_Framework_TestCase -{ - protected $tokenizer; - - protected function setUp() - { - $this->tokenizer = new Tokenizer(); - } - - /** - * @dataProvider getCssSelectors - */ - public function testTokenize($css) - { - $this->assertEquals($css, $this->tokensToString($this->tokenizer->tokenize($css)), '->tokenize() lexes an input string and returns an array of tokens'); - } - - public function testTokenizeWithQuotedStrings() - { - $this->assertEquals('foo[class=foo bar ]', $this->tokensToString($this->tokenizer->tokenize('foo[class="foo bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); - $this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($this->tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens'); - $this->assertEquals("img[alt= ]", $this->tokensToString($this->tokenizer->tokenize('img[alt=""]')), '->tokenize() lexes an input string and returns an array of tokens'); - } - - /** - * @expectedException \Symfony\Component\CssSelector\Exception\ParseException - */ - public function testTokenizeInvalidString() - { - $this->tokensToString($this->tokenizer->tokenize('/invalid')); - } - - public function getCssSelectors() - { - return array( - array('h1'), - array('h1:nth-child(3n+1)'), - array('h1 > p'), - array('h1#foo'), - array('h1.foo'), - array('h1[class*=foo]'), - array('h1 .foo'), - array('h1 #foo'), - array('h1 [class*=foo]'), - ); - } - - protected function tokensToString($tokens) - { - $str = ''; - foreach ($tokens as $token) { - $str .= str_repeat(' ', $token->getPosition() - strlen($str)).$token; - } - - return $str; - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html new file mode 100644 index 0000000..5799fad --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html @@ -0,0 +1,48 @@ + + + + +
+ + + + link +
    +
  1. content
  2. +
  3. +
    +
    +
  4. +
  5. +
  6. +
  7. +
  8. +
  9. +
+

+ hi there + guy + + + + + + + +

+ + +
+

+
    +
+ + + + +
+
+ diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml new file mode 100644 index 0000000..14f8dbe --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml @@ -0,0 +1,11 @@ + + a + b + c + d + e + f + + + + diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html new file mode 100644 index 0000000..15d1ad3 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html @@ -0,0 +1,308 @@ + + + + + + +
+
+

As You Like It

+
+ by William Shakespeare +
+
+

ACT I, SCENE III. A room in the palace.

+
+
Enter CELIA and ROSALIND
+
+
CELIA
+
+
Why, cousin! why, Rosalind! Cupid have mercy! not a word?
+
+
ROSALIND
+
+
Not one to throw at a dog.
+
+
CELIA
+
+
No, thy words are too precious to be cast away upon
+
curs; throw some of them at me; come, lame me with reasons.
+
+
ROSALIND
+
CELIA
+
+
But is all this for your father?
+
+
+
Then there were two cousins laid up; when the one
+
should be lamed with reasons and the other mad
+
without any.
+
+
ROSALIND
+
+
No, some of it is for my child's father. O, how
+
full of briers is this working-day world!
+
+
CELIA
+
+
They are but burs, cousin, thrown upon thee in
+
holiday foolery: if we walk not in the trodden
+
paths our very petticoats will catch them.
+
+
ROSALIND
+
+
I could shake them off my coat: these burs are in my heart.
+
+
CELIA
+
+
Hem them away.
+
+
ROSALIND
+
+
I would try, if I could cry 'hem' and have him.
+
+
CELIA
+
+
Come, come, wrestle with thy affections.
+
+
ROSALIND
+
+
O, they take the part of a better wrestler than myself!
+
+
CELIA
+
+
O, a good wish upon you! you will try in time, in
+
despite of a fall. But, turning these jests out of
+
service, let us talk in good earnest: is it
+
possible, on such a sudden, you should fall into so
+
strong a liking with old Sir Rowland's youngest son?
+
+
ROSALIND
+
+
The duke my father loved his father dearly.
+
+
CELIA
+
+
Doth it therefore ensue that you should love his son
+
dearly? By this kind of chase, I should hate him,
+
for my father hated his father dearly; yet I hate
+
not Orlando.
+
+
ROSALIND
+
+
No, faith, hate him not, for my sake.
+
+
CELIA
+
+
Why should I not? doth he not deserve well?
+
+
ROSALIND
+
+
Let me love him for that, and do you love him
+
because I do. Look, here comes the duke.
+
+
CELIA
+
+
With his eyes full of anger.
+
Enter DUKE FREDERICK, with Lords
+
+
DUKE FREDERICK
+
+
Mistress, dispatch you with your safest haste
+
And get you from our court.
+
+
ROSALIND
+
+
Me, uncle?
+
+
DUKE FREDERICK
+
+
You, cousin
+
Within these ten days if that thou be'st found
+
So near our public court as twenty miles,
+
Thou diest for it.
+
+
ROSALIND
+
+
I do beseech your grace,
+
Let me the knowledge of my fault bear with me:
+
If with myself I hold intelligence
+
Or have acquaintance with mine own desires,
+
If that I do not dream or be not frantic,--
+
As I do trust I am not--then, dear uncle,
+
Never so much as in a thought unborn
+
Did I offend your highness.
+
+
DUKE FREDERICK
+
+
Thus do all traitors:
+
If their purgation did consist in words,
+
They are as innocent as grace itself:
+
Let it suffice thee that I trust thee not.
+
+
ROSALIND
+
+
Yet your mistrust cannot make me a traitor:
+
Tell me whereon the likelihood depends.
+
+
DUKE FREDERICK
+
+
Thou art thy father's daughter; there's enough.
+
+
ROSALIND
+
+
So was I when your highness took his dukedom;
+
So was I when your highness banish'd him:
+
Treason is not inherited, my lord;
+
Or, if we did derive it from our friends,
+
What's that to me? my father was no traitor:
+
Then, good my liege, mistake me not so much
+
To think my poverty is treacherous.
+
+
CELIA
+
+
Dear sovereign, hear me speak.
+
+
DUKE FREDERICK
+
+
Ay, Celia; we stay'd her for your sake,
+
Else had she with her father ranged along.
+
+
CELIA
+
+
I did not then entreat to have her stay;
+
It was your pleasure and your own remorse:
+
I was too young that time to value her;
+
But now I know her: if she be a traitor,
+
Why so am I; we still have slept together,
+
Rose at an instant, learn'd, play'd, eat together,
+
And wheresoever we went, like Juno's swans,
+
Still we went coupled and inseparable.
+
+
DUKE FREDERICK
+
+
She is too subtle for thee; and her smoothness,
+
Her very silence and her patience
+
Speak to the people, and they pity her.
+
Thou art a fool: she robs thee of thy name;
+
And thou wilt show more bright and seem more virtuous
+
When she is gone. Then open not thy lips:
+
Firm and irrevocable is my doom
+
Which I have pass'd upon her; she is banish'd.
+
+
CELIA
+
+
Pronounce that sentence then on me, my liege:
+
I cannot live out of her company.
+
+
DUKE FREDERICK
+
+
You are a fool. You, niece, provide yourself:
+
If you outstay the time, upon mine honour,
+
And in the greatness of my word, you die.
+
Exeunt DUKE FREDERICK and Lords
+
+
CELIA
+
+
O my poor Rosalind, whither wilt thou go?
+
Wilt thou change fathers? I will give thee mine.
+
I charge thee, be not thou more grieved than I am.
+
+
ROSALIND
+
+
I have more cause.
+
+
CELIA
+
+
Thou hast not, cousin;
+
Prithee be cheerful: know'st thou not, the duke
+
Hath banish'd me, his daughter?
+
+
ROSALIND
+
+
That he hath not.
+
+
CELIA
+
+
No, hath not? Rosalind lacks then the love
+
Which teacheth thee that thou and I am one:
+
Shall we be sunder'd? shall we part, sweet girl?
+
No: let my father seek another heir.
+
Therefore devise with me how we may fly,
+
Whither to go and what to bear with us;
+
And do not seek to take your change upon you,
+
To bear your griefs yourself and leave me out;
+
For, by this heaven, now at our sorrows pale,
+
Say what thou canst, I'll go along with thee.
+
+
ROSALIND
+
+
Why, whither shall we go?
+
+
CELIA
+
+
To seek my uncle in the forest of Arden.
+
+
ROSALIND
+
+
Alas, what danger will it be to us,
+
Maids as we are, to travel forth so far!
+
Beauty provoketh thieves sooner than gold.
+
+
CELIA
+
+
I'll put myself in poor and mean attire
+
And with a kind of umber smirch my face;
+
The like do you: so shall we pass along
+
And never stir assailants.
+
+
ROSALIND
+
+
Were it not better,
+
Because that I am more than common tall,
+
That I did suit me all points like a man?
+
A gallant curtle-axe upon my thigh,
+
A boar-spear in my hand; and--in my heart
+
Lie there what hidden woman's fear there will--
+
We'll have a swashing and a martial outside,
+
As many other mannish cowards have
+
That do outface it with their semblances.
+
+
CELIA
+
+
What shall I call thee when thou art a man?
+
+
ROSALIND
+
+
I'll have no worse a name than Jove's own page;
+
And therefore look you call me Ganymede.
+
But what will you be call'd?
+
+
CELIA
+
+
Something that hath a reference to my state
+
No longer Celia, but Aliena.
+
+
ROSALIND
+
+
But, cousin, what if we assay'd to steal
+
The clownish fool out of your father's court?
+
Would he not be a comfort to our travel?
+
+
CELIA
+
+
He'll go along o'er the wide world with me;
+
Leave me alone to woo him. Let's away,
+
And get our jewels and our wealth together,
+
Devise the fittest time and safest way
+
To hide us from pursuit that will be made
+
After my flight. Now go we in content
+
To liberty and not to banishment.
+
Exeunt
+
+
+
+
+ + diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php new file mode 100644 index 0000000..143328f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -0,0 +1,324 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\XPath; + +use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension; +use Symfony\Component\CssSelector\XPath\Translator; + +class TranslatorTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getXpathLiteralTestData */ + public function testXpathLiteral($value, $literal) + { + $this->assertEquals($literal, Translator::getXpathLiteral($value)); + } + + /** @dataProvider getCssToXPathTestData */ + public function testCssToXPath($css, $xpath) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $this->assertEquals($xpath, $translator->cssToXPath($css, '')); + } + + /** @dataProvider getXmlLangTestData */ + public function testXmlLang($css, array $elementsId) + { + $translator = new Translator(); + $document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml')); + $elements = $document->xpath($translator->cssToXPath($css)); + $this->assertEquals(count($elementsId), count($elements)); + foreach ($elements as $element) { + $this->assertTrue(in_array($element->attributes()->id, $elementsId)); + } + } + + /** @dataProvider getHtmlIdsTestData */ + public function testHtmlIds($css, array $elementsId) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $document = new \DOMDocument(); + $document->strictErrorChecking = false; + $internalErrors = libxml_use_internal_errors(true); + $document->loadHTMLFile(__DIR__.'/Fixtures/ids.html'); + $document = simplexml_import_dom($document); + $elements = $document->xpath($translator->cssToXPath($css)); + $this->assertCount(count($elementsId), $elementsId); + foreach ($elements as $element) { + if (null !== $element->attributes()->id) { + $this->assertTrue(in_array($element->attributes()->id, $elementsId)); + } + } + libxml_clear_errors(); + libxml_use_internal_errors($internalErrors); + } + + /** @dataProvider getHtmlShakespearTestData */ + public function testHtmlShakespear($css, $count) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $document = new \DOMDocument(); + $document->strictErrorChecking = false; + $document->loadHTMLFile(__DIR__.'/Fixtures/shakespear.html'); + $document = simplexml_import_dom($document); + $bodies = $document->xpath('//body'); + $elements = $bodies[0]->xpath($translator->cssToXPath($css)); + $this->assertEquals($count, count($elements)); + } + + public function getXpathLiteralTestData() + { + return array( + array('foo', "'foo'"), + array("foo's bar", '"foo\'s bar"'), + array("foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'), + array("foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'), + ); + } + + public function getCssToXPathTestData() + { + return array( + array('*', '*'), + array('e', 'e'), + array('*|e', 'e'), + array('e|f', 'e:f'), + array('e[foo]', 'e[@foo]'), + array('e[foo|bar]', 'e[@foo:bar]'), + array('e[foo="bar"]', "e[@foo = 'bar']"), + array('e[foo~="bar"]', "e[@foo and contains(concat(' ', normalize-space(@foo), ' '), ' bar ')]"), + array('e[foo^="bar"]', "e[@foo and starts-with(@foo, 'bar')]"), + array('e[foo$="bar"]', "e[@foo and substring(@foo, string-length(@foo)-2) = 'bar']"), + array('e[foo*="bar"]', "e[@foo and contains(@foo, 'bar')]"), + array('e[hreflang|="en"]', "e[@hreflang and (@hreflang = 'en' or starts-with(@hreflang, 'en-'))]"), + array('e:nth-child(1)', "*/*[name() = 'e' and (position() = 1)]"), + array('e:nth-last-child(1)', "*/*[name() = 'e' and (position() = last() - 0)]"), + array('e:nth-last-child(2n+2)', "*/*[name() = 'e' and (last() - position() - 1 >= 0 and (last() - position() - 1) mod 2 = 0)]"), + array('e:nth-of-type(1)', '*/e[position() = 1]'), + array('e:nth-last-of-type(1)', '*/e[position() = last() - 0]'), + array('div e:nth-last-of-type(1) .aclass', "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')]"), + array('e:first-child', "*/*[name() = 'e' and (position() = 1)]"), + array('e:last-child', "*/*[name() = 'e' and (position() = last())]"), + array('e:first-of-type', '*/e[position() = 1]'), + array('e:last-of-type', '*/e[position() = last()]'), + array('e:only-child', "*/*[name() = 'e' and (last() = 1)]"), + array('e:only-of-type', 'e[last() = 1]'), + array('e:empty', 'e[not(*) and not(string-length())]'), + array('e:EmPTY', 'e[not(*) and not(string-length())]'), + array('e:root', 'e[not(parent::*)]'), + array('e:hover', 'e[0]'), + array('e:contains("foo")', "e[contains(string(.), 'foo')]"), + array('e:ConTains(foo)', "e[contains(string(.), 'foo')]"), + array('e.warning', "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')]"), + array('e#myid', "e[@id = 'myid']"), + array('e:not(:nth-child(odd))', 'e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]'), + array('e:nOT(*)', 'e[0]'), + array('e f', 'e/descendant-or-self::*/f'), + array('e > f', 'e/f'), + array('e + f', "e/following-sibling::*[name() = 'f' and (position() = 1)]"), + array('e ~ f', 'e/following-sibling::f'), + array('div#container p', "div[@id = 'container']/descendant-or-self::*/p"), + ); + } + + public function getXmlLangTestData() + { + return array( + array(':lang("EN")', array('first', 'second', 'third', 'fourth')), + array(':lang("en-us")', array('second', 'fourth')), + array(':lang(en-nz)', array('third')), + array(':lang(fr)', array('fifth')), + array(':lang(ru)', array('sixth')), + array(":lang('ZH')", array('eighth')), + array(':lang(de) :lang(zh)', array('eighth')), + array(':lang(en), :lang(zh)', array('first', 'second', 'third', 'fourth', 'eighth')), + array(':lang(es)', array()), + ); + } + + public function getHtmlIdsTestData() + { + return array( + array('div', array('outer-div', 'li-div', 'foobar-div')), + array('DIV', array('outer-div', 'li-div', 'foobar-div')), // case-insensitive in HTML + array('div div', array('li-div')), + array('div, div div', array('outer-div', 'li-div', 'foobar-div')), + array('a[name]', array('name-anchor')), + array('a[NAme]', array('name-anchor')), // case-insensitive in HTML: + array('a[rel]', array('tag-anchor', 'nofollow-anchor')), + array('a[rel="tag"]', array('tag-anchor')), + array('a[href*="localhost"]', array('tag-anchor')), + array('a[href*=""]', array()), + array('a[href^="http"]', array('tag-anchor', 'nofollow-anchor')), + array('a[href^="http:"]', array('tag-anchor')), + array('a[href^=""]', array()), + array('a[href$="org"]', array('nofollow-anchor')), + array('a[href$=""]', array()), + array('div[foobar~="bc"]', array('foobar-div')), + array('div[foobar~="cde"]', array('foobar-div')), + array('[foobar~="ab bc"]', array('foobar-div')), + array('[foobar~=""]', array()), + array('[foobar~=" \t"]', array()), + array('div[foobar~="cd"]', array()), + array('*[lang|="En"]', array('second-li')), + array('[lang|="En-us"]', array('second-li')), + // Attribute values are case sensitive + array('*[lang|="en"]', array()), + array('[lang|="en-US"]', array()), + array('*[lang|="e"]', array()), + // ... :lang() is not. + array(':lang("EN")', array('second-li', 'li-div')), + array('*:lang(en-US)', array('second-li', 'li-div')), + array(':lang("e")', array()), + array('li:nth-child(3)', array('third-li')), + array('li:nth-child(10)', array()), + array('li:nth-child(2n)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-child(even)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-child(2n+0)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-child(+2n+1)', array('first-li', 'third-li', 'fifth-li', 'seventh-li')), + array('li:nth-child(odd)', array('first-li', 'third-li', 'fifth-li', 'seventh-li')), + array('li:nth-child(2n+4)', array('fourth-li', 'sixth-li')), + array('li:nth-child(3n+1)', array('first-li', 'fourth-li', 'seventh-li')), + array('li:nth-child(n)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-child(n-1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-child(n+1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-child(n+3)', array('third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-child(-n)', array()), + array('li:nth-child(-n-1)', array()), + array('li:nth-child(-n+1)', array('first-li')), + array('li:nth-child(-n+3)', array('first-li', 'second-li', 'third-li')), + array('li:nth-last-child(0)', array()), + array('li:nth-last-child(2n)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-last-child(even)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-last-child(2n+2)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-last-child(n)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-last-child(n-1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-last-child(n-3)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-last-child(n+1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-last-child(n+3)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li')), + array('li:nth-last-child(-n)', array()), + array('li:nth-last-child(-n-1)', array()), + array('li:nth-last-child(-n+1)', array('seventh-li')), + array('li:nth-last-child(-n+3)', array('fifth-li', 'sixth-li', 'seventh-li')), + array('ol:first-of-type', array('first-ol')), + array('ol:nth-child(1)', array('first-ol')), + array('ol:nth-of-type(2)', array('second-ol')), + array('ol:nth-last-of-type(1)', array('second-ol')), + array('span:only-child', array('foobar-span')), + array('li div:only-child', array('li-div')), + array('div *:only-child', array('li-div', 'foobar-span')), + array('p:only-of-type', array('paragraph')), + array('a:empty', array('name-anchor')), + array('a:EMpty', array('name-anchor')), + array('li:empty', array('third-li', 'fourth-li', 'fifth-li', 'sixth-li')), + array(':root', array('html')), + array('html:root', array('html')), + array('li:root', array()), + array('* :root', array()), + array('*:contains("link")', array('html', 'outer-div', 'tag-anchor', 'nofollow-anchor')), + array(':CONtains("link")', array('html', 'outer-div', 'tag-anchor', 'nofollow-anchor')), + array('*:contains("LInk")', array()), // case sensitive + array('*:contains("e")', array('html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em')), + array('*:contains("E")', array()), // case-sensitive + array('.a', array('first-ol')), + array('.b', array('first-ol')), + array('*.a', array('first-ol')), + array('ol.a', array('first-ol')), + array('.c', array('first-ol', 'third-li', 'fourth-li')), + array('*.c', array('first-ol', 'third-li', 'fourth-li')), + array('ol *.c', array('third-li', 'fourth-li')), + array('ol li.c', array('third-li', 'fourth-li')), + array('li ~ li.c', array('third-li', 'fourth-li')), + array('ol > li.c', array('third-li', 'fourth-li')), + array('#first-li', array('first-li')), + array('li#first-li', array('first-li')), + array('*#first-li', array('first-li')), + array('li div', array('li-div')), + array('li > div', array('li-div')), + array('div div', array('li-div')), + array('div > div', array()), + array('div>.c', array('first-ol')), + array('div > .c', array('first-ol')), + array('div + div', array('foobar-div')), + array('a ~ a', array('tag-anchor', 'nofollow-anchor')), + array('a[rel="tag"] ~ a', array('nofollow-anchor')), + array('ol#first-ol li:last-child', array('seventh-li')), + array('ol#first-ol *:last-child', array('li-div', 'seventh-li')), + array('#outer-div:first-child', array('outer-div')), + array('#outer-div :first-child', array('name-anchor', 'first-li', 'li-div', 'p-b', 'checkbox-fieldset-disabled', 'area-href')), + array('a[href]', array('tag-anchor', 'nofollow-anchor')), + array(':not(*)', array()), + array('a:not([href])', array('name-anchor')), + array('ol :Not(li[class])', array('first-li', 'second-li', 'li-div', 'fifth-li', 'sixth-li', 'seventh-li')), + // HTML-specific + array(':link', array('link-href', 'tag-anchor', 'nofollow-anchor', 'area-href')), + array(':visited', array()), + array(':enabled', array('link-href', 'tag-anchor', 'nofollow-anchor', 'checkbox-unchecked', 'text-checked', 'checkbox-checked', 'area-href')), + array(':disabled', array('checkbox-disabled', 'checkbox-disabled-checked', 'fieldset', 'checkbox-fieldset-disabled')), + array(':checked', array('checkbox-checked', 'checkbox-disabled-checked')), + ); + } + + public function getHtmlShakespearTestData() + { + return array( + array('*', 246), + array('div:contains(CELIA)', 26), + array('div:only-child', 22), // ? + array('div:nth-child(even)', 106), + array('div:nth-child(2n)', 106), + array('div:nth-child(odd)', 137), + array('div:nth-child(2n+1)', 137), + array('div:nth-child(n)', 243), + array('div:last-child', 53), + array('div:first-child', 51), + array('div > div', 242), + array('div + div', 190), + array('div ~ div', 190), + array('body', 1), + array('body div', 243), + array('div', 243), + array('div div', 242), + array('div div div', 241), + array('div, div, div', 243), + array('div, a, span', 243), + array('.dialog', 51), + array('div.dialog', 51), + array('div .dialog', 51), + array('div.character, div.dialog', 99), + array('div.direction.dialog', 0), + array('div.dialog.direction', 0), + array('div.dialog.scene', 1), + array('div.scene.scene', 1), + array('div.scene .scene', 0), + array('div.direction .dialog ', 0), + array('div .dialog .direction', 4), + array('div.dialog .dialog .direction', 4), + array('#speech5', 1), + array('div#speech5', 1), + array('div #speech5', 1), + array('div.scene div.dialog', 49), + array('div#scene1 div.dialog div', 142), + array('#scene1 #speech1', 1), + array('div[class]', 103), + array('div[class=dialog]', 50), + array('div[class^=dia]', 51), + array('div[class$=log]', 50), + array('div[class*=sce]', 1), + array('div[class|=dialog]', 50), // ? Seems right + array('div[class!=madeup]', 243), // ? Seems right + array('div[class~=dialog]', 51), // ? Seems right + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPathExprTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPathExprTest.php deleted file mode 100644 index df6e5a0..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPathExprTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector\Tests; - -use Symfony\Component\CssSelector\XPathExpr; - -class XPathExprTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getXPathLiteralValues - */ - public function testXpathLiteral($value, $literal) - { - $this->assertEquals($literal, XPathExpr::xpathLiteral($value)); - } - - public function getXPathLiteralValues() - { - return array( - array('foo', "'foo'"), - array("foo's bar", '"foo\'s bar"'), - array("foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'), - array("foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'), - ); - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Token.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Token.php deleted file mode 100644 index 6748a44..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Token.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector; - -/** - * Token represents a CSS Selector token. - * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. - * - * @author Fabien Potencier - */ -class Token -{ - private $type; - private $value; - private $position; - - /** - * Constructor. - * - * @param string $type The type of this token. - * @param mixed $value The value of this token. - * @param integer $position The order of this token. - */ - public function __construct($type, $value, $position) - { - $this->type = $type; - $this->value = $value; - $this->position = $position; - } - - /** - * Gets a string representation of this token. - * - * @return string - */ - public function __toString() - { - return (string) $this->value; - } - - /** - * Answers whether this token's type equals to $type. - * - * @param string $type The type to test against this token's one. - * - * @return Boolean - */ - public function isType($type) - { - return $this->type == $type; - } - - /** - * Gets the position of this token. - * - * @return integer - */ - public function getPosition() - { - return $this->position; - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/TokenStream.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/TokenStream.php deleted file mode 100644 index cf04702..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/TokenStream.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector; - -/** - * TokenStream represents a stream of CSS Selector tokens. - * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. - * - * @author Fabien Potencier - */ -class TokenStream -{ - private $used; - private $tokens; - private $source; - private $peeked; - private $peeking; - - /** - * Constructor. - * - * @param array $tokens The tokens that make the stream. - * @param mixed $source The source of the stream. - */ - public function __construct($tokens, $source = null) - { - $this->used = array(); - $this->tokens = $tokens; - $this->source = $source; - $this->peeked = null; - $this->peeking = false; - } - - /** - * Gets the tokens that have already been visited in this stream. - * - * @return array - */ - public function getUsed() - { - return $this->used; - } - - /** - * Gets the next token in the stream or null if there is none. - * Note that if this stream was set to be peeking its behavior - * will be restored to not peeking after this operation. - * - * @return mixed - */ - public function next() - { - if ($this->peeking) { - $this->peeking = false; - $this->used[] = $this->peeked; - - return $this->peeked; - } - - if (!count($this->tokens)) { - return null; - } - - $next = array_shift($this->tokens); - $this->used[] = $next; - - return $next; - } - - /** - * Peeks for the next token in this stream. This means that the next token - * will be returned but it won't be considered as used (visited) until the - * next() method is invoked. - * If there are no remaining tokens null will be returned. - * - * @see next() - * - * @return mixed - */ - public function peek() - { - if (!$this->peeking) { - if (!count($this->tokens)) { - return null; - } - - $this->peeked = array_shift($this->tokens); - - $this->peeking = true; - } - - return $this->peeked; - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tokenizer.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tokenizer.php deleted file mode 100644 index 34e8ac5..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tokenizer.php +++ /dev/null @@ -1,201 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector; - -use Symfony\Component\CssSelector\Exception\ParseException; - -/** - * Tokenizer lexes a CSS Selector to tokens. - * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. - * - * @author Fabien Potencier - */ -class Tokenizer -{ - /** - * Takes a CSS selector and returns an array holding the Tokens - * it contains. - * - * @param string $s The selector to lex. - * - * @return array Token[] - */ - public function tokenize($s) - { - if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { - $mbEncoding = mb_internal_encoding(); - mb_internal_encoding('ASCII'); - } - - $tokens = array(); - $pos = 0; - $s = preg_replace('#/\*.*?\*/#s', '', $s); - - while (true) { - if (preg_match('#\s+#A', $s, $match, 0, $pos)) { - $precedingWhitespacePos = $pos; - $pos += strlen($match[0]); - } else { - $precedingWhitespacePos = 0; - } - - if ($pos >= strlen($s)) { - if (isset($mbEncoding)) { - mb_internal_encoding($mbEncoding); - } - - return $tokens; - } - - if (preg_match('#[+-]?\d*n(?:[+-]\d+)?#A', $s, $match, 0, $pos) && 'n' !== $match[0]) { - $sym = substr($s, $pos, strlen($match[0])); - $tokens[] = new Token('Symbol', $sym, $pos); - $pos += strlen($match[0]); - - continue; - } - - $c = $s[$pos]; - $c2 = substr($s, $pos, 2); - if (in_array($c2, array('~=', '|=', '^=', '$=', '*=', '::', '!='))) { - $tokens[] = new Token('Token', $c2, $pos); - $pos += 2; - - continue; - } - - if (in_array($c, array('>', '+', '~', ',', '.', '*', '=', '[', ']', '(', ')', '|', ':', '#'))) { - if (in_array($c, array('.', '#', '[')) && $precedingWhitespacePos > 0) { - $tokens[] = new Token('Token', ' ', $precedingWhitespacePos); - } - $tokens[] = new Token('Token', $c, $pos); - ++$pos; - - continue; - } - - if ('"' === $c || "'" === $c) { - // Quoted string - $oldPos = $pos; - list($sym, $pos) = $this->tokenizeEscapedString($s, $pos); - - $tokens[] = new Token('String', $sym, $oldPos); - - continue; - } - - $oldPos = $pos; - list($sym, $pos) = $this->tokenizeSymbol($s, $pos); - - $tokens[] = new Token('Symbol', $sym, $oldPos); - - continue; - } - } - - /** - * Tokenizes a quoted string (i.e. 'A string quoted with \' characters'), - * and returns an array holding the unquoted string contained by $s and - * the new position from which tokenizing should take over. - * - * @param string $s The selector string containing the quoted string. - * @param integer $pos The starting position for the quoted string. - * - * @return array - * - * @throws ParseException When expected closing is not found - */ - private function tokenizeEscapedString($s, $pos) - { - $quote = $s[$pos]; - - $pos = $pos + 1; - $start = $pos; - while (true) { - $next = strpos($s, $quote, $pos); - if (false === $next) { - throw new ParseException(sprintf('Expected closing %s for string in: %s', $quote, substr($s, $start))); - } - - $result = substr($s, $start, $next - $start); - if (strlen($result) > 0 && '\\' === $result[strlen($result) - 1]) { - // next quote character is escaped - $pos = $next + 1; - continue; - } - - if (false !== strpos($result, '\\')) { - $result = $this->unescapeStringLiteral($result); - } - - return array($result, $next + 1); - } - } - - /** - * Unescapes a string literal and returns the unescaped string. - * - * @param string $literal The string literal to unescape. - * - * @return string - * - * @throws ParseException When invalid escape sequence is found - */ - private function unescapeStringLiteral($literal) - { - return preg_replace_callback('#(\\\\(?:[A-Fa-f0-9]{1,6}(?:\r\n|\s)?|[^A-Fa-f0-9]))#', function ($matches) use ($literal) { - if ($matches[0][0] == '\\' && strlen($matches[0]) > 1) { - $matches[0] = substr($matches[0], 1); - if (in_array($matches[0][0], array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f'))) { - return chr(trim($matches[0])); - } - } else { - throw new ParseException(sprintf('Invalid escape sequence %s in string %s', $matches[0], $literal)); - } - }, $literal); - } - - /** - * Lexes selector $s and returns an array holding the name of the symbol - * contained in it and the new position from which tokenizing should take - * over. - * - * @param string $s The selector string. - * @param integer $pos The position in $s at which the symbol starts. - * - * @return array - * - * @throws ParseException When Unexpected symbol is found - */ - private function tokenizeSymbol($s, $pos) - { - $start = $pos; - - if (!preg_match('#[^\w\-]#', $s, $match, PREG_OFFSET_CAPTURE, $pos)) { - // Goes to end of s - return array(substr($s, $start), strlen($s)); - } - - $matchStart = $match[0][1]; - - if ($matchStart == $pos) { - throw new ParseException(sprintf('Unexpected symbol: %s at %s', $s[$pos], $pos)); - } - - $result = substr($s, $start, $matchStart - $start); - $pos = $matchStart; - - return array($result, $pos); - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php new file mode 100644 index 0000000..c70609c --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +/** + * XPath expression translator abstract extension. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +abstract class AbstractExtension implements ExtensionInterface +{ + /** + * {@inheritdoc} + */ + public function getNodeTranslators() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getCombinationTranslators() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getFunctionTranslators() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getPseudoClassTranslators() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getAttributeMatchingTranslators() + { + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php new file mode 100644 index 0000000..cbe48c5 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php @@ -0,0 +1,173 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\XPath\Translator; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator attribute extension. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class AttributeMatchingExtension extends AbstractExtension +{ + /** + * {@inheritdoc} + */ + public function getAttributeMatchingTranslators() + { + return array( + 'exists' => array($this, 'translateExists'), + '=' => array($this, 'translateEquals'), + '~=' => array($this, 'translateIncludes'), + '|=' => array($this, 'translateDashMatch'), + '^=' => array($this, 'translatePrefixMatch'), + '$=' => array($this, 'translateSuffixMatch'), + '*=' => array($this, 'translateSubstringMatch'), + '!=' => array($this, 'translateDifferent'), + ); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateExists(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($attribute); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateEquals(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition(sprintf('%s = %s', $attribute, Translator::getXpathLiteral($value))); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateIncludes(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($value ? sprintf( + '%1$s and contains(concat(\' \', normalize-space(%1$s), \' \'), %2$s)', + $attribute, + Translator::getXpathLiteral(' '.$value.' ') + ) : '0'); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateDashMatch(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition(sprintf( + '%1$s and (%1$s = %2$s or starts-with(%1$s, %3$s))', + $attribute, + Translator::getXpathLiteral($value), + Translator::getXpathLiteral($value.'-') + )); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translatePrefixMatch(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($value ? sprintf( + '%1$s and starts-with(%1$s, %2$s)', + $attribute, + Translator::getXpathLiteral($value) + ) : '0'); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($value ? sprintf( + '%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s', + $attribute, + strlen($value) - 1, + Translator::getXpathLiteral($value) + ) : '0'); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateSubstringMatch(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($value ? sprintf( + '%1$s and contains(%1$s, %2$s)', + $attribute, + Translator::getXpathLiteral($value) + ) : '0'); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateDifferent(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition(sprintf( + $value ? 'not(%1$s) or %1$s != %2$s' : '%s != %s', + $attribute, + Translator::getXpathLiteral($value) + )); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'attribute-matching'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php new file mode 100644 index 0000000..9ce018f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator combination extension. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class CombinationExtension extends AbstractExtension +{ + /** + * {@inheritdoc} + */ + public function getCombinationTranslators() + { + return array( + ' ' => array($this, 'translateDescendant'), + '>' => array($this, 'translateChild'), + '+' => array($this, 'translateDirectAdjacent'), + '~' => array($this, 'translateIndirectAdjacent'), + ); + } + + /** + * @param XPathExpr $xpath + * @param XPathExpr $combinedXpath + * + * @return XPathExpr + */ + public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath) + { + return $xpath->join('/descendant-or-self::*/', $combinedXpath); + } + + /** + * @param XPathExpr $xpath + * @param XPathExpr $combinedXpath + * + * @return XPathExpr + */ + public function translateChild(XPathExpr $xpath, XPathExpr $combinedXpath) + { + return $xpath->join('/', $combinedXpath); + } + + /** + * @param XPathExpr $xpath + * @param XPathExpr $combinedXpath + * + * @return XPathExpr + */ + public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath) + { + return $xpath + ->join('/following-sibling::', $combinedXpath) + ->addNameTest() + ->addCondition('position() = 1'); + } + + /** + * @param XPathExpr $xpath + * @param XPathExpr $combinedXpath + * + * @return XPathExpr + */ + public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath) + { + return $xpath->join('/following-sibling::', $combinedXpath); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'combination'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php new file mode 100644 index 0000000..9b47f24 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +/** + * XPath expression translator extension interface. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface ExtensionInterface +{ + /** + * Returns node translators. + * + * These callables will receive the node as first argument and the translator as second argument. + * + * @return callable[] + */ + public function getNodeTranslators(); + + /** + * Returns combination translators. + * + * @return callable[] + */ + public function getCombinationTranslators(); + + /** + * Returns function translators. + * + * @return callable[] + */ + public function getFunctionTranslators(); + + /** + * Returns pseudo-class translators. + * + * @return callable[] + */ + public function getPseudoClassTranslators(); + + /** + * Returns attribute operation translators. + * + * @return callable[] + */ + public function getAttributeMatchingTranslators(); + + /** + * Returns extension name. + * + * @return string + */ + public function getName(); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php new file mode 100644 index 0000000..0086240 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php @@ -0,0 +1,209 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\Parser\Parser; +use Symfony\Component\CssSelector\XPath\Translator; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator function extension. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class FunctionExtension extends AbstractExtension +{ + /** + * {@inheritdoc} + */ + public function getFunctionTranslators() + { + return array( + 'nth-child' => array($this, 'translateNthChild'), + 'nth-last-child' => array($this, 'translateNthLastChild'), + 'nth-of-type' => array($this, 'translateNthOfType'), + 'nth-last-of-type' => array($this, 'translateNthLastOfType'), + 'contains' => array($this, 'translateContains'), + 'lang' => array($this, 'translateLang'), + ); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * @param bool $last + * @param bool $addNameTest + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $last = false, $addNameTest = true) + { + try { + list($a, $b) = Parser::parseSeries($function->getArguments()); + } catch (SyntaxErrorException $e) { + throw new ExpressionErrorException(sprintf('Invalid series: %s', implode(', ', $function->getArguments())), 0, $e); + } + + $xpath->addStarPrefix(); + if ($addNameTest) { + $xpath->addNameTest(); + } + + if (0 === $a) { + return $xpath->addCondition('position() = '.($last ? 'last() - '.($b - 1) : $b)); + } + + if ($a < 0) { + if ($b < 1) { + return $xpath->addCondition('false()'); + } + + $sign = '<='; + } else { + $sign = '>='; + } + + $expr = 'position()'; + + if ($last) { + $expr = 'last() - '.$expr; + $b--; + } + + if (0 !== $b) { + $expr .= ' - '.$b; + } + + $conditions = array(sprintf('%s %s 0', $expr, $sign)); + + if (1 !== $a && -1 !== $a) { + $conditions[] = sprintf('(%s) mod %d = 0', $expr, $a); + } + + return $xpath->addCondition(implode(' and ', $conditions)); + + // todo: handle an+b, odd, even + // an+b means every-a, plus b, e.g., 2n+1 means odd + // 0n+b means b + // n+0 means a=1, i.e., all elements + // an means every a elements, i.e., 2n means even + // -n means -1n + // -1n+6 means elements 6 and previous + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + */ + public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function) + { + return $this->translateNthChild($xpath, $function, true); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + */ + public function translateNthOfType(XPathExpr $xpath, FunctionNode $function) + { + return $this->translateNthChild($xpath, $function, false, false); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function) + { + if ('*' === $xpath->getElement()) { + throw new ExpressionErrorException('"*:nth-of-type()" is not implemented.'); + } + + return $this->translateNthChild($xpath, $function, true, false); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateContains(XPathExpr $xpath, FunctionNode $function) + { + $arguments = $function->getArguments(); + foreach ($arguments as $token) { + if (!($token->isString() || $token->isIdentifier())) { + throw new ExpressionErrorException( + 'Expected a single string or identifier for :contains(), got ' + .implode(', ', $arguments) + ); + } + } + + return $xpath->addCondition(sprintf( + 'contains(string(.), %s)', + Translator::getXpathLiteral($arguments[0]->getValue()) + )); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateLang(XPathExpr $xpath, FunctionNode $function) + { + $arguments = $function->getArguments(); + foreach ($arguments as $token) { + if (!($token->isString() || $token->isIdentifier())) { + throw new ExpressionErrorException( + 'Expected a single string or identifier for :lang(), got ' + .implode(', ', $arguments) + ); + } + } + + return $xpath->addCondition(sprintf( + 'lang(%s)', + Translator::getXpathLiteral($arguments[0]->getValue()) + )); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'function'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php new file mode 100644 index 0000000..0da74d4 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php @@ -0,0 +1,238 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\XPath\Translator; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator HTML extension. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class HtmlExtension extends AbstractExtension +{ + /** + * Constructor. + * + * @param Translator $translator + */ + public function __construct(Translator $translator) + { + $translator + ->getExtension('node') + ->setFlag(NodeExtension::ELEMENT_NAME_IN_LOWER_CASE, true) + ->setFlag(NodeExtension::ATTRIBUTE_NAME_IN_LOWER_CASE, true); + } + + /** + * {@inheritdoc} + */ + public function getPseudoClassTranslators() + { + return array( + 'checked' => array($this, 'translateChecked'), + 'link' => array($this, 'translateLink'), + 'disabled' => array($this, 'translateDisabled'), + 'enabled' => array($this, 'translateEnabled'), + 'selected' => array($this, 'translateSelected'), + 'invalid' => array($this, 'translateInvalid'), + 'hover' => array($this, 'translateHover'), + 'visited' => array($this, 'translateVisited'), + ); + } + + /** + * {@inheritdoc} + */ + public function getFunctionTranslators() + { + return array( + 'lang' => array($this, 'translateLang'), + ); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateChecked(XPathExpr $xpath) + { + return $xpath->addCondition( + '(@checked ' + ."and (name(.) = 'input' or name(.) = 'command')" + ."and (@type = 'checkbox' or @type = 'radio'))" + ); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateLink(XPathExpr $xpath) + { + return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')"); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateDisabled(XPathExpr $xpath) + { + return $xpath->addCondition( + '(' + .'@disabled and' + .'(' + ."(name(.) = 'input' and @type != 'hidden')" + ." or name(.) = 'button'" + ." or name(.) = 'select'" + ." or name(.) = 'textarea'" + ." or name(.) = 'command'" + ." or name(.) = 'fieldset'" + ." or name(.) = 'optgroup'" + ." or name(.) = 'option'" + .')' + .') or (' + ."(name(.) = 'input' and @type != 'hidden')" + ." or name(.) = 'button'" + ." or name(.) = 'select'" + ." or name(.) = 'textarea'" + .')' + .' and ancestor::fieldset[@disabled]' + ); + // todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any." + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateEnabled(XPathExpr $xpath) + { + return $xpath->addCondition( + '(' + .'@href and (' + ."name(.) = 'a'" + ." or name(.) = 'link'" + ." or name(.) = 'area'" + .')' + .') or (' + .'(' + ."name(.) = 'command'" + ." or name(.) = 'fieldset'" + ." or name(.) = 'optgroup'" + .')' + .' and not(@disabled)' + .') or (' + .'(' + ."(name(.) = 'input' and @type != 'hidden')" + ." or name(.) = 'button'" + ." or name(.) = 'select'" + ." or name(.) = 'textarea'" + ." or name(.) = 'keygen'" + .')' + .' and not (@disabled or ancestor::fieldset[@disabled])' + .') or (' + ."name(.) = 'option' and not(" + .'@disabled or ancestor::optgroup[@disabled]' + .')' + .')' + ); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateLang(XPathExpr $xpath, FunctionNode $function) + { + $arguments = $function->getArguments(); + foreach ($arguments as $token) { + if (!($token->isString() || $token->isIdentifier())) { + throw new ExpressionErrorException( + 'Expected a single string or identifier for :lang(), got ' + .implode(', ', $arguments) + ); + } + } + + return $xpath->addCondition(sprintf( + 'ancestor-or-self::*[@lang][1][starts-with(concat(' + ."translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '-')" + .', %s)]', + 'lang', + Translator::getXpathLiteral(strtolower($arguments[0]->getValue()).'-') + )); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateSelected(XPathExpr $xpath) + { + return $xpath->addCondition("(@selected and name(.) = 'option')"); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateInvalid(XPathExpr $xpath) + { + return $xpath->addCondition('0'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateHover(XPathExpr $xpath) + { + return $xpath->addCondition('0'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateVisited(XPathExpr $xpath) + { + return $xpath->addCondition('0'); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'html'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php new file mode 100644 index 0000000..2b8920f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -0,0 +1,271 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\Node; +use Symfony\Component\CssSelector\XPath\Translator; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator node extension. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class NodeExtension extends AbstractExtension +{ + const ELEMENT_NAME_IN_LOWER_CASE = 1; + const ATTRIBUTE_NAME_IN_LOWER_CASE = 2; + const ATTRIBUTE_VALUE_IN_LOWER_CASE = 4; + + /** + * @var int + */ + private $flags; + + /** + * Constructor. + * + * @param int $flags + */ + public function __construct($flags = 0) + { + $this->flags = $flags; + } + + /** + * @param int $flag + * @param bool $on + * + * @return NodeExtension + */ + public function setFlag($flag, $on) + { + if ($on && !$this->hasFlag($flag)) { + $this->flags += $flag; + } + + if (!$on && $this->hasFlag($flag)) { + $this->flags -= $flag; + } + + return $this; + } + + /** + * @param int $flag + * + * @return bool + */ + public function hasFlag($flag) + { + return $this->flags & $flag; + } + + /** + * {@inheritdoc} + */ + public function getNodeTranslators() + { + return array( + 'Selector' => array($this, 'translateSelector'), + 'CombinedSelector' => array($this, 'translateCombinedSelector'), + 'Negation' => array($this, 'translateNegation'), + 'Function' => array($this, 'translateFunction'), + 'Pseudo' => array($this, 'translatePseudo'), + 'Attribute' => array($this, 'translateAttribute'), + 'Class' => array($this, 'translateClass'), + 'Hash' => array($this, 'translateHash'), + 'Element' => array($this, 'translateElement'), + ); + } + + /** + * @param Node\SelectorNode $node + * @param Translator $translator + * + * @return XPathExpr + */ + public function translateSelector(Node\SelectorNode $node, Translator $translator) + { + return $translator->nodeToXPath($node->getTree()); + } + + /** + * @param Node\CombinedSelectorNode $node + * @param Translator $translator + * + * @return XPathExpr + */ + public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator) + { + return $translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); + } + + /** + * @param Node\NegationNode $node + * @param Translator $translator + * + * @return XPathExpr + */ + public function translateNegation(Node\NegationNode $node, Translator $translator) + { + $xpath = $translator->nodeToXPath($node->getSelector()); + $subXpath = $translator->nodeToXPath($node->getSubSelector()); + $subXpath->addNameTest(); + + if ($subXpath->getCondition()) { + return $xpath->addCondition(sprintf('not(%s)', $subXpath->getCondition())); + } + + return $xpath->addCondition('0'); + } + + /** + * @param Node\FunctionNode $node + * @param Translator $translator + * + * @return XPathExpr + */ + public function translateFunction(Node\FunctionNode $node, Translator $translator) + { + $xpath = $translator->nodeToXPath($node->getSelector()); + + return $translator->addFunction($xpath, $node); + } + + /** + * @param Node\PseudoNode $node + * @param Translator $translator + * + * @return XPathExpr + */ + public function translatePseudo(Node\PseudoNode $node, Translator $translator) + { + $xpath = $translator->nodeToXPath($node->getSelector()); + + return $translator->addPseudoClass($xpath, $node->getIdentifier()); + } + + /** + * @param Node\AttributeNode $node + * @param Translator $translator + * + * @return XPathExpr + */ + public function translateAttribute(Node\AttributeNode $node, Translator $translator) + { + $name = $node->getAttribute(); + $safe = $this->isSafeName($name); + + if ($this->hasFlag(self::ATTRIBUTE_NAME_IN_LOWER_CASE)) { + $name = strtolower($name); + } + + if ($node->getNamespace()) { + $name = sprintf('%s:%s', $node->getNamespace(), $name); + $safe = $safe && $this->isSafeName($node->getNamespace()); + } + + $attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name)); + $value = $node->getValue(); + $xpath = $translator->nodeToXPath($node->getSelector()); + + if ($this->hasFlag(self::ATTRIBUTE_VALUE_IN_LOWER_CASE)) { + $value = strtolower($value); + } + + return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value); + } + + /** + * @param Node\ClassNode $node + * @param Translator $translator + * + * @return XPathExpr + */ + public function translateClass(Node\ClassNode $node, Translator $translator) + { + $xpath = $translator->nodeToXPath($node->getSelector()); + + return $translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); + } + + /** + * @param Node\HashNode $node + * @param Translator $translator + * + * @return XPathExpr + */ + public function translateHash(Node\HashNode $node, Translator $translator) + { + $xpath = $translator->nodeToXPath($node->getSelector()); + + return $translator->addAttributeMatching($xpath, '=', '@id', $node->getId()); + } + + /** + * @param Node\ElementNode $node + * + * @return XPathExpr + */ + public function translateElement(Node\ElementNode $node) + { + $element = $node->getElement(); + + if ($this->hasFlag(self::ELEMENT_NAME_IN_LOWER_CASE)) { + $element = strtolower($element); + } + + if ($element) { + $safe = $this->isSafeName($element); + } else { + $element = '*'; + $safe = true; + } + + if ($node->getNamespace()) { + $element = sprintf('%s:%s', $node->getNamespace(), $element); + $safe = $safe && $this->isSafeName($node->getNamespace()); + } + + $xpath = new XPathExpr('', $element); + + if (!$safe) { + $xpath->addNameTest(); + } + + return $xpath; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'node'; + } + + /** + * Tests if given name is safe. + * + * @param string $name + * + * @return bool + */ + private function isSafeName($name) + { + return 0 < preg_match('~^[a-zA-Z_][a-zA-Z0-9_.-]*$~', $name); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php new file mode 100644 index 0000000..008ec2b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php @@ -0,0 +1,162 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator pseudo-class extension. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class PseudoClassExtension extends AbstractExtension +{ + /** + * {@inheritdoc} + */ + public function getPseudoClassTranslators() + { + return array( + 'root' => array($this, 'translateRoot'), + 'first-child' => array($this, 'translateFirstChild'), + 'last-child' => array($this, 'translateLastChild'), + 'first-of-type' => array($this, 'translateFirstOfType'), + 'last-of-type' => array($this, 'translateLastOfType'), + 'only-child' => array($this, 'translateOnlyChild'), + 'only-of-type' => array($this, 'translateOnlyOfType'), + 'empty' => array($this, 'translateEmpty'), + ); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateRoot(XPathExpr $xpath) + { + return $xpath->addCondition('not(parent::*)'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateFirstChild(XPathExpr $xpath) + { + return $xpath + ->addStarPrefix() + ->addNameTest() + ->addCondition('position() = 1'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateLastChild(XPathExpr $xpath) + { + return $xpath + ->addStarPrefix() + ->addNameTest() + ->addCondition('position() = last()'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateFirstOfType(XPathExpr $xpath) + { + if ('*' === $xpath->getElement()) { + throw new ExpressionErrorException('"*:first-of-type" is not implemented.'); + } + + return $xpath + ->addStarPrefix() + ->addCondition('position() = 1'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateLastOfType(XPathExpr $xpath) + { + if ('*' === $xpath->getElement()) { + throw new ExpressionErrorException('"*:last-of-type" is not implemented.'); + } + + return $xpath + ->addStarPrefix() + ->addCondition('position() = last()'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateOnlyChild(XPathExpr $xpath) + { + return $xpath + ->addStarPrefix() + ->addNameTest() + ->addCondition('last() = 1'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateOnlyOfType(XPathExpr $xpath) + { + if ('*' === $xpath->getElement()) { + throw new ExpressionErrorException('"*:only-of-type" is not implemented.'); + } + + return $xpath->addCondition('last() = 1'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateEmpty(XPathExpr $xpath) + { + return $xpath->addCondition('not(*) and not(string-length())'); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'pseudo-class'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php new file mode 100644 index 0000000..5053793 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php @@ -0,0 +1,299 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath; + +use Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\Node\NodeInterface; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Parser; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * XPath expression translator interface. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Translator implements TranslatorInterface +{ + /** + * @var ParserInterface + */ + private $mainParser; + + /** + * @var ParserInterface[] + */ + private $shortcutParsers = array(); + + /** + * @var Extension\ExtensionInterface + */ + private $extensions = array(); + + /** + * @var array + */ + private $nodeTranslators = array(); + + /** + * @var array + */ + private $combinationTranslators = array(); + + /** + * @var array + */ + private $functionTranslators = array(); + + /** + * @var array + */ + private $pseudoClassTranslators = array(); + + /** + * @var array + */ + private $attributeMatchingTranslators = array(); + + /** + * Constructor. + */ + public function __construct(ParserInterface $parser = null) + { + $this->mainParser = $parser ?: new Parser(); + + $this + ->registerExtension(new Extension\NodeExtension()) + ->registerExtension(new Extension\CombinationExtension()) + ->registerExtension(new Extension\FunctionExtension()) + ->registerExtension(new Extension\PseudoClassExtension()) + ->registerExtension(new Extension\AttributeMatchingExtension()) + ; + } + + /** + * @param string $element + * + * @return string + */ + public static function getXpathLiteral($element) + { + if (false === strpos($element, "'")) { + return "'".$element."'"; + } + + if (false === strpos($element, '"')) { + return '"'.$element.'"'; + } + + $string = $element; + $parts = array(); + while (true) { + if (false !== $pos = strpos($string, "'")) { + $parts[] = sprintf("'%s'", substr($string, 0, $pos)); + $parts[] = "\"'\""; + $string = substr($string, $pos + 1); + } else { + $parts[] = "'$string'"; + break; + } + } + + return sprintf('concat(%s)', implode($parts, ', ')); + } + + /** + * {@inheritdoc} + */ + public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::') + { + $selectors = $this->parseSelectors($cssExpr); + + /** @var SelectorNode $selector */ + foreach ($selectors as $index => $selector) { + if (null !== $selector->getPseudoElement()) { + throw new ExpressionErrorException('Pseudo-elements are not supported.'); + } + + $selectors[$index] = $this->selectorToXPath($selector, $prefix); + } + + return implode(' | ', $selectors); + } + + /** + * {@inheritdoc} + */ + public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::') + { + return ($prefix ?: '').$this->nodeToXPath($selector); + } + + /** + * Registers an extension. + * + * @param Extension\ExtensionInterface $extension + * + * @return Translator + */ + public function registerExtension(Extension\ExtensionInterface $extension) + { + $this->extensions[$extension->getName()] = $extension; + + $this->nodeTranslators = array_merge($this->nodeTranslators, $extension->getNodeTranslators()); + $this->combinationTranslators = array_merge($this->combinationTranslators, $extension->getCombinationTranslators()); + $this->functionTranslators = array_merge($this->functionTranslators, $extension->getFunctionTranslators()); + $this->pseudoClassTranslators = array_merge($this->pseudoClassTranslators, $extension->getPseudoClassTranslators()); + $this->attributeMatchingTranslators = array_merge($this->attributeMatchingTranslators, $extension->getAttributeMatchingTranslators()); + + return $this; + } + + /** + * @param string $name + * + * @return Extension\ExtensionInterface + * + * @throws ExpressionErrorException + */ + public function getExtension($name) + { + if (!isset($this->extensions[$name])) { + throw new ExpressionErrorException(sprintf('Extension "%s" not registered.', $name)); + } + + return $this->extensions[$name]; + } + + /** + * Registers a shortcut parser. + * + * @param ParserInterface $shortcut + * + * @return Translator + */ + public function registerParserShortcut(ParserInterface $shortcut) + { + $this->shortcutParsers[] = $shortcut; + + return $this; + } + + /** + * @param NodeInterface $node + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function nodeToXPath(NodeInterface $node) + { + if (!isset($this->nodeTranslators[$node->getNodeName()])) { + throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName())); + } + + return call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this); + } + + /** + * @param string $combiner + * @param NodeInterface $xpath + * @param NodeInterface $combinedXpath + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function addCombination($combiner, NodeInterface $xpath, NodeInterface $combinedXpath) + { + if (!isset($this->combinationTranslators[$combiner])) { + throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner)); + } + + return call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath)); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function addFunction(XPathExpr $xpath, FunctionNode $function) + { + if (!isset($this->functionTranslators[$function->getName()])) { + throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName())); + } + + return call_user_func($this->functionTranslators[$function->getName()], $xpath, $function); + } + + /** + * @param XPathExpr $xpath + * @param string $pseudoClass + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function addPseudoClass(XPathExpr $xpath, $pseudoClass) + { + if (!isset($this->pseudoClassTranslators[$pseudoClass])) { + throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass)); + } + + return call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath); + } + + /** + * @param XPathExpr $xpath + * @param string $operator + * @param string $attribute + * @param string $value + * + * @throws ExpressionErrorException + * + * @return XPathExpr + */ + public function addAttributeMatching(XPathExpr $xpath, $operator, $attribute, $value) + { + if (!isset($this->attributeMatchingTranslators[$operator])) { + throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator)); + } + + return call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value); + } + + /** + * @param string $css + * + * @return SelectorNode[] + */ + private function parseSelectors($css) + { + foreach ($this->shortcutParsers as $shortcut) { + $tokens = $shortcut->parse($css); + + if (!empty($tokens)) { + return $tokens; + } + } + + return $this->mainParser->parse($css); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/TranslatorInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/TranslatorInterface.php new file mode 100644 index 0000000..1d9d1c8 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/TranslatorInterface.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath; + +use Symfony\Component\CssSelector\Node\SelectorNode; + +/** + * XPath expression translator interface. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface TranslatorInterface +{ + /** + * Translates a CSS selector to an XPath expression. + * + * @param string $cssExpr + * @param string $prefix + * + * @return XPathExpr + */ + public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::'); + + /** + * Translates a parsed selector node to an XPath expression. + * + * @param SelectorNode $selector + * @param string $prefix + * + * @return XPathExpr + */ + public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::'); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/XPathExpr.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/XPathExpr.php new file mode 100644 index 0000000..c7ef97c --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/XPathExpr.php @@ -0,0 +1,140 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath; + +/** + * XPath expression translator interface. + * + * This component is a port of the Python cssselect library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class XPathExpr +{ + /** + * @var string + */ + private $path; + + /** + * @var string + */ + private $element; + + /** + * @var string + */ + private $condition; + + /** + * @param string $path + * @param string $element + * @param string $condition + * @param bool $starPrefix + */ + public function __construct($path = '', $element = '*', $condition = '', $starPrefix = false) + { + $this->path = $path; + $this->element = $element; + $this->condition = $condition; + + if ($starPrefix) { + $this->addStarPrefix(); + } + } + + /** + * @return string + */ + public function getElement() + { + return $this->element; + } + + /** + * @param $condition + * + * @return XPathExpr + */ + public function addCondition($condition) + { + $this->condition = $this->condition ? sprintf('%s and (%s)', $this->condition, $condition) : $condition; + + return $this; + } + + /** + * @return string + */ + public function getCondition() + { + return $this->condition; + } + + /** + * @return XPathExpr + */ + public function addNameTest() + { + if ('*' !== $this->element) { + $this->addCondition('name() = '.Translator::getXpathLiteral($this->element)); + $this->element = '*'; + } + + return $this; + } + + /** + * @return XPathExpr + */ + public function addStarPrefix() + { + $this->path .= '*/'; + + return $this; + } + + /** + * Joins another XPathExpr with a combiner. + * + * @param string $combiner + * @param XPathExpr $expr + * + * @return XPathExpr + */ + public function join($combiner, XPathExpr $expr) + { + $path = $this->__toString().$combiner; + + if ('*/' !== $expr->path) { + $path .= $expr->path; + } + + $this->path = $path; + $this->element = $expr->element; + $this->condition = $expr->condition; + + return $this; + } + + /** + * @return string + */ + public function __toString() + { + $path = $this->path.$this->element; + $condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']'; + + return $path.$condition; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPathExpr.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPathExpr.php deleted file mode 100644 index 507b8ac..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPathExpr.php +++ /dev/null @@ -1,254 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector; - -/** - * XPathExpr represents an XPath expression. - * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. - * - * @author Fabien Potencier - */ -class XPathExpr -{ - private $prefix; - private $path; - private $element; - private $condition; - private $starPrefix; - - /** - * Constructor. - * - * @param string $prefix Prefix for the XPath expression. - * @param string $path Actual path of the expression. - * @param string $element The element in the expression. - * @param string $condition A condition for the expression. - * @param Boolean $starPrefix Indicates whether to use a star prefix. - */ - public function __construct($prefix = null, $path = null, $element = '*', $condition = null, $starPrefix = false) - { - $this->prefix = $prefix; - $this->path = $path; - $this->element = $element; - $this->condition = $condition; - $this->starPrefix = $starPrefix; - } - - /** - * Gets the prefix of this XPath expression. - * - * @return string - */ - public function getPrefix() - { - return $this->prefix; - } - - /** - * Gets the path of this XPath expression. - * - * @return string - */ - public function getPath() - { - return $this->path; - } - - /** - * Answers whether this XPath expression has a star prefix. - * - * @return Boolean - */ - public function hasStarPrefix() - { - return $this->starPrefix; - } - - /** - * Gets the element of this XPath expression. - * - * @return string - */ - public function getElement() - { - return $this->element; - } - - /** - * Gets the condition of this XPath expression. - * - * @return string - */ - public function getCondition() - { - return $this->condition; - } - - /** - * Gets a string representation for this XPath expression. - * - * @return string - */ - public function __toString() - { - $path = ''; - if (null !== $this->prefix) { - $path .= $this->prefix; - } - - if (null !== $this->path) { - $path .= $this->path; - } - - $path .= $this->element; - - if ($this->condition) { - $path .= sprintf('[%s]', $this->condition); - } - - return $path; - } - - /** - * Adds a condition to this XPath expression. - * Any pre-existent condition will be ANDed to it. - * - * @param string $condition The condition to add. - */ - public function addCondition($condition) - { - if ($this->condition) { - $this->condition = sprintf('%s and (%s)', $this->condition, $condition); - } else { - $this->condition = $condition; - } - } - - /** - * Adds a prefix to this XPath expression. - * It will be prepended to any pre-existent prefixes. - * - * @param string $prefix The prefix to add. - */ - public function addPrefix($prefix) - { - if ($this->prefix) { - $this->prefix = $prefix.$this->prefix; - } else { - $this->prefix = $prefix; - } - } - - /** - * Adds a condition to this XPath expression using the name of the element - * as the desired value. - * This method resets the element to '*'. - */ - public function addNameTest() - { - if ($this->element == '*') { - // We weren't doing a test anyway - return; - } - - $this->addCondition(sprintf('name() = %s', XPathExpr::xpathLiteral($this->element))); - $this->element = '*'; - } - - /** - * Adds a star prefix to this XPath expression. - * This method will prepend a '*' to the path and set the star prefix flag - * to true. - */ - public function addStarPrefix() - { - /* - Adds a /* prefix if there is no prefix. This is when you need - to keep context's constrained to a single parent. - */ - if ($this->path) { - $this->path .= '*/'; - } else { - $this->path = '*/'; - } - - $this->starPrefix = true; - } - - /** - * Joins this XPath expression with $other (another XPath expression) using - * $combiner to join them. - * - * @param string $combiner The combiner string. - * @param XPathExpr $other The other XPath expression to combine with - * this one. - */ - public function join($combiner, $other) - { - $prefix = (string) $this; - - $prefix .= $combiner; - $path = $other->getPrefix().$other->getPath(); - - /* We don't need a star prefix if we are joining to this other - prefix; so we'll get rid of it */ - if ($other->hasStarPrefix() && '*/' == $path) { - $path = ''; - } - $this->prefix = $prefix; - $this->path = $path; - $this->element = $other->getElement(); - $this->condition = $other->GetCondition(); - } - - /** - * Gets an XPath literal for $s. - * - * @param mixed $s Can either be a Node\ElementNode or a string. - * - * @return string - */ - public static function xpathLiteral($s) - { - if ($s instanceof Node\ElementNode) { - // This is probably a symbol that looks like an expression... - $s = $s->formatElement(); - } else { - $s = (string) $s; - } - - if (false === strpos($s, "'")) { - return sprintf("'%s'", $s); - } - - if (false === strpos($s, '"')) { - return sprintf('"%s"', $s); - } - - $string = $s; - $parts = array(); - while (true) { - if (false !== $pos = strpos($string, "'")) { - $parts[] = sprintf("'%s'", substr($string, 0, $pos)); - $parts[] = "\"'\""; - $string = substr($string, $pos + 1); - } else { - $parts[] = "'$string'"; - break; - } - } - - return sprintf('concat(%s)', implode($parts, ', ')); - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPathExprOr.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPathExprOr.php deleted file mode 100644 index f516367..0000000 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPathExprOr.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\CssSelector; - -/** - * XPathExprOr represents XPath |'d expressions. - * - * Note that unfortunately it isn't the union, it's the sum, so duplicate elements will appear. - * - * This component is a port of the Python lxml library, - * which is copyright Infrae and distributed under the BSD license. - * - * @author Fabien Potencier - */ -class XPathExprOr extends XPathExpr -{ - /** - * Constructor. - * - * @param array $items The items in the expression. - * @param string $prefix Optional prefix for the expression. - */ - public function __construct($items, $prefix = null) - { - $this->items = $items; - $this->prefix = $prefix; - } - - /** - * Gets a string representation of this |'d expression. - * - * @return string - */ - public function __toString() - { - $prefix = $this->getPrefix(); - - $tmp = array(); - foreach ($this->items as $i) { - $tmp[] = sprintf('%s%s', $prefix, $i); - } - - return implode($tmp, ' | '); - } -} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json b/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json index 54661fb..831b8eb 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json @@ -10,6 +10,10 @@ "name": "Fabien Potencier", "email": "fabien@symfony.com" }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" @@ -18,6 +22,9 @@ "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "autoload": { "psr-0": { "Symfony\\Component\\CssSelector\\": "" } }, @@ -25,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.6-dev" } } } diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist b/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist index a19dc00..bc57cfc 100644 --- a/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist @@ -1,16 +1,14 @@ - + + + ./Tests/ diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/.gitignore b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/.gitignore index 44de97a..c49a5d8 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/.gitignore +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/.gitignore @@ -1,4 +1,3 @@ vendor/ composer.lock phpunit.xml - diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/CHANGELOG.md b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/CHANGELOG.md index 815162c..48fd323 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/CHANGELOG.md +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/CHANGELOG.md @@ -1,6 +1,33 @@ CHANGELOG ========= +2.5.0 +----- + +* [BC BREAK] The default value for checkbox and radio inputs without a value attribute have changed + from '1' to 'on' to match the HTML specification. +* [BC BREAK] The typehints on the `Link`, `Form` and `FormField` classes have been changed from + `\DOMNode` to `DOMElement`. Using any other type of `DOMNode` was triggering fatal errors in previous + versions. Code extending these classes will need to update the typehints when overwriting these methods. + +2.4.0 +----- + + * `Crawler::addXmlContent()` removes the default document namespace again if it's an only namespace. + * added support for automatic discovery and explicit registration of document + namespaces for `Crawler::filterXPath()` and `Crawler::filter()` + * improved content type guessing in `Crawler::addContent()` + * [BC BREAK] `Crawler::addXmlContent()` no longer removes the default document + namespace + +2.3.0 +----- + + * added Crawler::html() + * [BC BREAK] Crawler::each() and Crawler::reduce() now return Crawler instances instead of DomElement instances + * added schema relative URL support to links + * added support for HTML5 'form' attribute + 2.2.0 ----- diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php index 56a84f5..82a790c 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php @@ -14,7 +14,7 @@ use Symfony\Component\CssSelector\CssSelector; /** - * Crawler eases navigation of a list of \DOMNode objects. + * Crawler eases navigation of a list of \DOMElement objects. * * @author Fabien Potencier * @@ -23,21 +23,38 @@ class Crawler extends \SplObjectStorage { /** - * @var string The current URI or the base href value + * @var string The current URI */ - private $uri; + protected $uri; + + /** + * @var string The default namespace prefix to be used with XPath and CSS expressions + */ + private $defaultNamespacePrefix = 'default'; + + /** + * @var array A map of manually registered namespaces + */ + private $namespaces = array(); + + /** + * @var string The base href value + */ + private $baseHref; /** * Constructor. * - * @param mixed $node A Node to use as the base for the crawling - * @param string $uri The current URI or the base href value + * @param mixed $node A Node to use as the base for the crawling + * @param string $currentUri The current URI + * @param string $baseHref The base href value * * @api */ - public function __construct($node = null, $uri = null) + public function __construct($node = null, $currentUri = null, $baseHref = null) { - $this->uri = $uri; + $this->uri = $currentUri; + $this->baseHref = $baseHref ?: $currentUri; $this->add($node); } @@ -58,7 +75,9 @@ public function clear() * This method uses the appropriate specialized add*() method based * on the type of the argument. * - * @param null|\DOMNodeList|array|\DOMNode $node A node + * @param \DOMNodeList|\DOMNode|array|string|null $node A node + * + * @throws \InvalidArgumentException When node is not the expected type. * * @api */ @@ -66,43 +85,58 @@ public function add($node) { if ($node instanceof \DOMNodeList) { $this->addNodeList($node); + } elseif ($node instanceof \DOMNode) { + $this->addNode($node); } elseif (is_array($node)) { $this->addNodes($node); } elseif (is_string($node)) { $this->addContent($node); - } elseif (is_object($node)) { - $this->addNode($node); + } elseif (null !== $node) { + throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', is_object($node) ? get_class($node) : gettype($node))); } } /** * Adds HTML/XML content. * + * If the charset is not set via the content type, it is assumed + * to be ISO-8859-1, which is the default charset defined by the + * HTTP 1.1 specification. + * * @param string $content A string to parse as HTML/XML * @param null|string $type The content type of the string - * - * @return null|void */ public function addContent($content, $type = null) { if (empty($type)) { - $type = 'text/html'; + $type = 0 === strpos($content, ']+charset *= *["\']?([a-zA-Z\-0-9_:.]+)/i', $content, $matches)) { + $charset = $matches[1]; + } + + if (null === $charset) { + $charset = 'ISO-8859-1'; + } + + if ('x' === $xmlMatches[1]) { $this->addXmlContent($content, $charset); } else { $this->addHtmlContent($content, $charset); @@ -126,28 +160,47 @@ public function addContent($content, $type = null) */ public function addHtmlContent($content, $charset = 'UTF-8') { - $current = libxml_use_internal_errors(true); + $internalErrors = libxml_use_internal_errors(true); $disableEntities = libxml_disable_entity_loader(true); $dom = new \DOMDocument('1.0', $charset); $dom->validateOnParse = true; - if (function_exists('mb_convert_encoding') && in_array(strtolower($charset), array_map('strtolower', mb_list_encodings()))) { - $content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset); + if (function_exists('mb_convert_encoding')) { + $hasError = false; + set_error_handler(function () use (&$hasError) { + $hasError = true; + }); + $tmpContent = @mb_convert_encoding($content, 'HTML-ENTITIES', $charset); + + restore_error_handler(); + + if (!$hasError) { + $content = $tmpContent; + } } - @$dom->loadHTML($content); + if ('' !== trim($content)) { + @$dom->loadHTML($content); + } - libxml_use_internal_errors($current); + libxml_use_internal_errors($internalErrors); libxml_disable_entity_loader($disableEntities); $this->addDocument($dom); - $base = $this->filterXPath('descendant-or-self::base')->extract(array('href')); + $base = $this->filterRelativeXPath('descendant-or-self::base')->extract(array('href')); $baseHref = current($base); if (count($base) && !empty($baseHref)) { - $this->uri = $baseHref; + if ($this->baseHref) { + $linkNode = $dom->createElement('a'); + $linkNode->setAttribute('href', $baseHref); + $link = new Link($linkNode, $this->baseHref); + $this->baseHref = $link->getUri(); + } else { + $this->baseHref = $baseHref; + } } } @@ -168,16 +221,22 @@ public function addHtmlContent($content, $charset = 'UTF-8') */ public function addXmlContent($content, $charset = 'UTF-8') { - $current = libxml_use_internal_errors(true); + // remove the default namespace if it's the only namespace to make XPath expressions simpler + if (!preg_match('/xmlns:/', $content)) { + $content = str_replace('xmlns', 'ns', $content); + } + + $internalErrors = libxml_use_internal_errors(true); $disableEntities = libxml_disable_entity_loader(true); $dom = new \DOMDocument('1.0', $charset); $dom->validateOnParse = true; - // remove the default namespace to make XPath expressions simpler - @$dom->loadXML(str_replace('xmlns', 'ns', $content), LIBXML_NONET); + if ('' !== trim($content)) { + @$dom->loadXML($content, LIBXML_NONET); + } - libxml_use_internal_errors($current); + libxml_use_internal_errors($internalErrors); libxml_disable_entity_loader($disableEntities); $this->addDocument($dom); @@ -207,7 +266,9 @@ public function addDocument(\DOMDocument $dom) public function addNodeList(\DOMNodeList $nodes) { foreach ($nodes as $node) { - $this->addNode($node); + if ($node instanceof \DOMNode) { + $this->addNode($node); + } } } @@ -244,7 +305,7 @@ public function addNode(\DOMNode $node) /** * Returns a node given its position in the node list. * - * @param integer $position The position + * @param int $position The position * * @return Crawler A new instance of the Crawler with the selected node, or an empty Crawler if it does not exist. * @@ -254,23 +315,23 @@ public function eq($position) { foreach ($this as $i => $node) { if ($i == $position) { - return new static($node, $this->uri); + return new static($node, $this->uri, $this->baseHref); } } - return new static(null, $this->uri); + return new static(null, $this->uri, $this->baseHref); } /** * Calls an anonymous function on each node of the list. * - * The anonymous function receives the position and the node as arguments. + * The anonymous function receives the position and the node wrapped + * in a Crawler instance as arguments. * * Example: * - * $crawler->filter('h1')->each(function ($node, $i) - * { - * return $node->nodeValue; + * $crawler->filter('h1')->each(function ($node, $i) { + * return $node->text(); * }); * * @param \Closure $closure An anonymous function @@ -283,12 +344,25 @@ public function each(\Closure $closure) { $data = array(); foreach ($this as $i => $node) { - $data[] = $closure($node, $i); + $data[] = $closure(new static($node, $this->uri, $this->baseHref), $i); } return $data; } + /** + * Slices the list of nodes by $offset and $length. + * + * @param int $offset + * @param int $length + * + * @return Crawler A Crawler instance with the sliced nodes + */ + public function slice($offset = 0, $length = -1) + { + return new static(iterator_to_array(new \LimitIterator($this, $offset, $length)), $this->uri); + } + /** * Reduces the list of nodes by calling an anonymous function. * @@ -304,16 +378,16 @@ public function reduce(\Closure $closure) { $nodes = array(); foreach ($this as $i => $node) { - if (false !== $closure($node, $i)) { + if (false !== $closure(new static($node, $this->uri, $this->baseHref), $i)) { $nodes[] = $node; } } - return new static($nodes, $this->uri); + return new static($nodes, $this->uri, $this->baseHref); } /** - * Returns the first node of the current selection + * Returns the first node of the current selection. * * @return Crawler A Crawler instance with the first selected node * @@ -325,7 +399,7 @@ public function first() } /** - * Returns the last node of the current selection + * Returns the last node of the current selection. * * @return Crawler A Crawler instance with the last selected node * @@ -337,7 +411,7 @@ public function last() } /** - * Returns the siblings nodes of the current selection + * Returns the siblings nodes of the current selection. * * @return Crawler A Crawler instance with the sibling nodes * @@ -351,11 +425,11 @@ public function siblings() throw new \InvalidArgumentException('The current node list is empty.'); } - return new static($this->sibling($this->getNode(0)->parentNode->firstChild), $this->uri); + return new static($this->sibling($this->getNode(0)->parentNode->firstChild), $this->uri, $this->baseHref); } /** - * Returns the next siblings nodes of the current selection + * Returns the next siblings nodes of the current selection. * * @return Crawler A Crawler instance with the next sibling nodes * @@ -369,11 +443,11 @@ public function nextAll() throw new \InvalidArgumentException('The current node list is empty.'); } - return new static($this->sibling($this->getNode(0)), $this->uri); + return new static($this->sibling($this->getNode(0)), $this->uri, $this->baseHref); } /** - * Returns the previous sibling nodes of the current selection + * Returns the previous sibling nodes of the current selection. * * @return Crawler A Crawler instance with the previous sibling nodes * @@ -387,11 +461,11 @@ public function previousAll() throw new \InvalidArgumentException('The current node list is empty.'); } - return new static($this->sibling($this->getNode(0), 'previousSibling'), $this->uri); + return new static($this->sibling($this->getNode(0), 'previousSibling'), $this->uri, $this->baseHref); } /** - * Returns the parents nodes of the current selection + * Returns the parents nodes of the current selection. * * @return Crawler A Crawler instance with the parents nodes of the current selection * @@ -409,16 +483,16 @@ public function parents() $nodes = array(); while ($node = $node->parentNode) { - if (1 === $node->nodeType && '_root' !== $node->nodeName) { + if (1 === $node->nodeType) { $nodes[] = $node; } } - return new static($nodes, $this->uri); + return new static($nodes, $this->uri, $this->baseHref); } /** - * Returns the children nodes of the current selection + * Returns the children nodes of the current selection. * * @return Crawler A Crawler instance with the children nodes * @@ -432,7 +506,9 @@ public function children() throw new \InvalidArgumentException('The current node list is empty.'); } - return new static($this->sibling($this->getNode(0)->firstChild), $this->uri); + $node = $this->getNode(0)->firstChild; + + return new static($node ? $this->sibling($node) : array(), $this->uri, $this->baseHref); } /** @@ -440,7 +516,7 @@ public function children() * * @param string $attribute The attribute name * - * @return string The attribute value + * @return string|null The attribute value or null if the attribute does not exist * * @throws \InvalidArgumentException When current node is empty * @@ -452,7 +528,25 @@ public function attr($attribute) throw new \InvalidArgumentException('The current node list is empty.'); } - return $this->getNode(0)->getAttribute($attribute); + $node = $this->getNode(0); + + return $node->hasAttribute($attribute) ? $node->getAttribute($attribute) : null; + } + + /** + * Returns the node name of the first node of the list. + * + * @return string The node name + * + * @throws \InvalidArgumentException When current node is empty + */ + public function nodeName() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + return $this->getNode(0)->nodeName; } /** @@ -473,6 +567,35 @@ public function text() return $this->getNode(0)->nodeValue; } + /** + * Returns the first node of the list as HTML. + * + * @return string The node html + * + * @throws \InvalidArgumentException When current node is empty + */ + public function html() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + $html = ''; + foreach ($this->getNode(0)->childNodes as $child) { + if (PHP_VERSION_ID >= 50306) { + // node parameter was added to the saveHTML() method in PHP 5.3.6 + // @see http://php.net/manual/en/domdocument.savehtml.php + $html .= $child->ownerDocument->saveHTML($child); + } else { + $document = new \DOMDocument('1.0', 'UTF-8'); + $document->appendChild($document->importNode($child, true)); + $html .= rtrim($document->saveHTML()); + } + } + + return $html; + } + /** * Extracts information from the list of nodes. * @@ -491,6 +614,7 @@ public function text() public function extract($attributes) { $attributes = (array) $attributes; + $count = count($attributes); $data = array(); foreach ($this as $node) { @@ -503,7 +627,7 @@ public function extract($attributes) } } - $data[] = count($attributes) > 1 ? $elements : $elements[0]; + $data[] = $count > 1 ? $elements : $elements[0]; } return $data; @@ -512,6 +636,11 @@ public function extract($attributes) /** * Filters the list of nodes with an XPath expression. * + * The XPath expression is evaluated in the context of the crawler, which + * is considered as a fake parent of the elements inside it. + * This means that a child selector "div" or "./div" will match only + * the div elements of the current crawler, not their children. + * * @param string $xpath An XPath expression * * @return Crawler A new instance of Crawler with the filtered list of nodes @@ -520,15 +649,14 @@ public function extract($attributes) */ public function filterXPath($xpath) { - $document = new \DOMDocument('1.0', 'UTF-8'); - $root = $document->appendChild($document->createElement('_root')); - foreach ($this as $node) { - $root->appendChild($document->importNode($node, true)); - } + $xpath = $this->relativize($xpath); - $domxpath = new \DOMXPath($document); + // If we dropped all expressions in the XPath while preparing it, there would be no match + if ('' === $xpath) { + return new static(null, $this->uri, $this->baseHref); + } - return new static($domxpath->query($xpath), $this->uri); + return $this->filterRelativeXPath($xpath); } /** @@ -547,12 +675,11 @@ public function filterXPath($xpath) public function filter($selector) { if (!class_exists('Symfony\\Component\\CssSelector\\CssSelector')) { - // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector is not installed (you can use filterXPath instead).'); - // @codeCoverageIgnoreEnd } - return $this->filterXPath(CssSelector::toXPath($selector)); + // The CssSelector already prefixes the selector with descendant-or-self:: + return $this->filterRelativeXPath(CssSelector::toXPath($selector)); } /** @@ -566,10 +693,10 @@ public function filter($selector) */ public function selectLink($value) { - $xpath = sprintf('//a[contains(concat(\' \', normalize-space(string(.)), \' \'), %s)] ', static::xpathLiteral(' '.$value.' ')). - sprintf('| //a/img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)]/ancestor::a', static::xpathLiteral(' '.$value.' ')); + $xpath = sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) ', static::xpathLiteral(' '.$value.' ')). + sprintf('or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)]]', static::xpathLiteral(' '.$value.' ')); - return $this->filterXPath($xpath); + return $this->filterRelativeXPath($xpath); } /** @@ -583,11 +710,12 @@ public function selectLink($value) */ public function selectButton($value) { - $xpath = sprintf('//input[((@type="submit" or @type="button") and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', static::xpathLiteral(' '.$value.' ')). - sprintf('or (@type="image" and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id="%s" or @name="%s"] ', static::xpathLiteral(' '.$value.' '), $value, $value). - sprintf('| //button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id="%s" or @name="%s"]', static::xpathLiteral(' '.$value.' '), $value, $value); + $translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")'; + $xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, $translate, static::xpathLiteral(' '.$value.' ')). + sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ', $translate, static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)). + sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)); - return $this->filterXPath($xpath); + return $this->filterRelativeXPath($xpath); } /** @@ -609,7 +737,7 @@ public function link($method = 'get') $node = $this->getNode(0); - return new Link($node, $this->uri, $method); + return new Link($node, $this->baseHref, $method); } /** @@ -623,7 +751,7 @@ public function links() { $links = array(); foreach ($this as $node) { - $links[] = new Link($node, $this->uri, 'get'); + $links[] = new Link($node, $this->baseHref, 'get'); } return $links; @@ -656,6 +784,25 @@ public function form(array $values = null, $method = null) return $form; } + /** + * Overloads a default namespace prefix to be used with XPath and CSS expressions. + * + * @param string $prefix + */ + public function setDefaultNamespacePrefix($prefix) + { + $this->defaultNamespacePrefix = $prefix; + } + + /** + * @param string $prefix + * @param string $namespace + */ + public function registerNamespace($prefix, $namespace) + { + $this->namespaces[$prefix] = $namespace; + } + /** * Converts string for XPath expressions. * @@ -676,7 +823,6 @@ public function form(array $values = null, $method = null) * @param string $s String to be escaped * * @return string Converted string - * */ public static function xpathLiteral($s) { @@ -701,23 +847,123 @@ public static function xpathLiteral($s) } } - return sprintf("concat(%s)", implode($parts, ', ')); + return sprintf('concat(%s)', implode($parts, ', ')); + } + + /** + * Filters the list of nodes with an XPath expression. + * + * The XPath expression should already be processed to apply it in the context of each node. + * + * @param string $xpath + * + * @return Crawler + */ + private function filterRelativeXPath($xpath) + { + $prefixes = $this->findNamespacePrefixes($xpath); + + $crawler = new static(null, $this->uri, $this->baseHref); + + foreach ($this as $node) { + $domxpath = $this->createDOMXPath($node->ownerDocument, $prefixes); + $crawler->add($domxpath->query($xpath, $node)); + } + + return $crawler; + } + + /** + * Make the XPath relative to the current context. + * + * The returned XPath will match elements matching the XPath inside the current crawler + * when running in the context of a node of the crawler. + * + * @param string $xpath + * + * @return string + */ + private function relativize($xpath) + { + $expressions = array(); + + $unionPattern = '/\|(?![^\[]*\])/'; + // An expression which will never match to replace expressions which cannot match in the crawler + // We cannot simply drop + $nonMatchingExpression = 'a[name() = "b"]'; + + // Split any unions into individual expressions. + foreach (preg_split($unionPattern, $xpath) as $expression) { + $expression = trim($expression); + $parenthesis = ''; + + // If the union is inside some braces, we need to preserve the opening braces and apply + // the change only inside it. + if (preg_match('/^[\(\s*]+/', $expression, $matches)) { + $parenthesis = $matches[0]; + $expression = substr($expression, strlen($parenthesis)); + } + + // BC for Symfony 2.4 and lower were elements were adding in a fake _root parent + if (0 === strpos($expression, '/_root/')) { + $expression = './'.substr($expression, 7); + } elseif (0 === strpos($expression, 'self::*/')) { + $expression = './'.substr($expression, 8); + } + + // add prefix before absolute element selector + if (empty($expression)) { + $expression = $nonMatchingExpression; + } elseif (0 === strpos($expression, '//')) { + $expression = 'descendant-or-self::'.substr($expression, 2); + } elseif (0 === strpos($expression, './/')) { + $expression = 'descendant-or-self::'.substr($expression, 3); + } elseif (0 === strpos($expression, './')) { + $expression = 'self::'.substr($expression, 2); + } elseif (0 === strpos($expression, 'child::')) { + $expression = 'self::'.substr($expression, 7); + } elseif ('/' === $expression[0] || 0 === strpos($expression, 'self::')) { + // the only direct child in Symfony 2.4 and lower is _root, which is already handled previously + // so let's drop the expression entirely + $expression = $nonMatchingExpression; + } elseif ('.' === $expression[0]) { + // '.' is the fake root element in Symfony 2.4 and lower, which is excluded from results + $expression = $nonMatchingExpression; + } elseif (0 === strpos($expression, 'descendant::')) { + $expression = 'descendant-or-self::'.substr($expression, strlen('descendant::')); + } elseif (preg_match('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/', $expression)) { + // the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes) + $expression = $nonMatchingExpression; + } elseif (0 !== strpos($expression, 'descendant-or-self::')) { + $expression = 'self::'.$expression; + } + $expressions[] = $parenthesis.$expression; + } + + return implode(' | ', $expressions); } - private function getNode($position) + /** + * @param int $position + * + * @return \DOMElement|null + */ + public function getNode($position) { foreach ($this as $i => $node) { if ($i == $position) { return $node; } - // @codeCoverageIgnoreStart } - - return null; - // @codeCoverageIgnoreEnd } - private function sibling($node, $siblingDir = 'nextSibling') + /** + * @param \DOMElement $node + * @param string $siblingDir + * + * @return array + */ + protected function sibling($node, $siblingDir = 'nextSibling') { $nodes = array(); @@ -729,4 +975,62 @@ private function sibling($node, $siblingDir = 'nextSibling') return $nodes; } + + /** + * @param \DOMDocument $document + * @param array $prefixes + * + * @return \DOMXPath + * + * @throws \InvalidArgumentException + */ + private function createDOMXPath(\DOMDocument $document, array $prefixes = array()) + { + $domxpath = new \DOMXPath($document); + + foreach ($prefixes as $prefix) { + $namespace = $this->discoverNamespace($domxpath, $prefix); + if (null !== $namespace) { + $domxpath->registerNamespace($prefix, $namespace); + } + } + + return $domxpath; + } + + /** + * @param \DOMXPath $domxpath + * @param string $prefix + * + * @return string + * + * @throws \InvalidArgumentException + */ + private function discoverNamespace(\DOMXPath $domxpath, $prefix) + { + if (isset($this->namespaces[$prefix])) { + return $this->namespaces[$prefix]; + } + + // ask for one namespace, otherwise we'd get a collection with an item for each node + $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix)); + + if ($node = $namespaces->item(0)) { + return $node->nodeValue; + } + } + + /** + * @param $xpath + * + * @return array + */ + private function findNamespacePrefixes($xpath) + { + if (preg_match_all('/(?P[a-z_][a-z_0-9\-\.]*):[^"\/:]/i', $xpath, $matches)) { + return array_unique($matches['prefix']); + } + + return array(); + } } diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index 2e192cb..ae7f4d1 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -27,18 +27,22 @@ class ChoiceFormField extends FormField */ private $type; /** - * @var Boolean + * @var bool */ private $multiple; /** * @var array */ private $options; + /** + * @var bool + */ + private $validationDisabled = false; /** * Returns true if the field should be included in the submitted values. * - * @return Boolean true if the field should be included in the submitted values, false otherwise + * @return bool true if the field should be included in the submitted values, false otherwise */ public function hasValue() { @@ -51,9 +55,9 @@ public function hasValue() } /** - * Check if the current selected option is disabled + * Check if the current selected option is disabled. * - * @return Boolean + * @return bool */ public function isDisabled() { @@ -119,10 +123,10 @@ public function untick() */ public function setValue($value) { - if ('checkbox' == $this->type && false === $value) { + if ('checkbox' === $this->type && false === $value) { // uncheck $this->value = null; - } elseif ('checkbox' == $this->type && true === $value) { + } elseif ('checkbox' === $this->type && true === $value) { // check $this->value = $this->options[0]['value']; } else { @@ -157,20 +161,20 @@ public function setValue($value) * * This method should only be used internally. * - * @param \DOMNode $node A \DOMNode + * @param \DOMElement $node * * @throws \LogicException When choice provided is not multiple nor radio */ - public function addChoice(\DOMNode $node) + public function addChoice(\DOMElement $node) { - if (!$this->multiple && 'radio' != $this->type) { + if (!$this->multiple && 'radio' !== $this->type) { throw new \LogicException(sprintf('Unable to add a choice for "%s" as it is not multiple or is not a radio button.', $this->name)); } $option = $this->buildOptionValue($node); $this->options[] = $option; - if ($node->getAttribute('checked')) { + if ($node->hasAttribute('checked')) { $this->value = $option['value']; } } @@ -188,7 +192,7 @@ public function getType() /** * Returns true if the field accepts multiple values. * - * @return Boolean true if the field accepts multiple values, false otherwise + * @return bool true if the field accepts multiple values, false otherwise */ public function isMultiple() { @@ -202,11 +206,11 @@ public function isMultiple() */ protected function initialize() { - if ('input' != $this->node->nodeName && 'select' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName && 'select' !== $this->node->nodeName) { throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName)); } - if ('input' == $this->node->nodeName && 'checkbox' != $this->node->getAttribute('type') && 'radio' != $this->node->getAttribute('type')) { + if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) { throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type'))); } @@ -215,11 +219,11 @@ protected function initialize() $this->multiple = false; if ('input' == $this->node->nodeName) { - $this->type = $this->node->getAttribute('type'); + $this->type = strtolower($this->node->getAttribute('type')); $optionValue = $this->buildOptionValue($this->node); $this->options[] = $optionValue; - if ($this->node->getAttribute('checked')) { + if ($this->node->hasAttribute('checked')) { $this->value = $optionValue['value']; } } else { @@ -232,46 +236,46 @@ protected function initialize() $found = false; foreach ($this->xpath->query('descendant::option', $this->node) as $option) { - $this->options[] = $this->buildOptionValue($option); + $optionValue = $this->buildOptionValue($option); + $this->options[] = $optionValue; - if ($option->getAttribute('selected')) { + if ($option->hasAttribute('selected')) { $found = true; if ($this->multiple) { - $this->value[] = $option->getAttribute('value'); + $this->value[] = $optionValue['value']; } else { - $this->value = $option->getAttribute('value'); + $this->value = $optionValue['value']; } } } // if no option is selected and if it is a simple select box, take the first option as the value - $option = $this->xpath->query('descendant::option', $this->node)->item(0); - if (!$found && !$this->multiple && $option instanceof \DOMElement) { - $this->value = $option->getAttribute('value'); + if (!$found && !$this->multiple && !empty($this->options)) { + $this->value = $this->options[0]['value']; } } } /** - * Returns option value with associated disabled flag + * Returns option value with associated disabled flag. * - * @param \DOMNode $node + * @param \DOMElement $node * * @return array */ - private function buildOptionValue($node) + private function buildOptionValue(\DOMElement $node) { $option = array(); - $defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : '1'; + $defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : 'on'; $option['value'] = $node->hasAttribute('value') ? $node->getAttribute('value') : $defaultValue; - $option['disabled'] = ($node->hasAttribute('disabled') && $node->getAttribute('disabled') == 'disabled'); + $option['disabled'] = $node->hasAttribute('disabled'); return $option; } /** - * Checks whether given vale is in the existing options + * Checks whether given value is in the existing options. * * @param string $optionValue * @param array $options @@ -280,6 +284,10 @@ private function buildOptionValue($node) */ public function containsOption($optionValue, $options) { + if ($this->validationDisabled) { + return true; + } + foreach ($options as $option) { if ($option['value'] == $optionValue) { return true; @@ -290,7 +298,7 @@ public function containsOption($optionValue, $options) } /** - * Returns list of available field options + * Returns list of available field options. * * @return array */ @@ -304,4 +312,16 @@ public function availableOptionValues() return $values; } + + /** + * Disables the internal validation of the field. + * + * @return self + */ + public function disableValidation() + { + $this->validationDisabled = true; + + return $this; + } } diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php index 4f82220..c3423b2 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php @@ -23,7 +23,7 @@ class FileFormField extends FormField /** * Sets the PHP error code associated with the field. * - * @param integer $error The error code (one of UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, or UPLOAD_ERR_EXTENSION) + * @param int $error The error code (one of UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, or UPLOAD_ERR_EXTENSION) * * @throws \InvalidArgumentException When error code doesn't exist */ @@ -83,7 +83,7 @@ public function setValue($value) } /** - * Sets path to the file as string for simulating HTTP request + * Sets path to the file as string for simulating HTTP request. * * @param string $path The path to the file */ @@ -99,11 +99,11 @@ public function setFilePath($path) */ protected function initialize() { - if ('input' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName) { throw new \LogicException(sprintf('A FileFormField can only be created from an input tag (%s given).', $this->node->nodeName)); } - if ('file' != $this->node->getAttribute('type')) { + if ('file' !== strtolower($this->node->getAttribute('type'))) { throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $this->node->getAttribute('type'))); } diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php index 6412272..5d70292 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php @@ -19,7 +19,7 @@ abstract class FormField { /** - * @var \DOMNode + * @var \DOMElement */ protected $node; /** @@ -39,26 +39,20 @@ abstract class FormField */ protected $xpath; /** - * @var Boolean + * @var bool */ protected $disabled; /** * Constructor. * - * @param \DOMNode $node The node associated with this field + * @param \DOMElement $node The node associated with this field */ - public function __construct(\DOMNode $node) + public function __construct(\DOMElement $node) { $this->node = $node; $this->name = $node->getAttribute('name'); - - $this->document = new \DOMDocument('1.0', 'UTF-8'); - $this->node = $this->document->importNode($this->node, true); - - $root = $this->document->appendChild($this->document->createElement('_root')); - $root->appendChild($this->node); - $this->xpath = new \DOMXPath($this->document); + $this->xpath = new \DOMXPath($node->ownerDocument); $this->initialize(); } @@ -98,7 +92,7 @@ public function setValue($value) /** * Returns true if the field should be included in the submitted values. * - * @return Boolean true if the field should be included in the submitted values, false otherwise + * @return bool true if the field should be included in the submitted values, false otherwise */ public function hasValue() { @@ -106,9 +100,9 @@ public function hasValue() } /** - * Check if the current field is disabled + * Check if the current field is disabled. * - * @return Boolean + * @return bool */ public function isDisabled() { diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/InputFormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/InputFormField.php index d3d3957..b9bd0a4 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/InputFormField.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/InputFormField.php @@ -30,15 +30,15 @@ class InputFormField extends FormField */ protected function initialize() { - if ('input' != $this->node->nodeName && 'button' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName && 'button' !== $this->node->nodeName) { throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName)); } - if ('checkbox' == $this->node->getAttribute('type')) { + if ('checkbox' === strtolower($this->node->getAttribute('type'))) { throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); } - if ('file' == $this->node->getAttribute('type')) { + if ('file' === strtolower($this->node->getAttribute('type'))) { throw new \LogicException('File inputs should be instances of FileFormField.'); } diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/TextareaFormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/TextareaFormField.php index 794e966..a14e707 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/TextareaFormField.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/TextareaFormField.php @@ -27,13 +27,13 @@ class TextareaFormField extends FormField */ protected function initialize() { - if ('textarea' != $this->node->nodeName) { + if ('textarea' !== $this->node->nodeName) { throw new \LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName)); } - $this->value = null; + $this->value = ''; foreach ($this->node->childNodes as $node) { - $this->value .= $this->document->saveXML($node); + $this->value .= $node->wholeText; } } } diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php index 6eaf246..acf62e6 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DomCrawler; +use Symfony\Component\DomCrawler\Field\ChoiceFormField; use Symfony\Component\DomCrawler\Field\FormField; /** @@ -23,27 +24,27 @@ class Form extends Link implements \ArrayAccess { /** - * @var \DOMNode + * @var \DOMElement */ private $button; /** - * @var Field\FormField[] + * @var FormFieldRegistry */ private $fields; /** * Constructor. * - * @param \DOMNode $node A \DOMNode instance - * @param string $currentUri The URI of the page where the form is embedded - * @param string $method The method to use for the link (if null, it defaults to the method defined by the form) + * @param \DOMElement $node A \DOMElement instance + * @param string $currentUri The URI of the page where the form is embedded + * @param string $method The method to use for the link (if null, it defaults to the method defined by the form) * * @throws \LogicException if the node is not a button inside a form tag * * @api */ - public function __construct(\DOMNode $node, $currentUri, $method = null) + public function __construct(\DOMElement $node, $currentUri, $method = null) { parent::__construct($node, $currentUri, $method); @@ -53,7 +54,7 @@ public function __construct(\DOMNode $node, $currentUri, $method = null) /** * Gets the form node associated with this form. * - * @return \DOMNode A \DOMNode instance + * @return \DOMElement A \DOMElement instance */ public function getFormNode() { @@ -143,8 +144,15 @@ public function getFiles() */ public function getPhpValues() { - $qs = http_build_query($this->getValues(), '', '&'); - parse_str($qs, $values); + $values = array(); + foreach ($this->getValues() as $name => $value) { + $qs = http_build_query(array($name => $value), '', '&'); + if (!empty($qs)) { + parse_str($qs, $expandedValue); + $varName = substr($name, 0, strlen(key($expandedValue))); + $values = array_replace_recursive($values, array($varName => current($expandedValue))); + } + } return $values; } @@ -161,8 +169,15 @@ public function getPhpValues() */ public function getPhpFiles() { - $qs = http_build_query($this->getFiles(), '', '&'); - parse_str($qs, $values); + $values = array(); + foreach ($this->getFiles() as $name => $value) { + $qs = http_build_query(array($name => $value), '', '&'); + if (!empty($qs)) { + parse_str($qs, $expandedValue); + $varName = substr($name, 0, strlen(key($expandedValue))); + $values = array_replace_recursive($values, array($varName => current($expandedValue))); + } + } return $values; } @@ -182,9 +197,18 @@ public function getUri() { $uri = parent::getUri(); - if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH')) && $queryString = http_build_query($this->getValues(), null, '&')) { - $sep = false === strpos($uri, '?') ? '?' : '&'; - $uri .= $sep.$queryString; + if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) { + $query = parse_url($uri, PHP_URL_QUERY); + $currentParameters = array(); + if ($query) { + parse_str($query, $currentParameters); + } + + $queryString = http_build_query(array_merge($currentParameters, $this->getValues()), null, '&'); + + $pos = strpos($uri, '?'); + $base = false === $pos ? $uri : substr($uri, 0, $pos); + $uri = rtrim($base.'?'.$queryString, '?'); } return $uri; @@ -218,7 +242,7 @@ public function getMethod() * * @param string $name The field name * - * @return Boolean true if the field exists, false otherwise + * @return bool true if the field exists, false otherwise * * @api */ @@ -286,7 +310,7 @@ public function all() * * @param string $name The field name * - * @return Boolean true if the field exists, false otherwise + * @return bool true if the field exists, false otherwise */ public function offsetExists($name) { @@ -331,65 +355,134 @@ public function offsetUnset($name) } /** - * Sets current \DOMNode instance. + * Disables validation + * + * @return self + */ + public function disableValidation() + { + foreach ($this->fields->all() as $field) { + if ($field instanceof Field\ChoiceFormField) { + $field->disableValidation(); + } + } + + return $this; + } + + /** + * Sets the node for the form. + * + * Expects a 'submit' button \DOMElement and finds the corresponding form element, or the form element itself. * - * @param \DOMNode $node A \DOMNode instance + * @param \DOMElement $node A \DOMElement instance * * @throws \LogicException If given node is not a button or input or does not have a form ancestor */ - protected function setNode(\DOMNode $node) + protected function setNode(\DOMElement $node) { $this->button = $node; - if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array($node->getAttribute('type'), array('submit', 'button', 'image')))) { + if ('button' === $node->nodeName || ('input' === $node->nodeName && in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) { + if ($node->hasAttribute('form')) { + // if the node has the HTML5-compliant 'form' attribute, use it + $formId = $node->getAttribute('form'); + $form = $node->ownerDocument->getElementById($formId); + if (null === $form) { + throw new \LogicException(sprintf('The selected node has an invalid form attribute (%s).', $formId)); + } + $this->node = $form; + + return; + } + // we loop until we find a form ancestor do { - // use the ancestor form element if (null === $node = $node->parentNode) { throw new \LogicException('The selected node does not have a form ancestor.'); } - } while ('form' != $node->nodeName); - } elseif ('form' != $node->nodeName) { + } while ('form' !== $node->nodeName); + } elseif ('form' !== $node->nodeName) { throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName)); } $this->node = $node; } + /** + * Adds form elements related to this form. + * + * Creates an internal copy of the submitted 'button' element and + * the form node or the entire document depending on whether we need + * to find non-descendant elements through HTML5 'form' attribute. + */ private function initialize() { $this->fields = new FormFieldRegistry(); - $document = new \DOMDocument('1.0', 'UTF-8'); - $node = $document->importNode($this->node, true); - $button = $document->importNode($this->button, true); - $root = $document->appendChild($document->createElement('_root')); - $root->appendChild($node); - $root->appendChild($button); - $xpath = new \DOMXPath($document); + $xpath = new \DOMXPath($this->node->ownerDocument); - foreach ($xpath->query('descendant::input | descendant::button | descendant::textarea | descendant::select', $root) as $node) { - if (!$node->hasAttribute('name') || !$node->getAttribute('name')) { - continue; + // add submitted button if it has a valid name + if ('form' !== $this->button->nodeName && $this->button->hasAttribute('name') && $this->button->getAttribute('name')) { + if ('input' == $this->button->nodeName && 'image' == strtolower($this->button->getAttribute('type'))) { + $name = $this->button->getAttribute('name'); + $this->button->setAttribute('value', '0'); + + // temporarily change the name of the input node for the x coordinate + $this->button->setAttribute('name', $name.'.x'); + $this->set(new Field\InputFormField($this->button)); + + // temporarily change the name of the input node for the y coordinate + $this->button->setAttribute('name', $name.'.y'); + $this->set(new Field\InputFormField($this->button)); + + // restore the original name of the input node + $this->button->setAttribute('name', $name); + } else { + $this->set(new Field\InputFormField($this->button)); } + } + + // find form elements corresponding to the current form + if ($this->node->hasAttribute('id')) { + // corresponding elements are either descendants or have a matching HTML5 form attribute + $formId = Crawler::xpathLiteral($this->node->getAttribute('id')); + + $fieldNodes = $xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%s] | descendant::textarea[@form=%s] | descendant::select[@form=%s] | //form[@id=%s]//input[not(@form)] | //form[@id=%s]//button[not(@form)] | //form[@id=%s]//textarea[not(@form)] | //form[@id=%s]//select[not(@form)]', $formId, $formId, $formId, $formId, $formId, $formId, $formId, $formId)); + foreach ($fieldNodes as $node) { + $this->addField($node); + } + } else { + // do the xpath query with $this->node as the context node, to only find descendant elements + // however, descendant elements with form attribute are not part of this form + $fieldNodes = $xpath->query('descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)]', $this->node); + foreach ($fieldNodes as $node) { + $this->addField($node); + } + } + } - $nodeName = $node->nodeName; + private function addField(\DOMElement $node) + { + if (!$node->hasAttribute('name') || !$node->getAttribute('name')) { + return; + } - if ($node === $button) { - $this->set(new Field\InputFormField($node)); - } elseif ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == $node->getAttribute('type')) { + $nodeName = $node->nodeName; + if ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == strtolower($node->getAttribute('type'))) { + $this->set(new Field\ChoiceFormField($node)); + } elseif ('input' == $nodeName && 'radio' == strtolower($node->getAttribute('type'))) { + // there may be other fields with the same name that are no choice + // fields already registered (see https://github.com/symfony/symfony/issues/11689) + if ($this->has($node->getAttribute('name')) && $this->get($node->getAttribute('name')) instanceof ChoiceFormField) { + $this->get($node->getAttribute('name'))->addChoice($node); + } else { $this->set(new Field\ChoiceFormField($node)); - } elseif ('input' == $nodeName && 'radio' == $node->getAttribute('type')) { - if ($this->has($node->getAttribute('name'))) { - $this->get($node->getAttribute('name'))->addChoice($node); - } else { - $this->set(new Field\ChoiceFormField($node)); - } - } elseif ('input' == $nodeName && 'file' == $node->getAttribute('type')) { - $this->set(new Field\FileFormField($node)); - } elseif ('input' == $nodeName && !in_array($node->getAttribute('type'), array('submit', 'button', 'image'))) { - $this->set(new Field\InputFormField($node)); - } elseif ('textarea' == $nodeName) { - $this->set(new Field\TextareaFormField($node)); } + } elseif ('input' == $nodeName && 'file' == strtolower($node->getAttribute('type'))) { + $this->set(new Field\FileFormField($node)); + } elseif ('input' == $nodeName && !in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image'))) { + $this->set(new Field\InputFormField($node)); + } elseif ('textarea' == $nodeName) { + $this->set(new Field\TextareaFormField($node)); } } } diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/FormFieldRegistry.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/FormFieldRegistry.php index 5144ac7..6a38e86 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -33,16 +33,16 @@ public function add(FormField $field) { $segments = $this->getSegments($field->getName()); - $target =& $this->fields; + $target = &$this->fields; while ($segments) { if (!is_array($target)) { $target = array(); } $path = array_shift($segments); if ('' === $path) { - $target =& $target[]; + $target = &$target[]; } else { - $target =& $target[$path]; + $target = &$target[$path]; } } $target = $field; @@ -58,13 +58,13 @@ public function add(FormField $field) public function remove($name) { $segments = $this->getSegments($name); - $target =& $this->fields; + $target = &$this->fields; while (count($segments) > 1) { $path = array_shift($segments); if (!array_key_exists($path, $target)) { return; } - $target =& $target[$path]; + $target = &$target[$path]; } unset($target[array_shift($segments)]); } @@ -82,13 +82,13 @@ public function remove($name) public function &get($name) { $segments = $this->getSegments($name); - $target =& $this->fields; + $target = &$this->fields; while ($segments) { $path = array_shift($segments); if (!array_key_exists($path, $target)) { throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path)); } - $target =& $target[$path]; + $target = &$target[$path]; } return $target; @@ -99,7 +99,7 @@ public function &get($name) * * @param string $name The fully qualified name of the field * - * @return Boolean Whether the form has the given field + * @return bool Whether the form has the given field */ public function has($name) { @@ -123,7 +123,7 @@ public function has($name) */ public function set($name, $value) { - $target =& $this->get($name); + $target = &$this->get($name); if (!is_array($value) || $target instanceof Field\ChoiceFormField) { $target->setValue($value); } else { @@ -137,7 +137,7 @@ public function set($name, $value) /** * Returns the list of field with their value. * - * @return array The list of fields as array((string) Fully qualified name => (mixed) value) + * @return FormField[] The list of fields as array((string) Fully qualified name => (mixed) value) */ public function all() { @@ -176,7 +176,7 @@ private static function create($base, array $values) private function walk(array $array, $base = '', array &$output = array()) { foreach ($array as $k => $v) { - $path = empty($base) ? $k : sprintf("%s[%s]", $base, $k); + $path = empty($base) ? $k : sprintf('%s[%s]', $base, $k); if (is_array($v)) { $this->walk($v, $path, $output); } else { @@ -196,7 +196,7 @@ private function walk(array $array, $base = '', array &$output = array()) * * @param string $name The name of the field * - * @return array The list of segments + * @return string[] The list of segments * * @throws \InvalidArgumentException when the name is malformed */ @@ -204,8 +204,12 @@ private function getSegments($name) { if (preg_match('/^(?P[^[]+)(?P(\[.*)|$)/', $name, $m)) { $segments = array($m['base']); - while (preg_match('/^\[(?P.*?)\](?P.*)$/', $m['extra'], $m)) { - $segments[] = $m['segment']; + while (!empty($m['extra'])) { + if (preg_match('/^\[(?P.*?)\](?P.*)$/', $m['extra'], $m)) { + $segments[] = $m['segment']; + } else { + throw new \InvalidArgumentException(sprintf('Malformed field path "%s"', $name)); + } } return $segments; diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE index 88a57f8..43028bc 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2013 Fabien Potencier +Copyright (c) 2004-2015 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php index 3a65148..8db686a 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php @@ -12,7 +12,7 @@ namespace Symfony\Component\DomCrawler; /** - * Link represents an HTML link (an HTML a tag). + * Link represents an HTML link (an HTML a, area or link tag). * * @author Fabien Potencier * @@ -21,13 +21,15 @@ class Link { /** - * @var \DOMNode A \DOMNode instance + * @var \DOMElement */ protected $node; + /** * @var string The method to use for the link */ protected $method; + /** * @var string The URI of the page where the link is embedded (or the base href) */ @@ -36,15 +38,15 @@ class Link /** * Constructor. * - * @param \DOMNode $node A \DOMNode instance - * @param string $currentUri The URI of the page where the link is embedded (or the base href) - * @param string $method The method to use for the link (get by default) + * @param \DOMElement $node A \DOMElement instance + * @param string $currentUri The URI of the page where the link is embedded (or the base href) + * @param string $method The method to use for the link (get by default) * * @throws \InvalidArgumentException if the node is not a link * * @api */ - public function __construct(\DOMNode $node, $currentUri, $method = 'GET') + public function __construct(\DOMElement $node, $currentUri, $method = 'GET') { if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) { throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri)); @@ -58,7 +60,7 @@ public function __construct(\DOMNode $node, $currentUri, $method = 'GET') /** * Gets the node associated with this link. * - * @return \DOMNode A \DOMNode instance + * @return \DOMElement A \DOMElement instance */ public function getNode() { @@ -98,29 +100,23 @@ public function getUri() return $this->currentUri; } - // only an anchor + // an anchor if ('#' === $uri[0]) { - $baseUri = $this->currentUri; - if (false !== $pos = strpos($baseUri, '#')) { - $baseUri = substr($baseUri, 0, $pos); - } - - return $baseUri.$uri; + return $this->cleanupAnchor($this->currentUri).$uri; } - // only a query string - if ('?' === $uri[0]) { - $baseUri = $this->currentUri; - - // remove the query string from the current uri - if (false !== $pos = strpos($baseUri, '?')) { - $baseUri = substr($baseUri, 0, $pos); - } + $baseUri = $this->cleanupUri($this->currentUri); + if ('?' === $uri[0]) { return $baseUri.$uri; } - $baseUri = preg_replace('#^(.*?//[^/]+)(?:\/.*)?$#', '$1', $this->currentUri); + // absolute URL with relative schema + if (0 === strpos($uri, '//')) { + return preg_replace('#^([^/]*)//.*$#', '$1', $baseUri).$uri; + } + + $baseUri = preg_replace('#^(.*?//[^/]*)(?:\/.*)?$#', '$1', $baseUri); // absolute path if ('/' === $uri[0]) { @@ -135,7 +131,7 @@ public function getUri() } /** - * Returns raw uri data. + * Returns raw URI data. * * @return string */ @@ -145,7 +141,7 @@ protected function getRawUri() } /** - * Returns the canonicalized URI path (see RFC 3986, section 5.2.4) + * Returns the canonicalized URI path (see RFC 3986, section 5.2.4). * * @param string $path URI path * @@ -158,7 +154,7 @@ protected function canonicalizePath($path) } if ('.' === substr($path, -1)) { - $path = $path.'/'; + $path .= '/'; } $output = array(); @@ -175,18 +171,62 @@ protected function canonicalizePath($path) } /** - * Sets current \DOMNode instance. + * Sets current \DOMElement instance. * - * @param \DOMNode $node A \DOMNode instance + * @param \DOMElement $node A \DOMElement instance * * @throws \LogicException If given node is not an anchor */ - protected function setNode(\DOMNode $node) + protected function setNode(\DOMElement $node) { - if ('a' != $node->nodeName) { - throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName)); + if ('a' !== $node->nodeName && 'area' !== $node->nodeName && 'link' !== $node->nodeName) { + throw new \LogicException(sprintf('Unable to navigate from a "%s" tag.', $node->nodeName)); } $this->node = $node; } + + /** + * Removes the query string and the anchor from the given uri. + * + * @param string $uri The uri to clean + * + * @return string + */ + private function cleanupUri($uri) + { + return $this->cleanupQuery($this->cleanupAnchor($uri)); + } + + /** + * Remove the query string from the uri. + * + * @param string $uri + * + * @return string + */ + private function cleanupQuery($uri) + { + if (false !== $pos = strpos($uri, '?')) { + return substr($uri, 0, $pos); + } + + return $uri; + } + + /** + * Remove the anchor from the uri. + * + * @param string $uri + * + * @return string + */ + private function cleanupAnchor($uri) + { + if (false !== $pos = strpos($uri, '#')) { + return substr($uri, 0, $pos); + } + + return $uri; + } } diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/README.md b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/README.md index 721c0d9..d2c8de5 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/README.md +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/README.md @@ -5,22 +5,26 @@ DomCrawler eases DOM navigation for HTML and XML documents. If you are familiar with jQuery, DomCrawler is a PHP equivalent: - use Symfony\Component\DomCrawler\Crawler; +```php +use Symfony\Component\DomCrawler\Crawler; - $crawler = new Crawler(); - $crawler->addContent('

Hello World!

'); +$crawler = new Crawler(); +$crawler->addContent('

Hello World!

'); - print $crawler->filterXPath('descendant-or-self::body/p')->text(); +print $crawler->filterXPath('descendant-or-self::body/p')->text(); +``` If you are also using the CssSelector component, you can use CSS Selectors instead of XPath expressions: - use Symfony\Component\DomCrawler\Crawler; +```php +use Symfony\Component\DomCrawler\Crawler; - $crawler = new Crawler(); - $crawler->addContent('

Hello World!

'); +$crawler = new Crawler(); +$crawler->addContent('

Hello World!

'); - print $crawler->filter('body > p')->text(); +print $crawler->filter('body > p')->text(); +``` Resources --------- @@ -28,5 +32,5 @@ Resources You can run the unit tests with the following command: $ cd path/to/Symfony/Component/DomCrawler/ - $ composer.phar install --dev + $ composer install $ phpunit diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 8aac5d0..1431908 100644 --- a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DomCrawler\Tests; +use Symfony\Component\CssSelector\CssSelector; use Symfony\Component\DomCrawler\Crawler; class CrawlerTest extends \PHPUnit_Framework_TestCase @@ -46,13 +47,22 @@ public function testAdd() $crawler = new Crawler(); $crawler->add($this->createNodeList()->item(0)); - $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from an \DOMNode'); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from a \DOMElement'); $crawler = new Crawler(); $crawler->add('Foo'); $this->assertEquals('Foo', $crawler->filterXPath('//body')->text(), '->add() adds nodes from a string'); } + /** + * @expectedException \InvalidArgumentException + */ + public function testAddInvalidNode() + { + $crawler = new Crawler(); + $crawler->add(1); + } + /** * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent */ @@ -103,12 +113,24 @@ public function testAddHtmlContentUnsupportedCharset() $this->assertEquals('Žťčýů', $crawler->filterXPath('//p')->text()); } + /** + * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent + */ + public function testAddHtmlContentCharsetGbk() + { + $crawler = new Crawler(); + //gbk encode of

中文

+ $crawler->addHtmlContent(base64_decode('PGh0bWw+PHA+1tDOxDwvcD48L2h0bWw+'), 'gbk'); + + $this->assertEquals('中文', $crawler->filterXPath('//p')->text()); + } + /** * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent */ public function testAddHtmlContentWithErrors() { - libxml_use_internal_errors(true); + $internalErrors = libxml_use_internal_errors(true); $crawler = new Crawler(); $crawler->addHtmlContent(<<assertEquals("Tag nav invalid\n", $errors[0]->message); libxml_clear_errors(); - libxml_use_internal_errors(false); + libxml_use_internal_errors($internalErrors); } /** @@ -158,7 +180,7 @@ public function testAddXmlContentCharset() */ public function testAddXmlContentWithErrors() { - libxml_use_internal_errors(true); + $internalErrors = libxml_use_internal_errors(true); $crawler = new Crawler(); $crawler->addXmlContent(<<assertTrue(count(libxml_get_errors()) > 1); libxml_clear_errors(); - libxml_use_internal_errors(false); + libxml_use_internal_errors($internalErrors); } /** @@ -207,6 +229,14 @@ public function testAddContent() $crawler = new Crawler(); $crawler->addContent('foo bar', 'text/plain'); $this->assertCount(0, $crawler, '->addContent() does nothing if the type is not (x|ht)ml'); + + $crawler = new Crawler(); + $crawler->addContent('中文'); + $this->assertEquals('中文', $crawler->filterXPath('//span')->text(), '->addContent() guess wrong charset'); + + $crawler = new Crawler(); + $crawler->addContent(mb_convert_encoding('日本語', 'SJIS', 'UTF-8')); + $this->assertEquals('日本語', $crawler->filterXPath('//body')->text(), '->addContent() can recognize "Shift_JIS" in html5 meta charset tag'); } /** @@ -254,7 +284,7 @@ public function testAddNode() $crawler = new Crawler(); $crawler->addNode($this->createNodeList()->item(0)); - $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addNode() adds nodes from an \DOMNode'); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addNode() adds nodes from a \DOMElement'); } public function testClear() @@ -277,17 +307,27 @@ public function testEq() public function testEach() { $data = $this->createTestCrawler()->filterXPath('//ul[1]/li')->each(function ($node, $i) { - return $i.'-'.$node->nodeValue; + return $i.'-'.$node->text(); }); $this->assertEquals(array('0-One', '1-Two', '2-Three'), $data, '->each() executes an anonymous function on each node of the list'); } + public function testSlice() + { + $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); + $this->assertNotSame($crawler->slice(), $crawler, '->slice() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler->slice(), '->slice() returns a new instance of a crawler'); + + $this->assertCount(3, $crawler->slice(), '->slice() does not slice the nodes in the list if any param is entered'); + $this->assertCount(1, $crawler->slice(1, 1), '->slice() slices the nodes in the list'); + } + public function testReduce() { $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); $nodes = $crawler->reduce(function ($node, $i) { - return $i == 1 ? false : true; + return $i !== 1; }); $this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler'); $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $nodes, '->reduce() returns a new instance of a crawler'); @@ -307,6 +347,29 @@ public function testAttr() } } + public function testMissingAttrValueIsNull() + { + $crawler = new Crawler(); + $crawler->addContent('
', 'text/html; charset=UTF-8'); + $div = $crawler->filterXPath('//div'); + + $this->assertEquals('sample value', $div->attr('non-empty-attr'), '->attr() reads non-empty attributes correctly'); + $this->assertEquals('', $div->attr('empty-attr'), '->attr() reads empty attributes correctly'); + $this->assertNull($div->attr('missing-attr'), '->attr() reads missing attributes correctly'); + } + + public function testNodeName() + { + $this->assertEquals('li', $this->createTestCrawler()->filterXPath('//li')->nodeName(), '->nodeName() returns the node name of the first element of the node list'); + + try { + $this->createTestCrawler()->filterXPath('//ol')->nodeName(); + $this->fail('->nodeName() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->nodeName() throws an \InvalidArgumentException if the node list is empty'); + } + } + public function testText() { $this->assertEquals('One', $this->createTestCrawler()->filterXPath('//li')->text(), '->text() returns the node value of the first element of the node list'); @@ -319,6 +382,19 @@ public function testText() } } + public function testHtml() + { + $this->assertEquals('Bar', $this->createTestCrawler()->filterXPath('//a[5]')->html()); + $this->assertEquals('', trim($this->createTestCrawler()->filterXPath('//form[@id="FooFormId"]')->html())); + + try { + $this->createTestCrawler()->filterXPath('//ol')->html(); + $this->fail('->html() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->html() throws an \InvalidArgumentException if the node list is empty'); + } + } + public function testExtract() { $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); @@ -329,6 +405,29 @@ public function testExtract() $this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->extract('_text'), '->extract() returns an empty array if the node list is empty'); } + public function testFilterXpathComplexQueries() + { + $crawler = $this->createTestCrawler()->filterXPath('//body'); + + $this->assertCount(0, $crawler->filterXPath('/input')); + $this->assertCount(0, $crawler->filterXPath('/body')); + $this->assertCount(1, $crawler->filterXPath('/_root/body')); + $this->assertCount(1, $crawler->filterXPath('./body')); + $this->assertCount(1, $crawler->filterXPath('.//body')); + $this->assertCount(5, $crawler->filterXPath('.//input')); + $this->assertCount(4, $crawler->filterXPath('//form')->filterXPath('//button | //input')); + $this->assertCount(1, $crawler->filterXPath('body')); + $this->assertCount(6, $crawler->filterXPath('//button | //input')); + $this->assertCount(1, $crawler->filterXPath('//body')); + $this->assertCount(1, $crawler->filterXPath('descendant-or-self::body')); + $this->assertCount(1, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('./div'), 'A child selection finds only the current div'); + $this->assertCount(3, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('descendant::div'), 'A descendant selector matches the current div and its child'); + $this->assertCount(3, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('//div'), 'A descendant selector matches the current div and its child'); + $this->assertCount(5, $crawler->filterXPath('(//a | //div)//img')); + $this->assertCount(7, $crawler->filterXPath('((//a | //div)//img | //ul)')); + $this->assertCount(7, $crawler->filterXPath('( ( //a | //div )//img | //ul )')); + } + /** * @covers Symfony\Component\DomCrawler\Crawler::filterXPath */ @@ -339,8 +438,159 @@ public function testFilterXPath() $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filterXPath() returns a new instance of a crawler'); $crawler = $this->createTestCrawler()->filterXPath('//ul'); - $this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression'); + + $crawler = $this->createTestCrawler(); + $this->assertCount(3, $crawler->filterXPath('//body')->filterXPath('//button')->parents(), '->filterXpath() preserves parents when chained'); + } + + public function testFilterXPathWithDefaultNamespace() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//default:entry/default:id'); + $this->assertCount(1, $crawler, '->filterXPath() automatically registers a namespace'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); + } + + public function testFilterXPathWithCustomDefaultNamespace() + { + $crawler = $this->createTestXmlCrawler(); + $crawler->setDefaultNamespacePrefix('x'); + $crawler = $crawler->filterXPath('//x:entry/x:id'); + + $this->assertCount(1, $crawler, '->filterXPath() lets to override the default namespace prefix'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); + } + + public function testFilterXPathWithNamespace() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//yt:accessControl'); + $this->assertCount(2, $crawler, '->filterXPath() automatically registers a namespace'); + } + + public function testFilterXPathWithMultipleNamespaces() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//media:group/yt:aspectRatio'); + $this->assertCount(1, $crawler, '->filterXPath() automatically registers multiple namespaces'); + $this->assertSame('widescreen', $crawler->text()); + } + + public function testFilterXPathWithManuallyRegisteredNamespace() + { + $crawler = $this->createTestXmlCrawler(); + $crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/'); + + $crawler = $crawler->filterXPath('//m:group/yt:aspectRatio'); + $this->assertCount(1, $crawler, '->filterXPath() uses manually registered namespace'); + $this->assertSame('widescreen', $crawler->text()); + } + + public function testFilterXPathWithAnUrl() + { + $crawler = $this->createTestXmlCrawler(); + + $crawler = $crawler->filterXPath('//media:category[@scheme="http://gdata.youtube.com/schemas/2007/categories.cat"]'); + $this->assertCount(1, $crawler); + $this->assertSame('Music', $crawler->text()); + } + + public function testFilterXPathWithFakeRoot() + { + $crawler = $this->createTestCrawler(); + $this->assertCount(0, $crawler->filterXPath('.'), '->filterXPath() returns an empty result if the XPath references the fake root node'); + $this->assertCount(0, $crawler->filterXPath('/_root'), '->filterXPath() returns an empty result if the XPath references the fake root node'); + $this->assertCount(0, $crawler->filterXPath('self::*'), '->filterXPath() returns an empty result if the XPath references the fake root node'); + $this->assertCount(0, $crawler->filterXPath('self::_root'), '->filterXPath() returns an empty result if the XPath references the fake root node'); + } + + public function testFilterXPathWithAncestorAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//form'); + + $this->assertCount(0, $crawler->filterXPath('ancestor::*'), 'The fake root node has no ancestor nodes'); + } + + public function testFilterXPathWithAncestorOrSelfAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//form'); + + $this->assertCount(0, $crawler->filterXPath('ancestor-or-self::*'), 'The fake root node has no ancestor nodes'); + } + + public function testFilterXPathWithAttributeAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//form'); + + $this->assertCount(0, $crawler->filterXPath('attribute::*'), 'The fake root node has no attribute nodes'); + } + + public function testFilterXPathWithAttributeAxisAfterElementAxis() + { + $this->assertCount(3, $this->createTestCrawler()->filterXPath('//form/button/attribute::*'), '->filterXPath() handles attribute axes properly when they are preceded by an element filtering axis'); + } + + public function testFilterXPathWithChildAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//div[@id="parent"]'); + + $this->assertCount(1, $crawler->filterXPath('child::div'), 'A child selection finds only the current div'); + } + + public function testFilterXPathWithFollowingAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//a'); + + $this->assertCount(0, $crawler->filterXPath('following::div'), 'The fake root node has no following nodes'); + } + + public function testFilterXPathWithFollowingSiblingAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//a'); + + $this->assertCount(0, $crawler->filterXPath('following-sibling::div'), 'The fake root node has no following nodes'); + } + + public function testFilterXPathWithNamespaceAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//button'); + + $this->assertCount(0, $crawler->filterXPath('namespace::*'), 'The fake root node has no namespace nodes'); + } + + public function testFilterXPathWithNamespaceAxisAfterElementAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//div[@id="parent"]/namespace::*'); + + $this->assertCount(0, $crawler->filterXPath('namespace::*'), 'Namespace axes cannot be requested'); + } + + public function testFilterXPathWithParentAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//button'); + + $this->assertCount(0, $crawler->filterXPath('parent::*'), 'The fake root node has no parent nodes'); + } + + public function testFilterXPathWithPrecedingAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//form'); + + $this->assertCount(0, $crawler->filterXPath('preceding::*'), 'The fake root node has no preceding nodes'); + } + + public function testFilterXPathWithPrecedingSiblingAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//form'); + + $this->assertCount(0, $crawler->filterXPath('preceding-sibling::*'), 'The fake root node has no preceding nodes'); + } + + public function testFilterXPathWithSelfAxes() + { + $crawler = $this->createTestCrawler()->filterXPath('//a'); + + $this->assertCount(0, $crawler->filterXPath('self::a'), 'The fake root node has no "real" element name'); + $this->assertCount(0, $crawler->filterXPath('self::a/img'), 'The fake root node has no "real" element name'); + $this->assertCount(9, $crawler->filterXPath('self::*/a')); } /** @@ -348,10 +598,6 @@ public function testFilterXPath() */ public function testFilter() { - if (!class_exists('Symfony\Component\CssSelector\CssSelector')) { - $this->markTestSkipped('The "CssSelector" component is not available'); - } - $crawler = $this->createTestCrawler(); $this->assertNotSame($crawler, $crawler->filter('li'), '->filter() returns a new instance of a crawler'); $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filter() returns a new instance of a crawler'); @@ -361,6 +607,52 @@ public function testFilter() $this->assertCount(6, $crawler->filter('li'), '->filter() filters the node list with the CSS selector'); } + public function testFilterWithDefaultNamespace() + { + $crawler = $this->createTestXmlCrawler()->filter('default|entry default|id'); + $this->assertCount(1, $crawler, '->filter() automatically registers namespaces'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); + } + + public function testFilterWithNamespace() + { + CssSelector::disableHtmlExtension(); + + $crawler = $this->createTestXmlCrawler()->filter('yt|accessControl'); + $this->assertCount(2, $crawler, '->filter() automatically registers namespaces'); + } + + public function testFilterWithMultipleNamespaces() + { + CssSelector::disableHtmlExtension(); + + $crawler = $this->createTestXmlCrawler()->filter('media|group yt|aspectRatio'); + $this->assertCount(1, $crawler, '->filter() automatically registers namespaces'); + $this->assertSame('widescreen', $crawler->text()); + } + + public function testFilterWithDefaultNamespaceOnly() + { + $crawler = new Crawler(' + + + http://localhost/foo + weekly + 0.5 + 2012-11-16 + + + http://localhost/bar + weekly + 0.5 + 2012-11-16 + + + '); + + $this->assertEquals(2, $crawler->filter('url')->count()); + } + public function testSelectLink() { $crawler = $this->createTestCrawler(); @@ -393,6 +685,51 @@ public function testSelectButton() $this->assertEquals(1, $crawler->selectButton('BarValue')->count(), '->selectButton() selects buttons'); $this->assertEquals(1, $crawler->selectButton('BarName')->count(), '->selectButton() selects buttons'); $this->assertEquals(1, $crawler->selectButton('BarId')->count(), '->selectButton() selects buttons'); + + $this->assertEquals(1, $crawler->selectButton('FooBarValue')->count(), '->selectButton() selects buttons with form attribute too'); + $this->assertEquals(1, $crawler->selectButton('FooBarName')->count(), '->selectButton() selects buttons with form attribute too'); + } + + public function testSelectButtonWithSingleQuotesInNameAttribute() + { + $html = << + + +
+ Login +
+
+ +
+ + +HTML; + + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->selectButton('Click \'Here\'')); + } + + public function testSelectButtonWithDoubleQuotesInNameAttribute() + { + $html = << + + +
+ Login +
+
+ +
+ + +HTML; + + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->selectButton('Click "Here"')); } public function testLink() @@ -413,6 +750,44 @@ public function testLink() } } + public function testSelectLinkAndLinkFiltered() + { + $html = << + + +
+ Login +
+
+ +
+ + +HTML; + + $crawler = new Crawler($html); + $filtered = $crawler->filterXPath("descendant-or-self::*[@id = 'login-form']"); + + $this->assertCount(0, $filtered->selectLink('Login')); + $this->assertCount(1, $filtered->selectButton('Submit')); + + $filtered = $crawler->filterXPath("descendant-or-self::*[@id = 'action']"); + + $this->assertCount(1, $filtered->selectLink('Login')); + $this->assertCount(0, $filtered->selectButton('Submit')); + + $this->assertCount(1, $crawler->selectLink('Login')->selectLink('Login')); + $this->assertCount(1, $crawler->selectButton('Submit')->selectButton('Submit')); + } + + public function testChaining() + { + $crawler = new Crawler('
'); + + $this->assertEquals('a', $crawler->filterXPath('//div')->filterXPath('div')->filterXPath('div')->attr('name')); + } + public function testLinks() { $crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo'); @@ -427,10 +802,17 @@ public function testLinks() public function testForm() { - $crawler = $this->createTestCrawler('http://example.com/bar/')->selectButton('FooValue'); + $testCrawler = $this->createTestCrawler('http://example.com/bar/'); + $crawler = $testCrawler->selectButton('FooValue'); + $crawler2 = $testCrawler->selectButton('FooBarValue'); $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Form', $crawler->form(), '->form() returns a Form instance'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Form', $crawler2->form(), '->form() returns a Form instance'); - $this->assertEquals(array('FooName' => 'FooBar'), $crawler->form(array('FooName' => 'FooBar'))->getValues(), '->form() takes an array of values to submit as its first argument'); + $this->assertEquals($crawler->form()->getFormNode()->getAttribute('id'), $crawler2->form()->getFormNode()->getAttribute('id'), '->form() works on elements with form attribute'); + + $this->assertEquals(array('FooName' => 'FooBar', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler->form(array('FooName' => 'FooBar'))->getValues(), '->form() takes an array of values to submit as its first argument'); + $this->assertEquals(array('FooName' => 'FooValue', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler->form()->getValues(), '->getValues() returns correct form values'); + $this->assertEquals(array('FooBarName' => 'FooBarValue', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler2->form()->getValues(), '->getValues() returns correct form values'); try { $this->createTestCrawler()->filterXPath('//ol')->form(); @@ -536,6 +918,14 @@ public function testChildren() } catch (\InvalidArgumentException $e) { $this->assertTrue(true, '->children() throws an \InvalidArgumentException if the node list is empty'); } + + try { + $crawler = new Crawler('

'); + $crawler->filter('p')->children(); + $this->assertTrue(true, '->children() does not trigger a notice if the node has no children'); + } catch (\PHPUnit_Framework_Error_Notice $e) { + $this->fail('->children() does not trigger a notice if the node has no children'); + } } public function testParents() @@ -558,6 +948,44 @@ public function testParents() } } + /** + * @dataProvider getBaseTagData + */ + public function testBaseTag($baseValue, $linkValue, $expectedUri, $currentUri = null, $description = null) + { + $crawler = new Crawler('', $currentUri); + $this->assertEquals($expectedUri, $crawler->filterXPath('//a')->link()->getUri(), $description); + } + + public function getBaseTagData() + { + return array( + array('http://base.com', 'link', 'http://base.com/link'), + array('//base.com', 'link', 'https://base.com/link', 'https://domain.com', ' tag can use a schema-less URL'), + array('path/', 'link', 'https://domain.com/path/link', 'https://domain.com', ' tag can set a path'), + array('http://base.com', '#', 'http://base.com#', 'http://domain.com/path/link', ' tag does work with links to an anchor'), + array('http://base.com', '', 'http://base.com', 'http://domain.com/path/link', ' tag does work with empty links'), + ); + } + + /** + * @dataProvider getBaseTagWithFormData + */ + public function testBaseTagWithForm($baseValue, $actionValue, $expectedUri, $currentUri = null, $description = null) + { + $crawler = new Crawler('
+ + + + '); + $form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com'); + + $this->assertInstanceOf('Symfony\Component\DomCrawler\Field\ChoiceFormField', $form->get('option')); + } + protected function getFormFieldMock($name, $value = null) { $field = $this @@ -678,7 +858,6 @@ protected function createForm($form, $method = null, $currentUri = null) $dom = new \DOMDocument(); $dom->loadHTML(''.$form.''); - $nodes = $dom->getElementsByTagName('input'); $xPath = new \DOMXPath($dom); $nodes = $xPath->query('//input | //button'); @@ -688,4 +867,83 @@ protected function createForm($form, $method = null, $currentUri = null) return new Form($nodes->item($nodes->length - 1), $currentUri, $method); } + + protected function createTestHtml5Form() + { + $dom = new \DOMDocument(); + $dom->loadHTML(' + +

Hello form

+
+
+ +
+ + +
+ +
+
+
+ + + +
+ +
+ +
+
+
+ + +
+
+ + +
+
+
+ + + +
+