Skip to content

Commit

Permalink
Merge pull request #48 from CakeDC/2.next
Browse files Browse the repository at this point in the history
2.next - Upgraded to CakePHP 4
  • Loading branch information
steinkel authored May 7, 2020
2 parents 35b629f + 3373559 commit 14311b4
Show file tree
Hide file tree
Showing 26 changed files with 665 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .semver
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
:major: 1
:minor: 2
:minor: 5
:patch: 0
:special: ''
:metadata: ''
46 changes: 30 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
language: php

dist: xenial

php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

sudo: false

services:
- postgresql
- mysql

cache:
directories:
- vendor
- $HOME/.composer/cache

env:
matrix:
- DB=mysql db_dsn='mysql://[email protected]/cakephp_test'
- DB=mysql db_dsn='mysql://[email protected]/cakephp_test?init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'
- DB=pgsql db_dsn='postgres://[email protected]/cakephp_test'
- DB=sqlite db_dsn='sqlite:///:memory:'

Expand All @@ -21,25 +30,30 @@ matrix:
fast_finish: true

include:
- php: 5.6
- php: 7.3
env: COVERAGE=1 DEFAULT=0

- php: 7.3
env: PHPCS=1 DEFAULT=0

before_script:
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
- php: 7.3
env: PHPSTAN=1 DEFAULT=0

before_script:
- if [[ $TRAVIS_PHP_VERSION != 7.3 ]]; then phpenv config-rm xdebug.ini; fi
- composer install --prefer-dist --no-interaction

- if [ $DB = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi
- if [ $DB = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi
- if [[ $DB == 'mysql' ]]; then mysql -u root -e 'CREATE DATABASE cakephp_test;'; fi
- if [[ $DB == 'pgsql' ]]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi
- if [[ $PHPSTAN = 1 ]]; then composer stan-setup; fi

script:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi

- if [ '$PHPCS' = '1' ]; then ./vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi
- if [[ $DEFAULT = 1 ]]; then composer test; fi
- if [[ $COVERAGE = 1 ]]; then composer coverage-test; fi
- if [[ $PHPCS = 1 ]]; then composer cs-check; fi
- if [[ $PHPSTAN = 1 ]]; then composer stan; fi

after_success:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi
- if [[ $COVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi

notifications:
email: false
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ Versions and branches

| CakePHP | CakeDC Enum Plugin | Tag | Notes |
| :-------------: | :------------------------: | :--: | :---- |
| ^3.6 | [master](https://github.com/cakedc/enum/tree/master) | 1.4.0 | stable |
| ^3.6 | [develop](https://github.com/cakedc/enum/tree/develop) | - | unstable |
| ^3.7 | [master](https://github.com/cakedc/enum/tree/master) | 1.5.0 | stable |
| ^3.7 | [develop](https://github.com/cakedc/enum/tree/develop) | - | unstable |
| ^3.6 | [master](https://github.com/cakedc/enum/tree/1.4.0) | 1.4.0 | stable |
| 3.1 - 3.5 | | 1.3.0 | stable |


Expand All @@ -24,7 +25,7 @@ Install
Using [Composer](http://getcomposer.org):

```
composer require cakedc/enum:~1.0
composer require cakedc/enum:1.5.0
```

You then need to load the plugin. You can use the shell command:
Expand All @@ -42,8 +43,8 @@ Plugin::load('CakeDC/Enum');
Requirements
------------

* CakePHP 3.1+
* PHP 5.4.16+ Note CakePHP 3.2 requires PHP 5.5 so 5.4 compatibility would be dropped sooner than later...
* CakePHP 3.7+
* PHP 5.6+

Documentation
-------------
Expand All @@ -65,6 +66,6 @@ This repository follows the [CakeDC Plugin Standard](http://cakedc.com/plugin-st
License
-------

Copyright 2015 - 2018 Cake Development Corporation (CakeDC). All rights reserved.
Copyright 2015 - 2019 Cake Development Corporation (CakeDC). All rights reserved.

Licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) License. Redistributions of the source code included in this repository must retain the copyright notice found in each file.
243 changes: 243 additions & 0 deletions clover.xml

Large diffs are not rendered by default.

31 changes: 28 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
"issues": "https://github.com/cakedc/enum/issues",
"source": "https://github.com/cakedc/enum"
},
"require": {
"php": ">=7.2.0",
"cakephp/cakephp": "^4.0.0"
},
"require-dev": {
"cakephp/cakephp": "^3.6.0",
"cakephp/cakephp-codesniffer": "2.*",
"phpunit/phpunit": "<6.0"
"phpunit/phpunit": "^8.5",
"vlucas/phpdotenv": "^3.3",
"cakephp/cakephp-codesniffer": "~4.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -27,5 +31,26 @@
"psr-4": {
"CakeDC\\Enum\\Test\\": "tests"
}
},
"prefer-stable": true,
"minimum-stability": "dev",
"scripts": {
"analyse": [
"@stan",
"@psalm"
],
"check": [
"@cs-check",
"@test",
"@analyse"
],
"cs-check": "phpcs -p --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.7 psalm/phar:~3.8.0 && mv composer.backup composer.json",
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:^0.4.11 && mv composer.backup composer.json",
"coverage-test": "phpunit --stderr --coverage-clover=clover.xml"
}
}
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 4
autoload_files:
- tests/bootstrap.php
126 changes: 126 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
allowCoercionFromStringToClassConst="true"
allowStringToStandInForClass="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<MissingClosureReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor>
</MissingConstructor>
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition>
<errorLevel type="suppress">
</errorLevel>
</RedundantCondition>

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<!-- level 4 issues - points to possible deficiencies in logic, higher false-positives -->

<MoreSpecificReturnType errorLevel="info" />
<LessSpecificReturnStatement errorLevel="info" />
<TypeCoercion errorLevel="info" />

<PossiblyInvalidArrayAccess errorLevel="info" />
<PossiblyInvalidArrayOffset errorLevel="info" />
<PossiblyInvalidFunctionCall errorLevel="info" />
<PossiblyInvalidIterator errorLevel="info" />
<PossiblyInvalidMethodCall errorLevel="info" />
<PossiblyInvalidOperand errorLevel="info" />
<PossiblyInvalidPropertyAssignment errorLevel="info" />
<PossiblyNullArgument errorLevel="info" />
<PossiblyNullArrayAccess errorLevel="info" />
<PossiblyNullArrayAssignment errorLevel="info" />
<PossiblyNullArrayOffset errorLevel="info" />
<PossiblyNullOperand errorLevel="info" />
<PossiblyNullPropertyAssignment errorLevel="info" />
<PossiblyNullPropertyAssignmentValue errorLevel="info" />
<PossiblyNullPropertyFetch errorLevel="info" />
<PossiblyNullReference errorLevel="info" />

<!-- level 5 issues - should be avoided at mosts costs... -->

<InvalidScalarArgument errorLevel="info" />
<InvalidOperand errorLevel="info" />
<NoInterfaceProperties errorLevel="info" />
<TypeDoesNotContainType errorLevel="info" />
<TypeDoesNotContainNull errorLevel="info" />
<ImplementedReturnTypeMismatch errorLevel="info" />

<!-- level 6 issues - really bad things -->

<NullableReturnStatement>
<errorLevel type="suppress">
</errorLevel>
</NullableReturnStatement>

<MoreSpecificImplementedParamType errorLevel="info" />
<LessSpecificImplementedReturnType errorLevel="info" />

<!-- level 7 issues - even worse -->
<InvalidArgument errorLevel="info" />

<InvalidPropertyAssignmentValue>
<errorLevel type="suppress">
</errorLevel>
</InvalidPropertyAssignmentValue>

<!-- CakePHP Specific -->
<DeprecatedClass>
<errorLevel type="suppress">
</errorLevel>
</DeprecatedClass>

<PossiblyUndefinedArrayOffset>
</PossiblyUndefinedArrayOffset>

<UndefinedConstant errorLevel="suppress" />

<UndefinedPropertyAssignment>
</UndefinedPropertyAssignment>

<UndefinedPropertyFetch>
</UndefinedPropertyFetch>

<EmptyArrayAccess>
</EmptyArrayAccess>

<LoopInvalidation>
</LoopInvalidation>

<UndefinedClass>
</UndefinedClass>

<UndefinedMethod>
</UndefinedMethod>

<NullReference>
</NullReference>

<PossiblyUndefinedMethod>
</PossiblyUndefinedMethod>

</issueHandlers>
</psalm>
4 changes: 4 additions & 0 deletions rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# rector.yaml
services:
Rector\Php\Rector\FunctionLike\ParamTypeDeclarationRector: ~
Rector\Php\Rector\FunctionLike\ReturnTypeDeclarationRector: ~
Loading

0 comments on commit 14311b4

Please sign in to comment.