From c1450d57a0bb1dc8c729d49d8bf5a16456334ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Tue, 27 Feb 2018 11:19:13 +0000 Subject: [PATCH 1/3] Use PHP 7.2 in AppVeyor builds (#198) --- .appveyor.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 471e9af1..155a97ff 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,7 +7,7 @@ cache: - '%LOCALAPPDATA%\Composer\files' init: - - SET PATH=C:\Program Files\OpenSSL;c:\tools\php71;%PATH% + - SET PATH=C:\Program Files\OpenSSL;C:\tools\php;%PATH% environment: matrix: @@ -17,22 +17,19 @@ install: - cinst -y OpenSSL.Light - sc config wuauserv start= auto - net start wuauserv - - cinst -y php - - cd c:\tools\php71 + - cinst -y php --params "/InstallDir:C:\tools\php" + - cd C:\tools\php - copy php.ini-production php.ini /Y - - echo date.timezone="UTC" >> php.ini - echo extension_dir=ext >> php.ini - echo extension=php_openssl.dll >> php.ini - echo extension=php_mbstring.dll >> php.ini - - echo extension=php_fileinfo.dll >> php.ini - - echo memory_limit=1G >> php.ini - - cd c:\projects\cocur\slugify - - php -r "readfile('http://getcomposer.org/installer');" | php + - cd %APPVEYOR_BUILD_FOLDER% + - php -r "readfile('https://getcomposer.org/installer');" | php - php composer.phar update %COMPOSER_FLAGS% --no-interaction --no-progress test_script: - - cd c:\projects\cocur\slugify - - vendor\bin\phpunit.bat --verbose + - cd %APPVEYOR_BUILD_FOLDER% + - vendor\bin\phpunit --verbose --colors=always notifications: - provider: Webhook From 91184c02423e860b3333aab9a0272687b53ccf34 Mon Sep 17 00:00:00 2001 From: Andrey Bolonin Date: Tue, 6 Mar 2018 17:41:18 +0200 Subject: [PATCH 2/3] Update composer.json (#199) --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 7c49047c..289fb1b3 100644 --- a/composer.json +++ b/composer.json @@ -30,9 +30,9 @@ "pimple/pimple": "~1.1", "plumphp/plum": "~0.1", "silex/silex": "~1.3", - "symfony/config": "~2.4|~3.0", - "symfony/dependency-injection": "~2.4|~3.0", - "symfony/http-kernel": "~2.4|~3.0", + "symfony/config": "~2.4|~3.0|~4.0", + "symfony/dependency-injection": "~2.4|~3.0|~4.0", + "symfony/http-kernel": "~2.4|~3.0|~4.0", "twig/twig": "~1.26|~2.0", "zendframework/zend-modulemanager": "~2.2", "zendframework/zend-servicemanager": "~2.2", From bdb3dc802aad4a0d7f1de6330a3ad3beecef5779 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Wed, 21 Mar 2018 11:20:30 +0000 Subject: [PATCH 3/3] Add strip_tags option (#201) --- src/Bridge/Symfony/CocurSlugifyExtension.php | 2 +- src/Bridge/Symfony/Configuration.php | 1 + src/Slugify.php | 5 +++++ tests/Bridge/Symfony/ConfigurationTest.php | 10 ++++++++++ tests/SlugifyTest.php | 4 ++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Bridge/Symfony/CocurSlugifyExtension.php b/src/Bridge/Symfony/CocurSlugifyExtension.php index b891d023..05accaf1 100644 --- a/src/Bridge/Symfony/CocurSlugifyExtension.php +++ b/src/Bridge/Symfony/CocurSlugifyExtension.php @@ -44,7 +44,7 @@ public function load(array $configs, ContainerBuilder $container) } // Extract slugify arguments from config - $slugifyArguments = array_intersect_key($config, array_flip(['lowercase', 'separator', 'regexp', 'rulesets'])); + $slugifyArguments = array_intersect_key($config, array_flip(['lowercase', 'trim', 'strip_tags', 'separator', 'regexp', 'rulesets'])); $container->setDefinition('cocur_slugify', new Definition('Cocur\Slugify\Slugify', [$slugifyArguments])); $container diff --git a/src/Bridge/Symfony/Configuration.php b/src/Bridge/Symfony/Configuration.php index d2f30d14..d51342bb 100644 --- a/src/Bridge/Symfony/Configuration.php +++ b/src/Bridge/Symfony/Configuration.php @@ -28,6 +28,7 @@ public function getConfigTreeBuilder() ->children() ->booleanNode('lowercase')->end() ->booleanNode('trim')->end() + ->booleanNode('strip_tags')->end() ->scalarNode('separator')->end() ->scalarNode('regexp')->end() ->arrayNode('rulesets')->prototype('scalar')->end() diff --git a/src/Slugify.php b/src/Slugify.php index 9e059d67..bdeb54d1 100644 --- a/src/Slugify.php +++ b/src/Slugify.php @@ -46,6 +46,7 @@ class Slugify implements SlugifyInterface 'separator' => '-', 'lowercase' => true, 'trim' => true, + 'strip_tags' => false, 'rulesets' => [ 'default', // Languages are preferred if they appear later, list is ordered by number of @@ -111,6 +112,10 @@ public function slugify($string, $options = null) $rules = $this->rules; } + $string = ($options['strip_tags']) + ? strip_tags($string) + : $string; + $string = strtr($string, $rules); unset($rules); diff --git a/tests/Bridge/Symfony/ConfigurationTest.php b/tests/Bridge/Symfony/ConfigurationTest.php index d7bc1945..1ebde250 100644 --- a/tests/Bridge/Symfony/ConfigurationTest.php +++ b/tests/Bridge/Symfony/ConfigurationTest.php @@ -21,6 +21,7 @@ public function testAll() $configs = [ [ 'lowercase' => true, + 'strip_tags' => false, 'separator' => '_', 'regexp' => 'abcd', 'rulesets' => ['burmese', 'hindi'] @@ -39,6 +40,15 @@ public function testLowercaseOnlyAcceptsBoolean() $this->process($configs); } + /** + * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException + */ + public function testStripTagsOnlyAcceptsBoolean() + { + $configs = [['strip_tags' => 'abc']]; + $this->process($configs); + } + /** * Processes an array of configurations and returns a compiled version. * diff --git a/tests/SlugifyTest.php b/tests/SlugifyTest.php index 69dbe8ae..2938a8eb 100644 --- a/tests/SlugifyTest.php +++ b/tests/SlugifyTest.php @@ -211,6 +211,10 @@ public function slugifyOptionsArray() $this->assertEquals('file-name', $this->slugify->slugify('file name ')); $this->assertEquals('file-name-', $this->slugify->slugify('file name ', ['trim' => false])); + + $this->assertEquals('file-name', $this->slugify->slugify('assertEquals('p-file-p-foo-a-href-bar-name-a', $this->slugify->slugify('

file

name')); + $this->assertEquals('file-name', $this->slugify->slugify('

file

name', ['strip_tags' => true])); } /**