Skip to content

Commit b5600b9

Browse files
committed
initial cakephp4 code migration
1 parent 94269f7 commit b5600b9

File tree

171 files changed

+1492
-1686
lines changed

Some content is hidden

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

171 files changed

+1492
-1686
lines changed

.travis.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
6-
- 7.1
4+
- 7.2
5+
- 7.3
6+
77
sudo: false
88

99
env:
1010
matrix:
1111
- DB=mysql db_dsn='mysql://[email protected]/cakephp_test'
12+
- DB=pgsql db_dsn='postgres://[email protected]/cakephp_test'
1213
- DB=sqlite db_dsn='sqlite:///:memory:'
1314

1415
global:
@@ -18,27 +19,30 @@ matrix:
1819
fast_finish: true
1920

2021
include:
21-
- php: 7.1
22+
- php: 7.3
23+
env: COVERAGE=1 DB=mysql db_dsn='mysql://[email protected]/cakephp_test'
24+
25+
- php: 7.3
2226
env: PHPCS=1 DEFAULT=0
2327

24-
- php: 7.1
25-
env: CODECOVERAGE=1 DEFAULT=0 DB=mysql db_dsn='mysql://[email protected]/cakephp_test'
28+
- php: 7.3
29+
env: PHPSTAN=1 DEFAULT=0
2630

2731
before_script:
2832
- composer self-update
2933
- composer install --prefer-dist --no-interaction
30-
31-
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
32-
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi"
33-
34-
- sh -c "if [ '$PHPCS' = '1' ]; then composer require cakephp/cakephp-codesniffer:dev-master; fi"
34+
- if [ $DB = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi
35+
- if [ $DB = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi
36+
- if [[ $PHPSTAN = 1 ]]; then composer stan-setup; fi
3537

3638
script:
37-
- sh -c "if [ '$DEFAULT' = '1' ]; then ./vendor/bin/phpunit --stderr; fi"
38-
- sh -c "if [ '$PHPCS' = '1' ]; then ./vendor/bin/phpcs -p -n --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi"
39-
- sh -c "if [ '$CODECOVERAGE' = '1' ]; then phpunit --coverage-clover=clover.xml || true; fi"
40-
- sh -c "if [ '$CODECOVERAGE' = '1' ]; then wget -O codecov.sh https://codecov.io/bash; fi"
41-
- sh -c "if [ '$CODECOVERAGE' = '1' ]; then bash codecov.sh; fi"
42-
39+
- if [[ $DEFAULT = 1 ]]; then composer test; fi
40+
- if [[ $COVERAGE = 1 ]]; then composer coverage-test; fi
41+
- if [[ $PHPCS = 1 ]]; then composer cs-check; fi
42+
- if [[ $PHPSTAN = 1 ]]; then composer stan; fi
43+
44+
after_success:
45+
- if [[ $COVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi
46+
4347
notifications:
4448
email: false

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright 2009-2016
3+
Copyright 2009-2019
44
Cake Development Corporation
55
1785 E. Sahara Avenue, Suite 490-423
66
Las Vegas, Nevada 89104

composer.json

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727
"source": "https://github.com/CakeDC/cakephp-api"
2828
},
2929
"require": {
30-
"php": ">=5.6",
31-
"cakephp/cakephp": "^3.7",
32-
"cakedc/users": "^8.0"
30+
"php": ">=7.2",
31+
"ext-json": "*",
32+
"cakephp/cakephp": "4.x-dev as 4.0.0",
33+
"cakedc/users": "9.next-dev",
34+
"firebase/php-jwt": "^5.0"
3335
},
3436
"require-dev": {
35-
"phpunit/phpunit": "^6",
36-
"league/flysystem-vfs": "^1.0"
37+
"phpunit/phpunit": "^8.0",
38+
"league/flysystem-vfs": "^1.0",
39+
"vlucas/phpdotenv": "^3.3",
40+
"cakephp/cakephp-codesniffer": "dev-next"
3741
},
3842
"autoload": {
3943
"psr-4": {
@@ -46,5 +50,25 @@
4650
"CakeDC\\Api\\Test\\": "tests",
4751
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
4852
}
53+
},
54+
"prefer-stable": true,
55+
"minimum-stability": "dev",
56+
"config": {
57+
"sort-packages": true
58+
},
59+
"scripts": {
60+
"check": [
61+
"@cs-check",
62+
"@test",
63+
"@stan"
64+
],
65+
"cs-check": "phpcs -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
66+
"cs-fix": "phpcbf --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
67+
"test": "phpunit --stderr",
68+
"stan": "phpstan analyse src/ && psalm --show-info=false",
69+
"psalm": "psalm --show-info=false",
70+
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.11 vimeo/psalm:^3.0 && mv composer.backup composer.json",
71+
"rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:^0.4.11 && mv composer.backup composer.json",
72+
"coverage-test": "phpunit --stderr --coverage-clover=clover.xml"
4973
}
5074
}

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 4
3+
autoload_files:
4+
- tests/bootstrap.php

phpunit.xml.dist

Lines changed: 0 additions & 8 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>
@@ -31,13 +30,6 @@
3130

3231
<!-- Prevent coverage reports from looking in tests and vendors -->
3332
<filter>
34-
<blacklist>
35-
<directory suffix=".php">./vendor/</directory>
36-
<directory suffix=".ctp">./vendor/</directory>
37-
38-
<directory suffix=".php">./tests/</directory>
39-
<directory suffix=".ctp">./tests/</directory>
40-
</blacklist>
4133
<whitelist processUncoveredFilesFromWhitelist="true">
4234
<directory suffix=".php">./src</directory>
4335
</whitelist>

psalm.xml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
totallyTyped="false"
4+
allowCoercionFromStringToClassConst="true"
5+
allowStringToStandInForClass="true"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xmlns="https://getpsalm.org/schema/config"
8+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
9+
>
10+
<projectFiles>
11+
<directory name="src" />
12+
<ignoreFiles>
13+
</ignoreFiles>
14+
</projectFiles>
15+
16+
<issueHandlers>
17+
<LessSpecificReturnType errorLevel="info" />
18+
19+
<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
20+
21+
<MissingClosureReturnType errorLevel="info" />
22+
<MissingPropertyType errorLevel="info" />
23+
24+
<PropertyNotSetInConstructor errorLevel="info" />
25+
<MissingConstructor>
26+
</MissingConstructor>
27+
<MissingClosureParamType errorLevel="info" />
28+
<MissingParamType errorLevel="info" />
29+
30+
<RedundantCondition>
31+
<errorLevel type="suppress">
32+
</errorLevel>
33+
</RedundantCondition>
34+
35+
<DocblockTypeContradiction errorLevel="info" />
36+
<RedundantConditionGivenDocblockType errorLevel="info" />
37+
38+
<UnresolvableInclude errorLevel="info" />
39+
40+
<!-- level 4 issues - points to possible deficiencies in logic, higher false-positives -->
41+
42+
<MoreSpecificReturnType errorLevel="info" />
43+
<LessSpecificReturnStatement errorLevel="info" />
44+
<TypeCoercion errorLevel="info" />
45+
46+
<PossiblyInvalidArrayAccess errorLevel="info" />
47+
<PossiblyInvalidArrayOffset errorLevel="info" />
48+
<PossiblyInvalidFunctionCall errorLevel="info" />
49+
<PossiblyInvalidIterator errorLevel="info" />
50+
<PossiblyInvalidMethodCall errorLevel="info" />
51+
<PossiblyInvalidOperand errorLevel="info" />
52+
<PossiblyInvalidPropertyAssignment errorLevel="info" />
53+
<PossiblyNullArgument errorLevel="info" />
54+
<PossiblyNullArrayAccess errorLevel="info" />
55+
<PossiblyNullArrayAssignment errorLevel="info" />
56+
<PossiblyNullArrayOffset errorLevel="info" />
57+
<PossiblyNullOperand errorLevel="info" />
58+
<PossiblyNullPropertyAssignment errorLevel="info" />
59+
<PossiblyNullPropertyAssignmentValue errorLevel="info" />
60+
<PossiblyNullPropertyFetch errorLevel="info" />
61+
<PossiblyNullReference errorLevel="info" />
62+
63+
<!-- level 5 issues - should be avoided at mosts costs... -->
64+
65+
<InvalidScalarArgument errorLevel="info" />
66+
<InvalidOperand errorLevel="info" />
67+
<NoInterfaceProperties errorLevel="info" />
68+
<TypeDoesNotContainType errorLevel="info" />
69+
<TypeDoesNotContainNull errorLevel="info" />
70+
<ImplementedReturnTypeMismatch errorLevel="info" />
71+
72+
<!-- level 6 issues - really bad things -->
73+
74+
<NullableReturnStatement>
75+
<errorLevel type="suppress">
76+
</errorLevel>
77+
</NullableReturnStatement>
78+
79+
<MoreSpecificImplementedParamType errorLevel="info" />
80+
<LessSpecificImplementedReturnType errorLevel="info" />
81+
82+
<!-- level 7 issues - even worse -->
83+
<InvalidArgument errorLevel="info" />
84+
85+
<InvalidPropertyAssignmentValue>
86+
<errorLevel type="suppress">
87+
</errorLevel>
88+
</InvalidPropertyAssignmentValue>
89+
90+
<!-- CakePHP Specific -->
91+
<DeprecatedClass>
92+
<errorLevel type="suppress">
93+
</errorLevel>
94+
</DeprecatedClass>
95+
96+
<PossiblyUndefinedArrayOffset>
97+
</PossiblyUndefinedArrayOffset>
98+
99+
<UndefinedConstant errorLevel="suppress" />
100+
101+
<UndefinedPropertyAssignment>
102+
</UndefinedPropertyAssignment>
103+
104+
<UndefinedPropertyFetch>
105+
</UndefinedPropertyFetch>
106+
107+
<EmptyArrayAccess>
108+
</EmptyArrayAccess>
109+
110+
<LoopInvalidation>
111+
</LoopInvalidation>
112+
113+
<UndefinedClass>
114+
</UndefinedClass>
115+
116+
<UndefinedMethod>
117+
</UndefinedMethod>
118+
119+
<NullReference>
120+
</NullReference>
121+
122+
<PossiblyUndefinedMethod>
123+
</PossiblyUndefinedMethod>
124+
125+
</issueHandlers>
126+
</psalm>

rector.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# rector.yaml
2+
services:
3+
Rector\Php\Rector\FunctionLike\ParamTypeDeclarationRector: ~
4+
Rector\Php\Rector\FunctionLike\ReturnTypeDeclarationRector: ~

src/Collection.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
3-
* Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
5+
* Copyright 2016 - 2019, Cake Development Corporation (http://cakedc.com)
46
*
57
* Licensed under The MIT License
68
* Redistributions of files must retain the above copyright notice.
79
*
8-
* @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
10+
* @copyright Copyright 2016 - 2019, Cake Development Corporation (http://cakedc.com)
911
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1012
*/
1113

@@ -31,6 +33,7 @@ abstract class Collection extends ObjectRegistry implements IteratorAggregate
3133
* Constructor
3234
*
3335
* @param array $config Configuration
36+
* @throws \Exception
3437
*/
3538
public function __construct(array $config = [])
3639
{
@@ -50,7 +53,7 @@ public function __construct(array $config = [])
5053
*
5154
* @return bool
5255
*/
53-
public function isEmpty()
56+
public function isEmpty(): bool
5457
{
5558
return empty($this->_loaded);
5659
}
@@ -60,7 +63,7 @@ public function isEmpty()
6063
*
6164
* @return \ArrayIterator
6265
*/
63-
public function getIterator()
66+
public function getIterator(): ArrayIterator
6467
{
6568
return new ArrayIterator($this->_loaded);
6669
}

0 commit comments

Comments
 (0)