Skip to content

Commit 871781d

Browse files
judmir.karriqillupa
authored andcommitted
Support PHP 74 and PHPunit 9
- Replace abandoned zendframework zend-json with laminas/laminas-json
1 parent a228f8b commit 871781d

8 files changed

Lines changed: 59 additions & 45 deletions

File tree

Form/Type/CodeMirrorType.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public function buildView(FormView $view, FormInterface $form, array $options)
2929
}
3030

3131
/**
32-
* {@inheritdoc}
32+
* Keep this to use same widget.
33+
*
34+
* @return string
3335
*/
3436
public function configureOptions(OptionsResolver $resolver)
3537
{
@@ -40,6 +42,18 @@ public function configureOptions(OptionsResolver $resolver)
4042
);
4143
}
4244

45+
/**
46+
* @param OptionsResolver $resolver
47+
*/
48+
public function configureOptions(OptionsResolver $resolver)
49+
{
50+
$resolver->setDefaults(
51+
array(
52+
'parameters' => array(),
53+
)
54+
);
55+
}
56+
4357
/**
4458
* {@inheritdoc}
4559
*/

Tests/App/config_test.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ framework:
1010
validation: { enable_annotations: true }
1111
templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
1212
default_locale: en
13-
trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
13+
trusted_proxies: [false] # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
1414
session: ~
1515
# Twig Configuration
1616
twig:
17-
form:
18-
resources:
19-
- 'SolutionCodeMirrorBundle:Form:code_mirror_widget.html.twig'
17+
form_themes:
18+
- 'SolutionCodeMirrorBundle:Form:code_mirror_widget.html.twig'
2019

2120
# Assetic Configuration
2221
assetic:
@@ -34,6 +33,6 @@ solution_code_mirror:
3433
lineNumbers: true
3534
lineWrapping: true
3635
mode_dirs:
37-
- @SolutionCodeMirrorBundle/Tests/App/dummy_js
36+
- "@SolutionCodeMirrorBundle/Tests/App/dummy_js"
3837
themes_dirs:
39-
- @SolutionCodeMirrorBundle/Tests/App/dummy_js
38+
- "@SolutionCodeMirrorBundle/Tests/App/dummy_js"

Tests/AssetTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Symfony\Component\DependencyInjection\ContainerInterface;
99
use Solution\CodeMirrorBundle\Tests\App\AppKernel;
1010

11-
class AssertTest extends WebTestCase
11+
class AssetTest extends WebTestCase
1212
{
1313
/**
1414
* @var AssetManager
@@ -18,7 +18,7 @@ class AssertTest extends WebTestCase
1818
/** @var ContainerInterface */
1919
protected $container;
2020

21-
protected function setUp()
21+
protected function setUp(): void
2222
{
2323
self::$kernel = new AppKernel('test', true);
2424
static::$kernel->boot();
@@ -86,4 +86,4 @@ public function testTheme()
8686
}
8787

8888

89-
}
89+
}

Tests/TwigExtensionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TwigExtensionTest extends WebTestCase
1313
{
1414
protected $extension;
1515

16-
protected function setUp()
16+
protected function setUp(): void
1717
{
1818
self::$kernel = new AppKernel('test', true);
1919
static::$kernel->boot();
@@ -43,7 +43,7 @@ public function testIsFirstCallByDefault()
4343
*/
4444
public function testRenderParameters($parameters, $return)
4545
{
46-
$this->assertEquals($return, $this->extension->parametersRender($parameters));
46+
$this->assertJsonStringEqualsJsonString((string) $return, (string) $this->extension->parametersRender($parameters));
4747
}
4848

4949
/**
@@ -77,4 +77,4 @@ static public function dataForRenderParameters()
7777
}
7878

7979

80-
}
80+
}

Tests/bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
if (file_exists($file = __DIR__.'/../vendor/autoload.php')) {
4-
$autoload = require_once $file;
4+
$autoload = require $file;
55
} else {
66
throw new RuntimeException('Install dependencies to run test suite.');
77
}
@@ -16,4 +16,4 @@
1616

1717
return true;
1818
}
19-
});
19+
});

Twig/CodeMirrorExtension.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
namespace Solution\CodeMirrorBundle\Twig;
33

4-
use Zend\Json\Json;
5-
use Zend\Json\Expr;
4+
use Laminas\Json\Expr;
5+
use Laminas\Json\Json;
66

77
use Assetic\AssetManager;
88
use Assetic\Asset\FileAsset;
9+
use Twig\TwigFunction;
910

1011
class CodeMirrorExtension extends \Twig_Extension
1112
{
@@ -24,10 +25,10 @@ function __construct($assetManager)
2425
public function getFunctions()
2526
{
2627
return array(
27-
new \Twig_SimpleFunction('code_mirror_parameters_render', array($this, 'parametersRender'), array('is_safe' => array('html'))),
28-
new \Twig_SimpleFunction('code_mirror_is_first_call', array($this, 'isFirstCall')),
29-
new \Twig_SimpleFunction('code_mirror_get_js_mode', array($this, 'code_mirror_get_js_mode')),
30-
new \Twig_SimpleFunction('code_mirror_get_css_theme', array($this, 'code_mirror_get_css_theme')),
28+
new TwigFunction('code_mirror_parameters_render', array($this, 'parametersRender'), array('is_safe' => array('html'))),
29+
new TwigFunction('code_mirror_is_first_call', array($this, 'isFirstCall')),
30+
new TwigFunction('code_mirror_get_js_mode', array($this, 'code_mirror_get_js_mode')),
31+
new TwigFunction('code_mirror_get_css_theme', array($this, 'code_mirror_get_css_theme')),
3132
);
3233
}
3334

@@ -36,7 +37,7 @@ public function parametersRender($paramters)
3637
if (isset($paramters['mode'])) {
3738
$paramters['mode'] = new Expr('"' . $paramters['mode'] . '"');
3839
}
39-
$params = Json::encode($paramters, false, array('enableJsonExprFinder' => true));
40+
$params = Json::encode($paramters, false, ['enableJsonExprFinder' => true]);
4041

4142
$this->isFirstCall = false;
4243

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/symfony": "~3.4",
2525
"twig/twig": "*",
2626
"symfony/assetic-bundle": "*",
27-
"zendframework/zend-json": "2.0.*"
27+
"laminas/laminas-json": "^3.1@dev"
2828
},
2929
"minimum-stability": "dev",
3030
"autoload": {

phpunit.xml.dist

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
44
<phpunit colors = "true" bootstrap = "./Tests/bootstrap.php" >
5-
<testsuites>
6-
<testsuite name="CodeMirror Test Suite">
7-
<directory suffix="Test.php">./Tests</directory>
8-
</testsuite>
9-
</testsuites>
10-
<!--
11-
<php>
12-
<server name="KERNEL_DIR" value="/path/to/your/app/" />
13-
</php>
14-
-->
15-
<filter>
16-
<whitelist>
17-
<directory>./</directory>
18-
<exclude>
19-
<directory>./DependencyInjection</directory>
20-
<directory>./Resources</directory>
21-
<directory>./Tests</directory>
22-
<directory>./vendor</directory>
23-
</exclude>
24-
</whitelist>
25-
</filter>
26-
</phpunit>
5+
<testsuites>
6+
<testsuite name="CodeMirror Test Suite">
7+
<directory suffix="Test.php">./Tests</directory>
8+
</testsuite>
9+
</testsuites>
10+
<!--
11+
<php>
12+
<server name="KERNEL_DIR" value="/path/to/your/app/" />
13+
</php>
14+
-->
15+
<filter>
16+
<whitelist>
17+
<directory>./</directory>
18+
<exclude>
19+
<directory>./DependencyInjection</directory>
20+
<directory>./Resources</directory>
21+
<directory>./Tests</directory>
22+
<directory>./vendor</directory>
23+
</exclude>
24+
</whitelist>
25+
</filter>
26+
</phpunit>

0 commit comments

Comments
 (0)