Skip to content

Commit

Permalink
Merge pull request #196 from cakephp/CakeDC-3.x
Browse files Browse the repository at this point in the history
CakeDC Cake 4 prep
  • Loading branch information
dereuromark authored Apr 2, 2020
2 parents c35170c + 045bb04 commit 4f5017a
Show file tree
Hide file tree
Showing 109 changed files with 739 additions and 541 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
language: php

php:
- 5.6
- 7.2
- 7.4

env:
global:
- DEFAULT=1

matrix:
fast_finish: true

include:
- php: 7.4
env: PHPCS=1
env: CHECKS=1 DEFAULT=0

- php: 5.6
- php: 7.2
env: PREFER_LOWEST=1

install:
- if [[ $PREFER_LOWEST != 1 ]]; then composer install --prefer-dist --no-interaction ; fi
- if [[ $PREFER_LOWEST == 1 ]]; then composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable ; fi

script:
- sh -c "if [ '$PHPCS' != '1' ]; then vendor/bin/phpunit; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then ./vendor/bin/phpcs -n -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/; fi"
- if [[ $DEFAULT == 1 ]]; then vendor/bin/phpunit; fi
- if [[ $CHECKS == 1 ]]; then composer stan-setup && composer stan ; fi
- if [[ $CHECKS == 1 ]]; then composer cs-check ; fi

cache:
directories:
Expand Down
30 changes: 26 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"source": "https://github.com/cakephp/localized"
},
"require": {
"php": ">=5.6",
"cakephp/cakephp": "^3.5"
"php": ">=7.2",
"cakephp/cakephp": "^4.0.0"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^3.0",
"phpunit/phpunit": "^4.8|^5.7|^6.0"
"cakephp/cakephp-codesniffer": "^4.0",
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
Expand All @@ -35,5 +35,27 @@
"Cake\\Test\\": "vendor/cakephp/cakephp/tests",
"Cake\\Localized\\Test\\": "tests"
}
},
"scripts": {
"check": [
"@cs-check",
"@test",
"@analyse"
],
"analyse": [
"@stan",
"@psalm"
],
"cs-check": "phpcs -p -n --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
"cs-fix": "phpcbf --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
"test": "phpunit --stderr",
"stan": "phpstan analyse src/",
"psalm": "php vendor/psalm/phar/psalm.phar --show-info=false src/",
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12.0 psalm/phar:^3.7 && mv composer.backup composer.json",
"stan-rebuild-baseline": "phpstan analyse --configuration phpstan.neon --error-format baselineNeon src/ > phpstan-baseline.neon",
"psalm-rebuild-baseline": "php vendor/psalm/phar/psalm.phar --show-info=false --set-baseline=psalm-baseline.xml src/",
"rector": "rector process src/",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:^0.7 && mv composer.backup composer.json",
"coverage-test": "phpunit --stderr --coverage-clover=clover.xml"
}
}
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 1
treatPhpDocTypesAsCertain: false
autoload_files:
- tests/bootstrap.php
11 changes: 0 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
Expand All @@ -18,15 +17,5 @@
</testsuite>
</testsuites>

<!-- Prevent coverage reports from looking in tests and vendors -->
<filter>
<blacklist>
<directory suffix=".php">./vendor/</directory>
<directory suffix=".ctp">./vendor/</directory>

<directory suffix=".php">./tests/</directory>
<directory suffix=".ctp">./tests/</directory>
</blacklist>
</filter>

</phpunit>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
49 changes: 49 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);

/**
* Localized Plugin class.
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org
* @since Localized Plugin v 0.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Localized;

use Cake\Core\BasePlugin;

class Plugin extends BasePlugin
{
/**
* Plugin name.
*
* @var string
*/
protected $name = 'Localized';

/**
* @var bool
*/
protected $routesEnabled = false;

/**
* @var bool
*/
protected $bootstrapEnabled = false;
/**
* @var bool
*/
protected $consoleEnabled = false;

/**
* @var bool
*/
protected $middlewareEnabled = false;
}
24 changes: 13 additions & 11 deletions src/Validation/AtValidation.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* Austrian Localized Validation class. Handles localized validation for Austria.
*
Expand All @@ -8,14 +10,14 @@
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org
* @since Localized Plugin v 0.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org
* @since Localized Plugin v 0.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Localized\Validation;

use Cake\Network\Exception\NotImplementedException;
use Cake\Http\Exception\NotImplementedException;

/**
* AtValidation
Expand All @@ -29,9 +31,9 @@ class AtValidation extends LocalizedValidation
* @param string $check The value to check.
* @return bool Success.
*/
public static function postal($check)
public static function postal(string $check): bool
{
$pattern = '/^[0-9]{4}$/';
$pattern = '/^\d{4}$/';

return (bool)preg_match($pattern, $check);
}
Expand All @@ -40,10 +42,10 @@ public static function postal($check)
* Checks a phone number.
*
* @param string $check The value to check.
* @throws NotImplementedException Exception
* @throws \Cake\Http\Exception\NotImplementedException Exception
* @return bool Success.
*/
public static function phone($check)
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
}
Expand All @@ -52,10 +54,10 @@ public static function phone($check)
* Checks a country specific identification number.
*
* @param string $check The value to check.
* @throws NotImplementedException Exception
* @throws \Cake\Http\Exception\NotImplementedException Exception
* @return bool Success.
*/
public static function personId($check)
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
}
Expand Down
22 changes: 12 additions & 10 deletions src/Validation/AuValidation.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* Australian Localised Validation class. Handles localised validation for Australia.
*
Expand All @@ -8,14 +10,14 @@
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org
* @since Localized Plugin v 0.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org
* @since Localized Plugin v 0.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Localized\Validation;

use Cake\Network\Exception\NotImplementedException;
use Cake\Http\Exception\NotImplementedException;

/**
* AuValidation
Expand All @@ -29,9 +31,9 @@ class AuValidation extends LocalizedValidation
* @param string $check The value to check.
* @return bool Success.
*/
public static function postal($check)
public static function postal(string $check): bool
{
$pattern = '/^[0-9]{4}$/';
$pattern = '/^\d{4}$/';

return (bool)preg_match($pattern, $check);
}
Expand All @@ -42,7 +44,7 @@ public static function postal($check)
* @param string $check The value to check.
* @return bool Success.
*/
public static function phone($check)
public static function phone(string $check): bool
{
$normalized = preg_replace('/(\s+|-|\(|\))/', '', preg_replace('/0011\s?61/', '+61', $check)); //remove spaces, parentheses and hyphens, convert full intl prefix.
$pattern = '/^(((0|\+61)[2378])(\d){8}|((0|\+61)[45](\d){2}|1300|1800|190[02])(\d){6}|(\+61)?180(\d){4}|(\+61)?13\d{4}|(\+61)?12[2-8](\d){1,7}|(\+61|0)14[12357](\d){6})$/';
Expand All @@ -54,10 +56,10 @@ public static function phone($check)
* Checks an identification number.
*
* @param string $check The value to check.
* @throws NotImplementedException Exception
* @throws \Cake\Http\Exception\NotImplementedException Exception
* @return bool Success.
*/
public static function personId($check)
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
}
Expand Down
22 changes: 12 additions & 10 deletions src/Validation/BdValidation.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

/**
* BD Localized Validation class. Handles localized validation for Bangladesh.
*
Expand All @@ -8,14 +10,14 @@
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org
* @since Localized Plugin v 0.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org
* @since Localized Plugin v 0.1
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Localized\Validation;

use Cake\Network\Exception\NotImplementedException;
use Cake\Http\Exception\NotImplementedException;

/**
* BdValidation
Expand All @@ -29,7 +31,7 @@ class BdValidation extends LocalizedValidation
* @param string $check The value to check.
* @return bool Success.
*/
public static function postal($check)
public static function postal(string $check): bool
{
$pattern = '/^\d{4}$/';

Expand All @@ -40,10 +42,10 @@ public static function postal($check)
* Checks a phone number.
*
* @param string $check The value to check.
* @throws NotImplementedException Exception
* @throws \Cake\Http\Exception\NotImplementedException Exception
* @return bool Success.
*/
public static function phone($check)
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
}
Expand All @@ -52,10 +54,10 @@ public static function phone($check)
* Checks a country specific identification number.
*
* @param string $check The value to check.
* @throws NotImplementedException Exception
* @throws \Cake\Http\Exception\NotImplementedException Exception
* @return bool Success.
*/
public static function personId($check)
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
}
Expand Down
Loading

0 comments on commit 4f5017a

Please sign in to comment.