Skip to content

Commit 529841c

Browse files
authored
Merge pull request #7 from UseMuffin/dev
Dev
2 parents 91c862a + 370cbe5 commit 529841c

23 files changed

+253
-131
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.editorconfig export-ignore
33
.gitattributes export-ignore
44
.gitignore export-ignore
5-
.semver export-ignore
65
phpunit.xml.dist export-ignore
76
.travis.yml export-ignore
87
tests export-ignore
8+
phpstan.neon

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
/composer.lock
22
/plugins
33
/vendor
4+
/tmp
5+
/phpcs.xml
6+
/phpunit.xml

.semver

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

.travis.yml

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

33
php:
4-
- 5.4
5-
- 5.5
64
- 5.6
7-
- 7
5+
- 7.2
6+
- 7.4
87

9-
sudo: false
8+
services:
9+
- mysql
10+
- postgresql
1011

1112
env:
1213
matrix:
13-
- DB=mysql db_dsn='mysql://travis@0.0.0.0/cakephp_test'
14+
- DB=mysql db_dsn='mysql://root@127.0.0.1/cakephp_test'
1415
- DB=pgsql db_dsn='postgres://postgres@127.0.0.1/cakephp_test'
1516
- DB=sqlite db_dsn='sqlite:///:memory:'
1617

@@ -21,29 +22,36 @@ matrix:
2122
fast_finish: true
2223

2324
include:
24-
- php: 5.4
25+
- php: 7.1
2526
env: PHPCS=1 DEFAULT=0
2627

27-
- php: 5.4
28-
env: COVERALLS=1 DEFAULT=0 DB=mysql db_dsn='mysql://travis@0.0.0.0/cakephp_test'
28+
- php: 7.1
29+
env: PHPSTAN=1 DEFAULT=0
30+
31+
- php: 5.6
32+
env: PREFER_LOWEST=1
2933

3034
before_script:
31-
- composer self-update
32-
- composer install --prefer-dist --no-interaction
35+
- if [[ $TRAVIS_PHP_VERSION != 7.4 ]]; then phpenv config-rm xdebug.ini; fi
3336

34-
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
35-
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; 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
3639

37-
- sh -c "if [ '$PHPCS' = '1' ]; then composer require cakephp/cakephp-codesniffer:dev-master; fi"
40+
- if [[ $PREFER_LOWEST != 1 ]]; then composer update --no-interaction; fi
41+
- if [[ $PREFER_LOWEST == 1 ]]; then composer update --no-interaction --prefer-lowest --prefer-stable; fi
3842

39-
- sh -c "if [ '$COVERALLS' = '1' ]; then composer require --dev satooshi/php-coveralls:dev-master; fi"
40-
- sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi"
43+
- if [[ $PHPCS == 1 ]]; then composer require cakephp/cakephp-codesniffer:"^3.0"; fi
4144

4245
script:
43-
- sh -c "if [ '$DEFAULT' = '1' ]; then phpunit --stderr; fi"
44-
- sh -c "if [ '$PHPCS' = '1' ]; then ./vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi"
45-
- sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --stderr --coverage-clover build/logs/clover.xml; fi"
46-
- sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi"
46+
- if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION != 7.4 ]]; then vendor/bin/phpunit; fi
47+
- if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION == 7.4 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi
48+
49+
- if [[ $PHPCS == 1 ]]; then vendor/bin/phpcs -n -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi
50+
51+
- if [[ $PHPSTAN == 1 ]]; then composer require --dev phpstan/phpstan:^0.12 && vendor/bin/phpstan analyse src; fi
52+
53+
after_success:
54+
- if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION == 7.4 ]]; then bash <(curl -s https://codecov.io/bash); fi
4755

4856
notifications:
4957
email: false

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015 Use Muffin
1+
Copyright (c) 2015-Present Use Muffin
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
[![Total Downloads](https://img.shields.io/packagist/dt/muffin/sti.svg?style=flat-square)](https://packagist.org/packages/muffin/sti)
66
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
77

8-
Single Table Inheritance for CakePHP 3 ORM.
8+
Single Table Inheritance for CakePHP ORM.
99

10-
> [...] a way to emulate object-oriented inheritance in a relational database. When mapping from a database
11-
> table to an object in an object-oriented language, a field in the database identifies what class in the
10+
> [...] a way to emulate object-oriented inheritance in a relational database. When mapping from a database
11+
> table to an object in an object-oriented language, a field in the database identifies what class in the
1212
> hierarchy the object belongs to.
1313
1414
(source: [Wikipedia][1])
@@ -18,21 +18,15 @@ Single Table Inheritance for CakePHP 3 ORM.
1818
Using [Composer][composer]:
1919

2020
```
21-
composer require muffin/sti:1.0.x-dev
21+
composer require muffin/sti
2222
```
2323

24-
You then need to load the plugin. You can use the shell command:
24+
You then need to load the plugin. You can use the console command:
2525

2626
```
2727
bin/cake plugin load Muffin/Sti
2828
```
2929

30-
or by manually adding statement shown below to `bootstrap.php`:
31-
32-
```php
33-
Plugin::load('Muffin/Sti');
34-
```
35-
3630
## Usage
3731

3832
```php
@@ -41,8 +35,8 @@ namespace App\Model\Table;
4135

4236
use Cake\ORM\Table;
4337

44-
class CooksTable extends Table {
45-
38+
class CooksTable extends Table
39+
{
4640
public function initialize($config)
4741
{
4842
$this->table('sti_cooks');
@@ -56,7 +50,7 @@ class CooksTable extends Table {
5650

5751
// Optionally, set the default type. If none is defined, the
5852
// first one (i.e. `chef`) will be used.
59-
$this->entityClass('App\Model\Entity\AssistantChef');
53+
$this->setEntityClass('App\Model\Entity\AssistantChef');
6054
}
6155
}
6256
```
@@ -69,7 +63,7 @@ Then create a class for every type of entity:
6963

7064
The entity that was previously defined to be the 'default' one will need to use the `StiAwareTrait`:
7165

72-
```
66+
```php
7367
<?php // src/Model/Entity/AssistantChef.php
7468
namespace App\Model\Entity;
7569

@@ -88,7 +82,7 @@ Optionally, you can create classes for your tables that extend the parent table
8882
<?php // src/Model/Table/ChefsTable.php
8983
namespace App\Model\Table;
9084

91-
class ChefsTable extends CooksTable
85+
class ChefsTable extends CooksTable
9286
{
9387
// ...
9488
}
@@ -107,25 +101,25 @@ public function validationChefs(Validator $validator)
107101
```
108102

109103
### New entities
110-
111-
The behavior will automatically add helper methods for creating entities of different types
104+
105+
The behavior will automatically add helper methods for creating entities of different types
112106
(i.e. `newChef()`). There are different ways of creating new entities, all are valid and depending
113107
on the cases, you might need one or the other:
114-
108+
115109
```php
116110
// using the parent table
117111
$cooks->newChef([...]);
118-
112+
119113
// or, using the parent table again
120114
$cooks->newEntity(['type' => 'chef', ...]);
121-
115+
122116
// or, using the child table
123117
$chefs->newEntity([...]);
124118
```
125119

126120
### Note
127121

128-
For the above examples to work using (*chef), you need to add a custom rule to the `Inflector`:
122+
For the above examples to work using (*chef), you need to add a custom rule to the `Inflector`:
129123

130124
```php
131125
Cake\Utility\Inflector::rules('plural', ['/chef$/i' => '\1Chefs']);
@@ -148,7 +142,7 @@ http://github.com/usemuffin/sti/issues
148142

149143
## License
150144

151-
Copyright (c) 2015, [Use Muffin][muffin] and licensed under [The MIT License][mit].
145+
Copyright (c) 2015-Present, [Use Muffin][muffin] and licensed under [The MIT License][mit].
152146

153147
[cakephp]:http://cakephp.org
154148
[composer]:http://getcomposer.org

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

composer.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "muffin/sti",
3-
"description": "Single Table Inheritance for CakePHP 3 ORM",
3+
"description": "Single Table Inheritance for CakePHP ORM",
44
"type": "cakephp-plugin",
55
"keywords": [
66
"cakephp",
@@ -30,11 +30,12 @@
3030
"source": "https://github.com/usemuffin/sti"
3131
},
3232
"require": {
33+
"php": ">=5.6",
34+
"cakephp/cakephp": "^3.6"
3335
},
3436
"require-dev": {
35-
"cakephp/cakephp": "~3.0",
36-
"cakephp/cakephp-codesniffer": "2.*",
37-
"phpunit/phpunit": "4.1.*"
37+
"cakephp/cakephp-codesniffer": "^3.0",
38+
"phpunit/phpunit": "^5.7.14|^6.0"
3839
},
3940
"autoload": {
4041
"psr-4": {
@@ -46,10 +47,5 @@
4647
"Muffin\\Sti\\Test\\": "tests",
4748
"Muffin\\Sti\\TestApp\\": "tests/test_app"
4849
}
49-
},
50-
"extra": {
51-
"branch-alias": {
52-
"dev-master": "1.0.x-dev"
53-
}
5450
}
5551
}

phpstan.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: 6
3+
checkGenericClassInNonGenericObjectType: false
4+
checkMissingIterableValueType: false
5+
ignoreErrors:
6+

phpunit.xml.dist

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
3-
bootstrap="./tests/bootstrap.php"
43
colors="true"
4+
processIsolation="false"
55
stopOnFailure="false"
6+
syntaxCheck="false"
7+
bootstrap="./tests/bootstrap.php"
68
>
9+
<php>
10+
<ini name="memory_limit" value="-1"/>
11+
</php>
712

813
<testsuites>
9-
<testsuite name="{{pluginName}} Test Cases">
10-
<directory>./tests/</directory>
14+
<testsuite name="Sti TestSuite">
15+
<directory>./tests/TestCase</directory>
1116
</testsuite>
1217
</testsuites>
1318

@@ -22,14 +27,9 @@
2227
</listener>
2328
</listeners>
2429

25-
<!-- Prevent coverage reports from looking in tests and vendors -->
2630
<filter>
27-
<blacklist>
28-
<directory suffix=".php">./vendor/</directory>
29-
<directory suffix=".ctp">./vendor/</directory>
30-
31-
<directory suffix=".php">./tests/</directory>
32-
<directory suffix=".ctp">./tests/</directory>
33-
</blacklist>
31+
<whitelist>
32+
<directory suffix=".php">./src/</directory>
33+
</whitelist>
3434
</filter>
3535
</phpunit>

0 commit comments

Comments
 (0)