Skip to content

Commit d212e9a

Browse files
authored
Merge pull request #49 from ADmad/cake-4.x
Cake 4.x
2 parents 092b85d + a393d48 commit d212e9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1585
-1023
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ trim_trailing_whitespace = true
1313
[*.yml]
1414
indent_style = space
1515
indent_size = 2
16+
17+
[*.neon]
18+
indent_style = tab

.gitattributes

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
.editorconfig export-ignore
33
.gitattributes export-ignore
44
.gitignore export-ignore
5-
phpunit.xml export-ignore
5+
phpunit.xml.dist export-ignore
66
.travis.yml export-ignore
77
tests export-ignore
8+
phpstan.neon export-ignore
9+
psalm.xml export-ignore
10+
psalm-baseline.xml export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/composer.lock
22
/vendor
3+
.phpunit.result.cache

.scrutinizer.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.styleci.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.travis.yml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.1
6-
- 7.3
4+
- 7.2
5+
- 7.4
76

87
services:
9-
- mysql
108
- postgresql
9+
- mysql
1110

1211
env:
1312
matrix:
@@ -22,36 +21,45 @@ matrix:
2221
fast_finish: true
2322

2423
include:
25-
- php: 7.1
24+
- php: 7.2
2625
env: PHPCS=1 DEFAULT=0
2726

28-
- php: 7.1
27+
- php: 7.2
2928
env: STATIC_ANALYSIS=1 DEFAULT=0
3029

31-
- php: 5.6
30+
- php: 7.2
3231
env: PREFER_LOWEST=1
3332

3433
before_script:
35-
- if [[ $TRAVIS_PHP_VERSION != 7.1 ]]; then phpenv config-rm xdebug.ini; fi
34+
- if [[ $PREFER_LOWEST != 1 ]]; then composer update --no-interaction; fi
35+
- if [[ $PREFER_LOWEST == 1 ]]; then composer update --no-interaction --prefer-lowest --prefer-stable; fi
3636

37-
- if [[ $PREFER_LOWEST != 1 ]]; then composer install --no-interaction; fi
38-
- if [[ $PREFER_LOWEST = 1 ]]; then composer update --no-interaction --prefer-lowest --prefer-stable; fi
37+
- if [[ $DB == 'mysql' ]]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi
38+
- if [[ $DB == 'pgsql' ]]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi
3939

40-
- if [[ $DB = 'mysql' ]]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi
41-
- if [[ $DB = 'pgsql' ]]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi
42-
43-
- if [[ $PHPCS = '1' ]]; then composer require cakephp/cakephp-codesniffer; fi
40+
- if [[ $PHPCS == 1 ]]; then composer require cakephp/cakephp-codesniffer:^4.0; fi
41+
- if [[ $STATIC_ANALYSIS == 1 ]]; then composer stan-setup; fi
4442

4543
script:
46-
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi
47-
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.1 ]]; then vendor/bin/phpunit; fi
44+
- |
45+
if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION == 7.2 ]]; then
46+
mkdir -p build/logs
47+
vendor/bin/phpunit --coverage-clover=build/logs/clover.xml
48+
fi
49+
50+
- if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION != 7.2 ]]; then vendor/bin/phpunit; fi
4851

49-
- if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi
52+
- if [[ $PHPCS == 1 ]]; then vendor/bin/phpcs -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi
5053

51-
- if [[ $STATIC_ANALYSIS = 1 ]]; then composer require --dev phpstan/phpstan:^0.11 && vendor/bin/phpstan analyse src; fi
54+
- if [[ $STATIC_ANALYSIS == 1 ]]; then composer stan; fi
5255

5356
after_success:
54-
- if [[ $DEFAULT = 1 && $DB = 'mysql' && $TRAVIS_PHP_VERSION = 7.1 ]]; then bash <(curl -s https://codecov.io/bash); fi
57+
- |
58+
if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION = 7.2 ]]; then
59+
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
60+
chmod +x php-coveralls.phar
61+
./php-coveralls.phar
62+
fi
5563
5664
notifications:
5765
email: false

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ This plugins provides:
1717
- Validation class for auto translating validation message.
1818
- A widget to generate select box with list of timezone identifiers.
1919

20-
## Requirements
21-
22-
* CakePHP 3.0+
23-
2420
## Installation
2521

2622
```
@@ -46,7 +42,7 @@ The `I18nRoutes` helps generating language prefixed routes of style
4642
For e.g. you can add routes to your `routes.php` similar to the ones shown below:
4743

4844
```php
49-
Router::scope('/', function ($routes) {
45+
$routes->scope('/', function ($routes) {
5046
$routes->connect(
5147
'/:controller',
5248
['action' => 'index'],
@@ -79,7 +75,7 @@ inflected accordingly.
7975

8076
### I18nMiddleware
8177

82-
While not necessary one would generally use the `I18nMiddleware` too when using
78+
While not necessary, one would generally use the `I18nMiddleware` too when using
8379
language prefixed routes with the help of `I18nRoute`.
8480

8581
You can setup the `I18nMiddleware` in your `src/Application::middleware()` as
@@ -104,7 +100,8 @@ $middlware->add(new \ADmad\I18n\Middleware\I18nMiddleware([
104100

105101
The keys of `languages` array are the language prefixes you use in your URL.
106102

107-
To ensure that the `lang` router param is available, you must add this middleware *after* adding CakePHP's default routing middleware (i.e. after `->add(new RoutingMiddleware($this))`).
103+
To ensure that the `lang` router param is available, you must add this middleware
104+
*after* adding CakePHP's default routing middleware (i.e. after `->add(new RoutingMiddleware($this))`).
108105

109106
The middleware does basically two things:
110107

@@ -116,7 +113,7 @@ The middleware does basically two things:
116113
you must connect a route for `/` to a controller action. That controller action
117114
will never be actually called as the middleware will intercept and redirect
118115
the request.
119-
116+
120117
For e.g. `$routes->connect('/', ['controller' => 'Foo']);`
121118

122119
2. When accesing any URL with language prefix it set's the app's locale based
@@ -154,12 +151,12 @@ I18n::config('default', function ($domain, $locale) {
154151
});
155152
```
156153

157-
You can use `ADmad/I18n.I18n` shell to extract the translation message from your
154+
You can use `admad/i18n extract` command to extract the translation message from your
158155
code files and populate the translations table. Updating the db records with
159156
translations for each language is upto you.
160157

161158
```
162-
bin/cake ADmad/I18n.i18n extract
159+
bin/cake admad/i18n extract
163160
```
164161

165162
Now you can use the translation funtions like `__()` etc. as you normally would.
@@ -172,7 +169,7 @@ In your `AppView::initialize()` configure the `FormHelper` to use `TimezoneWidge
172169

173170
```php
174171
// src/View/AppView.php
175-
public function initialize()
172+
public function initialize(): void
176173
{
177174
$this->loadHelper('Form', [
178175
'widget' => [

composer.json

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"issues":"https://github.com/ADmad/cakephp-i18n/issues"
2424
},
2525
"require": {
26-
"cakephp/cakephp": "^3.5"
26+
"cakephp/cakephp": "^4.0.2"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^5.7.14|^6.0"
29+
"phpunit/phpunit": "~8.5.0"
3030
},
3131
"autoload": {
3232
"psr-4": {
@@ -35,13 +35,19 @@
3535
},
3636
"autoload-dev": {
3737
"psr-4": {
38-
"ADmad\\I18n\\Test\\": "tests"
38+
"ADmad\\I18n\\Test\\": "tests",
39+
"TestApp\\": "tests/test_app/src",
40+
"TestPlugin\\": "tests/test_app/plugins/TestPlugin/src",
41+
"Company\\TestPluginThree\\": "tests/test_app/plugins/Company/TestPluginThree/src"
3942
}
4043
},
41-
"extra": {
42-
"branch-alias": {
43-
"dev-master": "1.0.x-dev"
44-
}
45-
},
46-
"prefer-stable": true
44+
"scripts": {
45+
"phpstan": "phpstan.phar analyse",
46+
"psalm": "psalm.phar",
47+
"stan": [
48+
"@phpstan",
49+
"@psalm"
50+
],
51+
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 psalm/phar:^3.11.2 && mv composer.backup composer.json"
52+
}
4753
}

phpstan.neon

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
parameters:
2-
level: 3
3-
autoload_files:
4-
- tests/bootstrap.php
5-
ignoreErrors:
6-
- '#Call to an undefined method Cake\\Datasource\\QueryInterface::enableHydration\(\)#'
2+
level: 6
3+
checkMissingIterableValueType: false
4+
checkGenericClassInNonGenericObjectType: false
5+
treatPhpDocTypesAsCertain: false
6+
bootstrapFiles:
7+
- tests/bootstrap.php
8+
paths:
9+
- src
10+
ignoreErrors:
11+
-
12+
message: "#^Parameter \\#1 \\$var_array of function extract is passed by reference, so it expects variables only\\.$#"
13+
count: 1
14+
path: src/Command/I18nExtractCommand.php
15+
16+
-
17+
message: "#^Strict comparison using \\!\\=\\= between null and null will always evaluate to false\\.$#"
18+
count: 2
19+
path: src/Command/I18nExtractCommand.php
20+
21+
-
22+
message: "#^Parameter \\#1 \\$request of method ADmad\\\\I18n\\\\Middleware\\\\I18nMiddleware\\:\\:detectLanguage\\(\\) expects Cake\\\\Http\\\\ServerRequest, Psr\\\\Http\\\\Message\\\\ServerRequestInterface given\\.$#"
23+
count: 1
24+
path: src/Middleware/I18nMiddleware.php

phpunit.xml.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
colors="true"
44
processIsolation="false"
55
stopOnFailure="false"
6-
syntaxCheck="false"
76
bootstrap="./tests/bootstrap.php"
87
>
98
<php>
@@ -32,7 +31,6 @@
3231
<filter>
3332
<whitelist>
3433
<directory suffix=".php">./src/</directory>
35-
<directory suffix=".ctp">./src/</directory>
3634
</whitelist>
3735
</filter>
3836
</phpunit>

0 commit comments

Comments
 (0)