Skip to content

Commit

Permalink
Merge pull request #29 from bedita/feat/upgrade-cake-4-2
Browse files Browse the repository at this point in the history
Upgrade cake 4.2
  • Loading branch information
stefanorosanelli authored Jan 22, 2021
2 parents 94c6f5d + 27d42ba commit c34b959
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 60 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
},
"require": {
"php": ">=7.2",
"cakephp/cakephp": "4.0.*"
"cakephp/cakephp": "~4.2.2"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"cakephp/cakephp-codesniffer": "~4.0.0"
"cakephp/cakephp-codesniffer": "~4.2.0"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 0 additions & 5 deletions src/Core/I18nTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ trait I18nTrait
* Return the currently configure locale as stored in the `intl.default_locale` PHP setting.
*
* @return string The name of the default locale.
*
* @codeCoverageIgnore
*/
public function getLocale(): string
Expand All @@ -40,7 +39,6 @@ public function getLocale(): string
* Return the configured supported locales
*
* @return array
*
* @codeCoverageIgnore
*/
public function getLocales(): array
Expand All @@ -52,7 +50,6 @@ public function getLocales(): array
* Return an array of available languages.
*
* @return array
*
* @codeCoverageIgnore
*/
public function getLanguages(): array
Expand All @@ -64,7 +61,6 @@ public function getLanguages(): array
* Return the current lang usually set by `\BEdita\I18n\Middleware\I18nMiddleware`
*
* @return string|null
*
* @codeCoverageIgnore
*/
public function getLang(): ?string
Expand All @@ -91,7 +87,6 @@ public function getLangName($lang = null): ?string
* Return the default lang as configured.
*
* @return string|null
*
* @codeCoverageIgnore
*/
public function getDefaultLang(): ?string
Expand Down
4 changes: 2 additions & 2 deletions src/Routing/Route/I18nRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class I18nRoute extends Route
use I18nTrait;

/**
* {@inheritDoc}
* @inheritDoc
*/
public function __construct($template, $defaults = [], array $options = [])
{
Expand Down Expand Up @@ -60,7 +60,7 @@ protected function buildTemplate(string $template): string
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function match(array $url, array $context = []): ?string
{
Expand Down
14 changes: 6 additions & 8 deletions src/Shell/GettextShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private function setupPaths(): void
$startPath = $this->params['startPath'] ? $this->params['startPath'] : getcwd();
$f = new Folder(sprintf('%s/plugins/%s', $startPath, $this->params['plugin']));
$basePath = $f->path;
$this->poName = $this->params['plugin'] . ".po";
$this->poName = $this->params['plugin'] . '.po';
}

$this->templatePaths = [
Expand Down Expand Up @@ -205,7 +205,6 @@ private function writePoFiles(): void
*
* @param string $type The file type (can be 'po', 'pot')
* @return string
*
* @codeCoverageIgnore
*/
private function header(string $type = 'po'): string
Expand All @@ -214,7 +213,7 @@ private function header(string $type = 'po'): string
$contents = [
'po' => [
'Project-Id-Version' => 'BEdita 4',
'POT-Creation-Date' => date("Y-m-d H:i:s"),
'POT-Creation-Date' => date('Y-m-d H:i:s'),
'PO-Revision-Date' => '',
'Last-Translator' => '',
'Language-Team' => 'BEdita I18N & I10N Team',
Expand All @@ -226,7 +225,7 @@ private function header(string $type = 'po'): string
],
'pot' => [
'Project-Id-Version' => 'BEdita 4',
'POT-Creation-Date' => date("Y-m-d H:i:s"),
'POT-Creation-Date' => date('Y-m-d H:i:s'),
'MIME-Version' => '1.0',
'Content-Transfer-Encoding' => '8bit',
'Language-Team' => 'BEdita I18N & I10N Team',
Expand Down Expand Up @@ -314,7 +313,7 @@ private function parseFile($file, $extension)
*/
private function parseContent($content): void
{
$p = preg_quote("(");
$p = preg_quote('(');
$q1 = preg_quote("'");
$q2 = preg_quote('"');

Expand All @@ -324,8 +323,8 @@ private function parseContent($content): void

// looks for __("text to translate",true)
// or __('text to translate',true), result in matches[1] or in matches[2]
$rgxp = "/" . "__\s*{$p}\s*{$q2}" . "([^{$q2}]*)" . "{$q2}" .
"|" . "__\s*{$p}\s*{$q1}" . "([^{$q1}]*)" . "{$q1}" . "/";
$rgxp = '/' . "__\s*{$p}\s*{$q2}" . "([^{$q2}]*)" . "{$q2}" .
'|' . "__\s*{$p}\s*{$q1}" . "([^{$q1}]*)" . "{$q1}" . '/';
$matches = [];
preg_match_all($rgxp, $content, $matches);

Expand Down Expand Up @@ -368,7 +367,6 @@ private function parseDir($dir): void
* Extract translations from javascript files using ttag, if available.
*
* @return void
*
* @codeCoverageIgnore
*/
private function ttagExtract(): void
Expand Down
3 changes: 1 addition & 2 deletions src/View/Helper/I18nHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class I18nHelper extends Helper
use I18nTrait;

/**
* {@inheritDoc}
* @inheritDoc
*/
public $helpers = ['Html', 'Url'];

Expand All @@ -44,7 +44,6 @@ class I18nHelper extends Helper
*
* translation[<object ID>][<lang>][<field>] = <value>.
*
*
* @var array|null
*/
protected $translation = null;
Expand Down
5 changes: 2 additions & 3 deletions tests/TestCase/Core/I18nTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class I18nTraitTest extends TestCase
protected $subject = null;

/**
* {@inheritDoc}
* @inheritDoc
*/
public function setUp(): void
{
Expand All @@ -60,7 +60,7 @@ public function setUp(): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function tearDown(): void
{
Expand Down Expand Up @@ -97,7 +97,6 @@ public function getLangNameProvider(): array
* Test `getLangName()`
*
* @return void
*
* @dataProvider getLangNameProvider
* @covers ::getLangName()
*/
Expand Down
13 changes: 2 additions & 11 deletions tests/TestCase/Middleware/I18nMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class I18nMiddlewareTest extends TestCase
protected $requestHandler;

/**
* {@inheritDoc}
* @inheritDoc
*/
public function setUp(): void
{
Expand Down Expand Up @@ -76,7 +76,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function tearDown(): void
{
Expand Down Expand Up @@ -149,7 +149,6 @@ public function statusProvider(): array
* @param array $conf The configuration passed to middleware
* @param array $server The server vars
* @return void
*
* @dataProvider statusProvider
* @covers ::__construct()
* @covers ::__invoke()
Expand Down Expand Up @@ -264,7 +263,6 @@ public function redirectPathProvider(): array
* @param array $conf The configuration passed to middleware
* @param array $server The server vars
* @return void
*
* @dataProvider redirectPathProvider
* @covers ::__invoke()
*/
Expand Down Expand Up @@ -322,7 +320,6 @@ public function setupLocaleProvider(): array
* @param array $expected The expected values (locale and lang)
* @param array $server The server vars
* @return void
*
* @dataProvider setupLocaleProvider
* @covers ::detectLocale()
* @covers ::setupLocale()
Expand All @@ -341,7 +338,6 @@ public function testSetupLocale(array $expected, array $server): void
* Test that an exception is raised if missing required conf.
*
* @return void
*
* @covers ::setupLocale()
*/
public function testSetupLocaleMissingConfig(): void
Expand All @@ -361,7 +357,6 @@ public function testSetupLocaleMissingConfig(): void
* Test that if middleware is not configured properly the locale cookie is ignored.
*
* @return void
*
* @covers ::detectLocale()
* @covers ::setupLocale()
* @covers ::getResponseWithCookie()
Expand All @@ -385,7 +380,6 @@ public function testNotUseCookie(): void
* Test that if middleware is configured properly the locale is set by cookie
*
* @return void
*
* @covers ::detectLocale()
* @covers ::setupLocale()
* @covers ::getResponseWithCookie()
Expand All @@ -411,7 +405,6 @@ public function testReadFromCookie(): void
* Test cookie creation.
*
* @return void
*
* @covers ::detectLocale()
* @covers ::setupLocale()
* @covers ::getResponseWithCookie()
Expand Down Expand Up @@ -448,7 +441,6 @@ public function testCreateCookie(): void
* Test change expire cookie.
*
* @return void
*
* @covers ::detectLocale()
* @covers ::setupLocale()
* @covers ::getResponseWithCookie()
Expand Down Expand Up @@ -563,7 +555,6 @@ public function changeLangProvider(): array
* @param array $server The server vars
* @param array $query The query string
* @return void
*
* @dataProvider changeLangProvider
* @covers ::changeLangAndRedirect()
* @covers ::__invoke()
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class PluginTest extends TestCase
* Test `console` method
*
* @return void
*
* @covers ::middleware()
*/
public function testMiddleware(): void
Expand Down
9 changes: 2 additions & 7 deletions tests/TestCase/Routing/Route/I18nRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class I18nRouteTest extends TestCase
use I18nTrait;

/**
* {@inheritDoc}
* @inheritDoc
*/
public function setUp(): void
{
Expand All @@ -52,7 +52,7 @@ public function setUp(): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function tearDown(): void
{
Expand Down Expand Up @@ -106,7 +106,6 @@ public function templateProvider(): array
* @param string $expected The expected template for the route
* @param string $template The initial template
* @return void
*
* @dataProvider templateProvider
* @covers ::__construct()
* @covers ::buildTemplate()
Expand Down Expand Up @@ -144,7 +143,6 @@ public function langPatternsProvider(): array
* @param string $expected The expected pattern for 'lang'
* @param array $options The options for constructor.
* @return void
*
* @dataProvider langPatternsProvider
* @covers ::__construct()
*/
Expand All @@ -158,7 +156,6 @@ public function testLangPatterns(string $expected, array $options): void
* Test that if missing 'lang' param match() method return current lang in path.
*
* @return void
*
* @covers ::match()
*/
public function testMatchUseCurrentLang(): void
Expand All @@ -180,7 +177,6 @@ public function testMatchUseCurrentLang(): void
* Test that passing a different lang match() method return it in path
*
* @return void
*
* @covers ::match()
*/
public function testMatchUseCustomLang(): void
Expand All @@ -204,7 +200,6 @@ public function testMatchUseCustomLang(): void
* Test that passing an invalid lang match() method return false
*
* @return void
*
* @covers ::match()
*/
public function testMatchInvalidLang(): void
Expand Down
8 changes: 2 additions & 6 deletions tests/TestCase/Shell/GettextShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GettextShellTest extends ConsoleIntegrationTestCase
protected $shell = null;

/**
* {@inheritDoc}
* @inheritDoc
*/
public function setUp(): void
{
Expand All @@ -51,7 +51,7 @@ public function setUp(): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function tearDown(): void
{
Expand Down Expand Up @@ -128,7 +128,6 @@ public function setupPathsProvider()
* @param array $expectedTemplatePaths The expected template paths
* @param string $expectedLocalePath The expected locale path
* @return void
*
* @dataProvider setupPathsProvider
* @covers ::setupPaths()
*/
Expand Down Expand Up @@ -196,7 +195,6 @@ public function testWriteMasterPot()
* Test 'writePoFiles'
*
* @return void
*
* @covers ::header()
* @covers ::writePoFiles()
* @covers ::analyzePoFile()
Expand Down Expand Up @@ -249,7 +247,6 @@ public function fixStringProvider()
* @param string $input The input string
* @param string $expected The expected output string
* @return void
*
* @dataProvider fixStringProvider
* @covers ::fixString()
*/
Expand Down Expand Up @@ -291,7 +288,6 @@ public function parseDirProvider()
* @param string $dir The directory containing files to parse
* @param array $expected The po result array
* @return void
*
* @dataProvider parseDirProvider
* @covers ::parseDir()
* @covers ::parseFile()
Expand Down
Loading

0 comments on commit c34b959

Please sign in to comment.