From 0024ddce9c4f0c0a25835286ddaf187f8b6ced44 Mon Sep 17 00:00:00 2001 From: Johannes Date: Thu, 5 Apr 2012 12:20:11 +0300 Subject: [PATCH 1/6] Fix for using route name as check_path. --- .../SecurityBundle/DependencyInjection/MainConfiguration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index f5cdcf42ae..1a412c53ff 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -274,7 +274,7 @@ class MainConfiguration implements ConfigurationInterface continue; } - if (!preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) { + if (false !== strpos('/', $firewall[$k]['check_path']) && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) { throw new \LogicException(sprintf('The check_path "%s" for login method "%s" is not matched by the firewall pattern "%s".', $firewall[$k]['check_path'], $k, $firewall['pattern'])); } } From 292364ad708c2955a7fc5aef15b19ecd1fb2dc5f Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Sun, 8 Apr 2012 09:55:44 +0200 Subject: [PATCH 2/6] [DomCrawler] Added some docbocks into DomCrawler classes. Closes #3832 --- src/Symfony/Component/DomCrawler/Crawler.php | 11 +++++--- .../DomCrawler/Field/ChoiceFormField.php | 19 +++++++++----- .../Component/DomCrawler/Field/FormField.php | 23 +++++++++++++++++ src/Symfony/Component/DomCrawler/Form.php | 10 ++++++-- src/Symfony/Component/DomCrawler/Link.php | 25 +++++++++++++++++-- 5 files changed, 75 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 7e42b507be..bbcb07152b 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -22,6 +22,9 @@ use Symfony\Component\CssSelector\CssSelector; */ class Crawler extends \SplObjectStorage { + /** + * @var string The current URI or the base href value + */ private $uri; /** @@ -75,8 +78,10 @@ class Crawler extends \SplObjectStorage /** * Adds HTML/XML content. * - * @param string $content A string to parse as HTML/XML - * @param string $type The content type of the string + * @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) { @@ -208,7 +213,7 @@ class Crawler extends \SplObjectStorage * * @param integer $position The position * - * @return A new instance of the Crawler with the selected node, or an empty Crawler if it does not exist. + * @return Crawler A new instance of the Crawler with the selected node, or an empty Crawler if it does not exist. * * @api */ diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index d3e9c9939d..2e192cb190 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -22,8 +22,17 @@ namespace Symfony\Component\DomCrawler\Field; */ class ChoiceFormField extends FormField { + /** + * @var string + */ private $type; + /** + * @var Boolean + */ private $multiple; + /** + * @var array + */ private $options; /** @@ -44,7 +53,7 @@ class ChoiceFormField extends FormField /** * Check if the current selected option is disabled * - * @return bool + * @return Boolean */ public function isDisabled() { @@ -62,8 +71,6 @@ class ChoiceFormField extends FormField * * @param string $value The value of the field * - * @throws \InvalidArgumentException When value type provided is not correct - * * @api */ public function select($value) @@ -74,7 +81,7 @@ class ChoiceFormField extends FormField /** * Ticks a checkbox. * - * @throws \InvalidArgumentException When value type provided is not correct + * @throws \LogicException When the type provided is not correct * * @api */ @@ -90,7 +97,7 @@ class ChoiceFormField extends FormField /** * Ticks a checkbox. * - * @throws \InvalidArgumentException When value type provided is not correct + * @throws \LogicException When the type provided is not correct * * @api */ @@ -248,7 +255,7 @@ class ChoiceFormField extends FormField /** * Returns option value with associated disabled flag * - * @param type $node + * @param \DOMNode $node * * @return array */ diff --git a/src/Symfony/Component/DomCrawler/Field/FormField.php b/src/Symfony/Component/DomCrawler/Field/FormField.php index b21bb38ea8..6412272c2e 100644 --- a/src/Symfony/Component/DomCrawler/Field/FormField.php +++ b/src/Symfony/Component/DomCrawler/Field/FormField.php @@ -18,11 +18,29 @@ namespace Symfony\Component\DomCrawler\Field; */ abstract class FormField { + /** + * @var \DOMNode + */ protected $node; + /** + * @var string + */ protected $name; + /** + * @var string + */ protected $value; + /** + * @var \DOMDocument + */ protected $document; + /** + * @var \DOMXPath + */ protected $xpath; + /** + * @var Boolean + */ protected $disabled; /** @@ -87,6 +105,11 @@ abstract class FormField return true; } + /** + * Check if the current field is disabled + * + * @return Boolean + */ public function isDisabled() { return $this->node->hasAttribute('disabled'); diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 2eadac8944..8bdaa33ebf 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -22,7 +22,13 @@ use Symfony\Component\DomCrawler\Field\FormField; */ class Form extends Link implements \ArrayAccess { + /** + * @var \DOMNode + */ private $button; + /** + * @var Field\FormField[] + */ private $fields; /** @@ -58,6 +64,8 @@ class Form extends Link implements \ArrayAccess * * @param array $values An array of field values * + * @return Form + * * @api */ public function setValues(array $values) @@ -254,8 +262,6 @@ class Form extends Link implements \ArrayAccess * * @param Field\FormField $field The field * - * @return FormField The field instance - * * @api */ public function set(Field\FormField $field) diff --git a/src/Symfony/Component/DomCrawler/Link.php b/src/Symfony/Component/DomCrawler/Link.php index 39ddb8ca97..1804111f2e 100644 --- a/src/Symfony/Component/DomCrawler/Link.php +++ b/src/Symfony/Component/DomCrawler/Link.php @@ -20,8 +20,17 @@ namespace Symfony\Component\DomCrawler; */ class Link { + /** + * @var \DOMNode A \DOMNode instance + */ 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) + */ protected $currentUri; /** @@ -31,7 +40,7 @@ class Link * @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 \LogicException if the node is not a link + * @throws \InvalidArgumentException if the node is not a link * * @api */ @@ -90,7 +99,7 @@ class Link } // only an anchor - if ('#' === $uri[0]) { + if ('#' === $uri[0]) { $baseUri = $this->currentUri; if (false !== $pos = strpos($baseUri, '#')) { $baseUri = substr($baseUri, 0, $pos); @@ -120,11 +129,23 @@ class Link return substr($this->currentUri, 0, strrpos($this->currentUri, '/') + 1).$uri; } + /** + * Returns raw uri data + * + * @return string + */ protected function getRawUri() { return $this->node->getAttribute('href'); } + /** + * Sets current \DOMNode instance + * + * @param \DOMNode $node A \DOMNode instance + * + * @throws \LogicException If given node is not an anchor + */ protected function setNode(\DOMNode $node) { if ('a' != $node->nodeName) { From f3408ccf2ceab42eda45ebeac2c1141aca5343ce Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 8 Apr 2012 19:39:04 +0200 Subject: [PATCH 3/6] [Finder] Avoid unnecessary use of the @ operator --- src/Symfony/Component/Finder/Comparator/DateComparator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Finder/Comparator/DateComparator.php b/src/Symfony/Component/Finder/Comparator/DateComparator.php index e82b295dc0..f5ad8f39ca 100644 --- a/src/Symfony/Component/Finder/Comparator/DateComparator.php +++ b/src/Symfony/Component/Finder/Comparator/DateComparator.php @@ -32,7 +32,10 @@ class DateComparator extends Comparator throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test)); } - if (false === $target = @strtotime($matches[2])) { + try { + $date = new \DateTime($matches[2]); + $target = $date->format('U'); + } catch (\Exception $e) { throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2])); } From 31dde144fff6b052e09cbcd20eeae8c87a207796 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Date: Sun, 8 Apr 2012 19:21:28 -0300 Subject: [PATCH 4/6] [Locale] updated StubIntlDateFormatter::format() behavior for PHP >= 5.3.4 --- .../Component/Locale/Stub/StubIntlDateFormatter.php | 9 +++++++-- .../Locale/Stub/StubIntlDateFormatterTest.php | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php b/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php index b53d55967a..edc952094f 100644 --- a/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php +++ b/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php @@ -174,13 +174,18 @@ class StubIntlDateFormatter throw new MethodArgumentValueNotImplementedException(__METHOD__, 'timestamp', $timestamp, 'Only integer unix timestamps are supported'); } - if (!is_int($timestamp)) { - // behave like the intl extension + // behave like the intl extension + if (!is_int($timestamp) && version_compare(\PHP_VERSION, '5.3.4', '<')) { StubIntl::setErrorCode(StubIntl::U_ILLEGAL_ARGUMENT_ERROR); return false; } + // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances + if ($timestamp instanceOf \DateTime && version_compare(\PHP_VERSION, '5.3.4', '>=')) { + $timestamp = $timestamp->getTimestamp(); + } + $transformer = new FullTransformer($this->getPattern(), $this->getTimeZoneId()); $formatted = $transformer->format($this->createDateTime($timestamp)); diff --git a/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php b/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php index 572986ed35..8d545c1d20 100644 --- a/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php +++ b/tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php @@ -276,6 +276,19 @@ class StubIntlDateFormatterTest extends LocaleTestCase array('zzzzz', 0, 'GMT+00:00'), ); + // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances + if (version_compare(\PHP_VERSION, '5.3.4', '>=')) { + $dateTime = new \DateTime('@0'); + + /* general, DateTime */ + $formatData[] = array('y-M-d', $dateTime, '1970-1-1'); + $formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT+00:00'); + $formatData[] = array("EEE, MMM d, ''yy", $dateTime, "Thu, Jan 1, '70"); + $formatData[] = array('h:mm a', $dateTime, '12:00 AM'); + $formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT+00:00'); + $formatData[] = array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'); + } + return $formatData; } From 353085857ba6d17694e5322e2eefb0d8fec6380d Mon Sep 17 00:00:00 2001 From: Brikou CARRE Date: Tue, 10 Apr 2012 11:04:07 +0200 Subject: [PATCH 5/6] fixed typehints in docblocks (IDE completion works now) --- src/Symfony/Bundle/DoctrineBundle/Registry.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/DoctrineBundle/Registry.php b/src/Symfony/Bundle/DoctrineBundle/Registry.php index a14545973c..eb6cce353d 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Registry.php +++ b/src/Symfony/Bundle/DoctrineBundle/Registry.php @@ -109,7 +109,7 @@ class Registry implements RegistryInterface * * @param string $name The entity manager name (null for the default one) * - * @return EntityManager + * @return \Doctrine\ORM\EntityManager */ public function getEntityManager($name = null) { @@ -154,7 +154,7 @@ class Registry implements RegistryInterface * * @param string $name The entity manager name (null for the default one) * - * @return EntityManager + * @return \Doctrine\ORM\EntityManager */ public function resetEntityManager($name = null) { @@ -210,7 +210,7 @@ class Registry implements RegistryInterface * @param string $entityName The name of the entity. * @param string $entityManagerName The entity manager name (null for the default one) * - * @return Doctrine\ORM\EntityRepository + * @return \Doctrine\ORM\EntityRepository */ public function getRepository($entityName, $entityManagerName = null) { @@ -222,7 +222,7 @@ class Registry implements RegistryInterface * * @param string $class A Doctrine Entity class name * - * @return EntityManager|null + * @return \Doctrine\ORM\EntityManager|null */ public function getEntityManagerForClass($class) { From 6486e25a38798b04adbf926bd69da7a61c0e2563 Mon Sep 17 00:00:00 2001 From: Brikou CARRE Date: Tue, 10 Apr 2012 11:28:30 +0200 Subject: [PATCH 6/6] fixed used statements --- src/Symfony/Bundle/DoctrineBundle/Registry.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/DoctrineBundle/Registry.php b/src/Symfony/Bundle/DoctrineBundle/Registry.php index eb6cce353d..656829ffcb 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Registry.php +++ b/src/Symfony/Bundle/DoctrineBundle/Registry.php @@ -15,6 +15,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Bridge\Doctrine\RegistryInterface; use Doctrine\DBAL\Connection; use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityRepository; use Doctrine\ORM\ORMException; /** @@ -109,7 +111,7 @@ class Registry implements RegistryInterface * * @param string $name The entity manager name (null for the default one) * - * @return \Doctrine\ORM\EntityManager + * @return EntityManager */ public function getEntityManager($name = null) { @@ -154,7 +156,7 @@ class Registry implements RegistryInterface * * @param string $name The entity manager name (null for the default one) * - * @return \Doctrine\ORM\EntityManager + * @return EntityManager */ public function resetEntityManager($name = null) { @@ -210,7 +212,7 @@ class Registry implements RegistryInterface * @param string $entityName The name of the entity. * @param string $entityManagerName The entity manager name (null for the default one) * - * @return \Doctrine\ORM\EntityRepository + * @return EntityRepository */ public function getRepository($entityName, $entityManagerName = null) { @@ -222,7 +224,7 @@ class Registry implements RegistryInterface * * @param string $class A Doctrine Entity class name * - * @return \Doctrine\ORM\EntityManager|null + * @return EntityManager|null */ public function getEntityManagerForClass($class) {