diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php index ff2e24ce36..7371d17242 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -33,7 +33,7 @@ class RequestMatcher implements RequestMatcherInterface /** * @var array */ - private $methods; + private $methods = array(); /** * @var string @@ -41,19 +41,26 @@ class RequestMatcher implements RequestMatcherInterface private $ip; /** - * Attributes. - * * @var array */ - private $attributes; + private $attributes = array(); + /** + * @param string|null $path + * @param string|null $host + * @param string|string[]|null $methods + * @param string|null $ip + * @param array $attributes + */ public function __construct($path = null, $host = null, $methods = null, $ip = null, array $attributes = array()) { - $this->path = $path; - $this->host = $host; - $this->methods = $methods; - $this->ip = $ip; - $this->attributes = $attributes; + $this->matchPath($path); + $this->matchHost($host); + $this->matchMethod($methods); + $this->matchIp($ip); + foreach ($attributes as $k => $v) { + $this->matchAttribute($k, $v); + } } /** @@ -89,11 +96,11 @@ class RequestMatcher implements RequestMatcherInterface /** * Adds a check for the HTTP method. * - * @param string|array $method An HTTP method or an array of HTTP methods + * @param string|string[]|null $method An HTTP method or an array of HTTP methods */ public function matchMethod($method) { - $this->methods = array_map('strtoupper', is_array($method) ? $method : array($method)); + $this->methods = array_map('strtoupper', (array) $method); } /** @@ -114,7 +121,7 @@ class RequestMatcher implements RequestMatcherInterface */ public function matches(Request $request) { - if (null !== $this->methods && !in_array($request->getMethod(), $this->methods)) { + if ($this->methods && !in_array($request->getMethod(), $this->methods)) { return false; } @@ -132,7 +139,7 @@ class RequestMatcher implements RequestMatcherInterface } } - if (null !== $this->host && !preg_match('#'.str_replace('#', '\\#', $this->host).'#', $request->getHost())) { + if (null !== $this->host && !preg_match('#'.str_replace('#', '\\#', $this->host).'#i', $request->getHost())) { return false; } @@ -204,7 +211,7 @@ class RequestMatcher implements RequestMatcherInterface if (false !== strpos($ip, '/')) { list($address, $netmask) = explode('/', $ip, 2); - + if ($netmask < 1 || $netmask > 128) { return false; } @@ -228,3 +235,4 @@ class RequestMatcher implements RequestMatcherInterface return true; } } + diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php index 32ca1e5246..0e7b9eff66 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php @@ -88,38 +88,59 @@ class RequestMatcherTest extends \PHPUnit_Framework_TestCase } } - public function testMethod() + /** + * @dataProvider testMethodFixtures + */ + public function testMethod($requestMethod, $matcherMethod, $isMatch) { $matcher = new RequestMatcher(); + $matcher->matchMethod($matcherMethod); + $request = Request::create('', $requestMethod); + $this->assertSame($isMatch, $matcher->matches($request)); - $matcher->matchMethod('get'); - $request = Request::create('', 'get'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchMethod('post'); - $this->assertFalse($matcher->matches($request)); - - $matcher->matchMethod(array('get', 'post')); - $this->assertTrue($matcher->matches($request)); + $matcher = new RequestMatcher(null, null, $matcherMethod); + $request = Request::create('', $requestMethod); + $this->assertSame($isMatch, $matcher->matches($request)); } - public function testHost() + public function testMethodFixtures() + { + return array( + array('get', 'get', true), + array('get', array('get', 'post'), true), + array('get', 'post', false), + array('get', 'GET', true), + array('get', array('GET', 'POST'), true), + array('get', 'POST', false), + ); + } + + /** + * @dataProvider testHostFixture + */ + public function testHost($pattern, $isMatch) { $matcher = new RequestMatcher(); - $request = Request::create('', 'get', array(), array(), array(), array('HTTP_HOST' => 'foo.example.com')); - $matcher->matchHost('.*\.example\.com'); - $this->assertTrue($matcher->matches($request)); + $matcher->matchHost($pattern); + $this->assertSame($isMatch, $matcher->matches($request)); - $matcher->matchHost('\.example\.com$'); - $this->assertTrue($matcher->matches($request)); + $matcher= new RequestMatcher(null, $pattern); + $this->assertSame($isMatch, $matcher->matches($request)); + } - $matcher->matchHost('^.*\.example\.com$'); - $this->assertTrue($matcher->matches($request)); - - $matcher->matchMethod('.*\.sensio\.com'); - $this->assertFalse($matcher->matches($request)); + public function testHostFixture() + { + return array( + array('.*\.example\.com', true), + array('\.example\.com$', true), + array('^.*\.example\.com$', true), + array('.*\.sensio\.com', false), + array('.*\.example\.COM', true), + array('\.example\.COM$', true), + array('^.*\.example\.COM$', true), + array('.*\.sensio\.COM', false), ); } public function testPath() @@ -179,3 +200,4 @@ class RequestMatcherTest extends \PHPUnit_Framework_TestCase $this->assertFalse($matcher->matches($request)); } } + diff --git a/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php b/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php index 7c9cc71e43..32bc260275 100644 --- a/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php +++ b/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php @@ -186,7 +186,7 @@ class StubIntlDateFormatter $argumentError = null; if (version_compare(\PHP_VERSION, '5.3.4', '<') && !is_int($timestamp)) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; - } elseif (version_compare(\PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceOf \DateTime) { + } elseif (version_compare(\PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; } @@ -199,7 +199,7 @@ class StubIntlDateFormatter } // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (version_compare(\PHP_VERSION, '5.3.4', '>=') && $timestamp instanceOf \DateTime) { + if (version_compare(\PHP_VERSION, '5.3.4', '>=') && $timestamp instanceof \DateTime) { $timestamp = $timestamp->getTimestamp(); } diff --git a/src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php b/src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php index 3b4e99a861..09e227ccdc 100644 --- a/src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php +++ b/src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php @@ -120,10 +120,8 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface * permission/identity combination. * * This process is repeated until either a granting ACE is found, or no - * permission/identity combinations are left. In the latter case, we will - * call this method on the parent ACL if it exists, and isEntriesInheriting - * is true. Otherwise, we will either throw an NoAceFoundException, or deny - * access finally. + * permission/identity combinations are left. Finally, we will either throw + * an NoAceFoundException, or deny access. * * @param AclInterface $acl * @param array $aces An array of ACE to check against diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ua.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ua.xlf deleted file mode 100644 index c323759602..0000000000 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ua.xlf +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - This value should be false. - Значення повинно бути Ні. - - - This value should be true. - Значення повинно бути Так. - - - This value should be of type {{ type }}. - Тип значення повинен бути {{ type }}. - - - This value should be blank. - Значення повинно бути пустим. - - - The value you selected is not a valid choice. - Обране вами значення недопустиме. - - - You must select at least {{ limit }} choices. - Ви повинні обрати хоча б {{ limit }} варіантів. - - - You must select at most {{ limit }} choices. - Ви повинні обрати не більше ніж {{ limit }} варіантів. - - - One or more of the given values is invalid. - Одне або кілька заданих значень є недопустимі. - - - The fields {{ fields }} were not expected. - Поля {{ fields }} не очікувалися. - - - The fields {{ fields }} are missing. - Поля {{ fields }} відсутні. - - - This value is not a valid date. - Дане значення не є вірною датою. - - - This value is not a valid datetime. - Дане значення дати та часу недопустиме. - - - This value is not a valid email address. - Значення адреси электронної пошти недопустиме. - - - The file could not be found. - Файл не знайдено. - - - The file is not readable. - Файл не читається. - - - The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - Файл занадто великий ({{ size }} {{ suffix }}). Дозволений максимальний розмір {{ limit }} {{ suffix }}. - - - The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - MIME-тип файлу недопустимий ({{ type }}). Допустимі MIME-типи файлів {{ types }}. - - - This value should be {{ limit }} or less. - Значення повинно бути {{ limit }} або менше. - - - This value is too long. It should have {{ limit }} characters or less. - Значення занадто довге. Повинно бути {{ limit }} символів або менше. - - - This value should be {{ limit }} or more. - Значення повинно бути {{ limit }} або більше. - - - This value is too short. It should have {{ limit }} characters or more. - Значення занадто коротке. Повинно бути {{ limit }} символів або більше. - - - This value should not be blank. - Значення не повинно бути пустим. - - - This value should not be null. - Значення не повинно бути null. - - - This value should be null. - Значення повинно бути null. - - - This value is not valid. - Значення недопустиме. - - - This value is not a valid time. - Значення часу недопустиме. - - - This value is not a valid URL. - Значення URL недопустиме. - - - The two values should be equal. - Обидва занчення повинні бути одинаковими. - - - The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - Файл занадто великий. Максимальний допустимий розмір {{ limit }} {{ suffix }}. - - - The file is too large. - Файл занадто великий. - - - The file could not be uploaded. - Файл не можливо завантажити. - - - This value should be a valid number. - Значення має бути допустимим числом. - - - This file is not a valid image. - Цей файл не є допустимим форматом зображення. - - - This is not a valid IP address. - Значення не є допустимою IP адресою. - - - This value is not a valid language. - Значення не є допустимим кодом мови. - - - This value is not a valid locale. - Значення не є допустимим значенням локалізації. - - - This value is not a valid country. - Значення не є допустимим значенням країни. - - - This value is already used. - Значення вже використовується. - - - The size of the image could not be detected. - Не можливо визначити розмір зображення. - - - The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. - Ширина зображення занадто велика ({{ width }}px). Максимальна допустима ширина {{ max_width }}px. - - - The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. - Ширина зображення занадто мала ({{ width }}px). Мінімальна допустима ширина {{ min_width }}px. - - - The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. - Висота зображення занадто велика ({{ height }}px). Максимальна допустима висота {{ max_height }}px. - - - The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. - Висота зображення занадто мала ({{ height }}px). Мінімальна допустима висота {{ min_height }}px. - - - This value should be the user current password. - Значення має бути поточним паролем користувача. - - - This value should have exactly {{ limit }} characters. - Значення повинно бути рівним {{ limit }} символу.|Значення повинно бути рівним {{ limit }} символам. - - - The file was only partially uploaded. - Файл було завантажено лише частково. - - - No file was uploaded. - Файл не завантажено. - - - No temporary folder was configured in php.ini. - Не налаштована тимчасова директорія в php.ini. - - - Cannot write temporary file to disk. - Неможливо записати тимчасовий файл на диск. - - - A PHP extension caused the upload to fail. - Розширення PHP викликало помилку при завантаженні. - - - This collection should contain {{ limit }} elements or more. - Колекція повинна містити {{ limit }} елемент або більше.|Колекція повинна містити {{ limit }} елементи або більше.|Колекція повинна містити {{ limit }} елементів або більше. - - - This collection should contain {{ limit }} elements or less. - Колекція повинна містити {{ limit }} елемент або менше.|Колекція повинна містити {{ limit }} елементи або менше.|Колекція повинна містити {{ limit }} елементів або менше. - - - This collection should contain exactly {{ limit }} elements. - Колекція повинна містити рівно {{ limit }} елемент.|Колекція повинна містити рівно {{ limit }} елементи.|Колекція повинна містити рівно {{ limit }} елементів. - - - - diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf new file mode 100644 index 0000000000..f572f0f817 --- /dev/null +++ b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf @@ -0,0 +1,163 @@ + + + + + + This value should be false + Значення повинно бути Ні + + + This value should be true + Значення повинно бути Так + + + This value should be of type {{ type }} + Тип значення повинен бути {{ type }} + + + This value should be blank + Значення повинно бути пустим + + + The value you selected is not a valid choice + Обране вами значення недопустиме + + + You must select at least {{ limit }} choices + Ви повинні обрати хоча б {{ limit }} варіантів + + + You must select at most {{ limit }} choices + Ви повинні обрати не більше ніж {{ limit }} варіантів + + + One or more of the given values is invalid + Одне або кілька заданих значень є недопустимі + + + The fields {{ fields }} were not expected + Поля {{ fields }} не очікувалися + + + The fields {{ fields }} are missing + Поля {{ fields }} відсутні + + + This value is not a valid date + Дане значення не є вірною датою + + + This value is not a valid datetime + Дане значення дати та часу недопустиме + + + This value is not a valid email address + Значення адреси электронної пошти недопустиме + + + The file could not be found + Файл не знайдено + + + The file is not readable + Файл не читається + + + The file is too large ({{ size }}). Allowed maximum size is {{ limit }} + Файл занадто великий ({{ size }}). Дозволений максимальний розмір {{ limit }} + + + The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }} + MIME-тип файлу недопустимий ({{ type }}). Допустимі MIME-типи файлів {{ types }} + + + This value should be {{ limit }} or less + Значення повинно бути {{ limit }} або менше + + + This value is too long. It should have {{ limit }} characters or less + Значення занадто довге. Повинно бути {{ limit }} символів або менше + + + This value should be {{ limit }} or more + Значення повинно бути {{ limit }} або більше + + + This value is too short. It should have {{ limit }} characters or more + Значення занадто коротке. Повинно бути {{ limit }} символів або більше + + + This value should not be blank + Значення не повинно бути пустим + + + This value should not be null + Значення не повинно бути null + + + This value should be null + Значення повинно бути null + + + This value is not valid + Значення недопустиме + + + This value is not a valid time + Значення часу недопустиме + + + This value is not a valid URL + Значення URL недопустиме + + + This form should not contain extra fields + Ця форма не повинна містити додаткових полів + + + The uploaded file was too large. Please try to upload a smaller file + Завантажений файл занадто великий. Будь-ласка, спробуйте завантажити файл меншого розміру + + + The CSRF token is invalid. Please try to resubmit the form + CSRF значення недопустиме. Будь-ласка, спробуйте відправити форму знову + + + The two values should be equal + Обидва занчення повинні бути одинаковими + + + The file is too large. Allowed maximum size is {{ limit }} + Файл занадто великий. Максимальний допустимий розмір {{ limit }} + + + The file is too large + Файл занадто великий + + + The file could not be uploaded + Файл не можливо завантажити + + + This value should be a valid number + Значення має бути допустимим числом + + + This value is not a valid country + Значення не є допустимим значенням країни + + + This file is not a valid image + Цей файл не є допустимим форматом зображення + + + This is not a valid IP address + Значення не є допустимою IP адресою + + + This value is not a valid language + Значення не є допустимим кодом мови + + + + \ No newline at end of file