Skip to content

Releases: dereuromark/cakephp-shim

2.0.0

14 Jan 23:56
Compare
Choose a tag to compare

CakePHP 4 release

The tool to help ease migration coming from CakePHP 3.x apps.

  • Shim Up: With CakePHP 3.x core and some of the shims, you can prepare your app already for 4.x.
  • Shim Down: Then, once upgraded, with 4.x core and some more shims you can further minimize required changes until the app works again.

Then you can slowly start refactoring again further while the app is already running again.

Contribute

Feel free to contribute more shims to either CakePHP 3.x or 4.x version branch.

2.0.0-beta

27 Dec 21:38
Compare
Choose a tag to compare

CakePHP 4 compatible pre-release.

Please help to finalize for stable release.

0.7.2

06 Dec 13:05
Compare
Choose a tag to compare

Improvements

CakePHP 2.x maintenance release.

  • backward compatibility access to the request object properties
  • FormHelper::input() and FormHelper::inputs() FC shims
  • TranslateShimBehavior
  • TreeShimBehavior updates

1.10.1

05 Dec 20:34
Compare
Choose a tag to compare

Improvements

FC Inflector shim

An Inflector backport has been added as an opt-in replacement for the core one.
Its Inflector::pluralize() already uses new 4.x behavior:

  • pluralize(): index => indexes (instead of indices)

You can also configure the core one with custom inflections from your bootstrap, though.

1.10.0

14 Aug 16:31
Compare
Choose a tag to compare

Improvements

  • Customizable deprecation output (use your own E_USER_* type if needed).
  • Enabling deprecations is now easier by Configure key Shim.deprecations set to true. You can also silence specific deprecations.
  • Added 4.x FC shim + deprecation for newEntity() vs newEmptyEntity().
  • Added 4.x FC shims for BoolType, DecimalType, StringType ORM type handling classes.
  • Removed deprecations for 3.7+.

1.9.0

31 Jul 07:11
6a65d1a
Compare
Choose a tag to compare

Improvements

Add more 4.x shims:

  • Controller::referer() now defaults to true for internal referer only (as per 4.x default).

1.8.3

12 Jun 15:52
Compare
Choose a tag to compare

Improvements

Allow CastTrait to handle empty strings.
This is mainly important when handling request data in controller, as they can be empty strings coming from either data or query.

1.8.2

12 May 17:17
Compare
Choose a tag to compare

Improvements

Add CastTrait

This is useful if you want to get your CakePHP 3 plugins to PHPStan level 7 on controller level, as the query input needs to be properly asserted/cast depending on if it is optional or required input (nullable or not).

1.8.1

08 May 09:19
82bf3cc
Compare
Choose a tag to compare

Improvements

Add read() method for entities to allow dot syntax convenience access.
$entity->read('tags.0.name') will return the property if it exists or returns null otherwise.

This compliments the getOrFail() part which does the opposite (guarantees the path to be present).

1.8.0

06 May 13:00
51854ab
Compare
Choose a tag to compare

Improvements

Allow adding get...OrFail() methods to Entity classes to have non-nullable return values asserted.
This is needed for chaining, as null-pointer-occurrences should be avoided here.

Just use the trait here:

use Shim\Model\Entity\GetTrait;

class Post extends Entity {

	use GetTrait;

        ...

}

It automatically provides the getters here for you.

// bad (tag could be null)
$tagName = $entity->tag->name;

// good (tag cannot be null as this would throw clear exception)
$tagName = $entity->getOrFail('tag')->name;

This will please both analyzers and IDE as well as throw meaningful exceptions in case the field is not set in the entity as expected in this particular case.

For all nullable cases you can still use the normal property access, of course.

Pro tip: Use the included IdeHelper EntityAnnotator replacement to allow annotations to be added for all of your entities' fields.

/**
 * @property int $id
 * @property string $title
 * @property \Cake\I18n\FrozenTime|null $created
 * @property \Tags\Model\Entity\Tag|null $tag
 * @method int getIdOrFail()
 * @method string getTitleOrFail()
 * @method \Cake\I18n\FrozenTime getCreatedOrFail()
 * @method \Tags\Model\Entity\Tag getTagOrFail()
 */
class Post extends Entity {
    ...
}