Skip to content

Commit d19ded9

Browse files
authored
Merge pull request #73 from thunderer/quality-of-life
Quality improvements
2 parents 0386f10 + 66cc3c3 commit d19ded9

File tree

13 files changed

+55
-16
lines changed

13 files changed

+55
-16
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
language: php
22

33
php:
4+
- 5.3
45
- 5.4
56
- 5.5
67
- 5.6
78
- 7.0
89
- 7.1
910
- 7.2
11+
- 7.3
1012
- hhvm
1113
- nightly
1214

@@ -24,5 +26,7 @@ after_script:
2426

2527
matrix:
2628
allow_failures:
29+
- php: 5.3
30+
- php: hhvm
2731
- php: nightly
2832
- php: hhvm

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
PHP ?= 7.3
2+
3+
composer-update:
4+
docker-compose run --rm composer composer config platform.php ${PHP}
5+
docker-compose run --rm composer composer update
6+
docker-compose run --rm composer composer config --unset platform
7+
8+
test:
9+
docker-compose run --rm php-${PHP} php -v
10+
docker-compose run --rm php-${PHP} php /app/vendor/bin/phpunit -c /app/phpunit.xml.dist
11+
test-local:
12+
php -v
13+
php vendor/bin/phpunit

docker-compose.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3'
2+
3+
services:
4+
5+
composer:
6+
image: 'composer:1.6'
7+
volumes: ['.:/app']
8+
9+
# PHP 5.3 contains neither mbstring extension nor docker-php-ext-install script
10+
# Original Dockerfile can be found here https://github.com/docker-library/php/pull/20/files
11+
# Unfortunately it fails to build now because GPG signatures do not exist anymore
12+
# php-5.3: { build: 'docker/php-5.3', volumes: ['.:/app'] }
13+
php-5.4: { build: 'docker/php-5.4', volumes: ['.:/app'] }
14+
php-5.5: { image: 'php:5.5', volumes: ['.:/app'] }
15+
php-5.6: { image: 'php:5.6', volumes: ['.:/app'] }
16+
php-7.0: { image: 'php:7.0', volumes: ['.:/app'] }
17+
php-7.1: { image: 'php:7.1', volumes: ['.:/app'] }
18+
php-7.2: { image: 'php:7.2', volumes: ['.:/app'] }
19+
php-7.3: { image: 'php:7.3', volumes: ['.:/app'] }

docker/php-5.4/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM php:5.4
2+
3+
RUN docker-php-ext-install mbstring

src/Event/ReplaceShortcodesEvent.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function __construct($text, array $replacements, ShortcodeInterface $shor
2323
{
2424
$this->shortcode = $shortcode;
2525
$this->text = $text;
26-
$this->result = null;
2726

2827
$this->setReplacements($replacements);
2928
}

src/EventContainer/EventContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct()
1616

1717
public function addListener($event, $handler)
1818
{
19-
if(!in_array($event, Events::getEvents())) {
19+
if(!\in_array($event, Events::getEvents(), true)) {
2020
throw new \InvalidArgumentException(sprintf('Unsupported event %s!', $event));
2121
}
2222

src/EventHandler/FilterRawEventHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(array $names)
2525
public function __invoke(FilterShortcodesEvent $event)
2626
{
2727
$parent = $event->getParent();
28-
if($parent && in_array($parent->getName(), $this->names)) {
28+
if($parent && \in_array($parent->getName(), $this->names, true)) {
2929
$event->setShortcodes(array());
3030

3131
return;

src/HandlerContainer/HandlerContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function getNames()
6262

6363
public function get($name)
6464
{
65-
return $this->has($name) ? $this->handlers[$name] : ($this->default ?: null);
65+
return $this->has($name) ? $this->handlers[$name] : $this->default;
6666
}
6767

6868
public function has($name)

src/Parser/WordpressParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static function parseParameters($text)
9797
$parameters[strtolower($match[3])] = stripcslashes($match[4]);
9898
} elseif(!empty($match[5])) {
9999
$parameters[strtolower($match[5])] = stripcslashes($match[6]);
100-
} elseif(isset($match[7]) && strlen($match[7])) {
100+
} elseif(isset($match[7]) && $match[7] !== '') {
101101
$parameters[stripcslashes($match[7])] = null;
102102
} elseif(isset($match[8])) {
103103
$parameters[stripcslashes($match[8])] = null;

src/Processor/Processor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ final class Processor implements ProcessorInterface
2323
/** @var EventContainerInterface */
2424
private $eventContainer;
2525

26-
private $recursionDepth = null; // infinite recursion
26+
/** @var int|null */
27+
private $recursionDepth; // infinite recursion
2728
private $maxIterations = 1; // one iteration
2829
private $autoProcessContent = true; // automatically process shortcode content
2930

@@ -144,7 +145,7 @@ private function processHandler(ParsedShortcodeInterface $parsed, ProcessorConte
144145
return mb_substr($state, 0, $offset, 'utf-8').$processed->getContent().mb_substr($state, $offset + $length, mb_strlen($state, 'utf-8'), 'utf-8');
145146
}
146147

147-
private function processRecursion(ParsedShortcodeInterface $shortcode, ProcessorContext $context)
148+
private function processRecursion(ProcessedShortcode $shortcode, ProcessorContext $context)
148149
{
149150
if ($this->autoProcessContent && null !== $shortcode->getContent()) {
150151
$context->recursionLevel++;

0 commit comments

Comments
 (0)