Skip to content

Commit

Permalink
Merge pull request #549 from FriendsOfCake/php-72
Browse files Browse the repository at this point in the history
Rename "Object" to "BaseObject" for PHP 7.2 compatibility.
  • Loading branch information
ADmad authored Aug 30, 2017
2 parents df80c0f + de1f1b6 commit ae533de
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 72 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ php:
- 5.6
- 7.0
- 7.1
- 7.2

sudo: false

Expand All @@ -27,7 +28,7 @@ matrix:
env: PHPSTAN=1 DEFAULT=0

before_script:
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
- if [[ $TRAVIS_PHP_VERSION != 7.0 && $TRAVIS_PHP_VERSION != 7.2 ]]; then phpenv config-rm xdebug.ini; fi

- if [[ $TRAVIS_PHP_VERSION = 5.5 ]]; then composer require --dev friendsofcake/search:^3.0; fi
- if [[ $TRAVIS_PHP_VERSION != 5.5 ]]; then composer install --prefer-dist --no-interaction; fi
Expand Down
4 changes: 2 additions & 2 deletions src/Action/BaseAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
use Cake\Utility\Text;
use Crud\Core\Object;
use Crud\Core\BaseObject;
use Crud\Event\Subject;

/**
Expand All @@ -15,7 +15,7 @@
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
*/
abstract class BaseAction extends Object
abstract class BaseAction extends BaseObject
{

/**
Expand Down
69 changes: 69 additions & 0 deletions src/Core/BaseObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
namespace Crud\Core;

use Cake\Controller\Controller;
use Cake\Core\InstanceConfigTrait;
use Cake\Event\EventListenerInterface;

/**
* Crud Base Class
*
* Implement base methods used in CrudAction and CrudListener classes
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
*/
abstract class BaseObject implements EventListenerInterface
{

use InstanceConfigTrait;
use ProxyTrait;

/**
* Container with reference to all objects
* needed within the CrudListener and CrudAction
*
* @var \Cake\Controller\Controller
*/
protected $_controller;

/**
* Default configuration
*
* @var array
*/
protected $_defaultConfig = [];

/**
* Constructor
*
* @param \Cake\Controller\Controller $Controller Controller instance
* @param array $config Default settings
*/
public function __construct(Controller $Controller, $config = [])
{
$this->_controller = $Controller;
$this->config($config);
}

/**
* List of implemented events
*
* @return array
*/
public function implementedEvents()
{
return [];
}

/**
* Convenient method for Request::is
*
* @param string|array $method Method(s) to check for
* @return bool
*/
protected function _checkRequestType($method)
{
return $this->_request()->is($method);
}
}
70 changes: 3 additions & 67 deletions src/Core/Object.php
Original file line number Diff line number Diff line change
@@ -1,69 +1,5 @@
<?php
namespace Crud\Core;

use Cake\Controller\Controller;
use Cake\Core\InstanceConfigTrait;
use Cake\Event\EventListenerInterface;

/**
* Crud Base Class
*
* Implement base methods used in CrudAction and CrudListener classes
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
*/
abstract class Object implements EventListenerInterface
{

use InstanceConfigTrait;
use ProxyTrait;

/**
* Container with reference to all objects
* needed within the CrudListener and CrudAction
*
* @var \Cake\Controller\Controller
*/
protected $_controller;

/**
* Default configuration
*
* @var array
*/
protected $_defaultConfig = [];

/**
* Constructor
*
* @param \Cake\Controller\Controller $Controller Controller instance
* @param array $config Default settings
*/
public function __construct(Controller $Controller, $config = [])
{
$this->_controller = $Controller;
$this->config($config);
}

/**
* List of implemented events
*
* @return array
*/
public function implementedEvents()
{
return [];
}

/**
* Convenient method for Request::is
*
* @param string|array $method Method(s) to check for
* @return bool
*/
protected function _checkRequestType($method)
{
return $this->_request()->is($method);
}
// @deprecated Add backwards compat alias. "Object" is protected keyword in PHP 7.2
if (PHP_VERSION_ID < 70200) {
class_alias('Crud\Core\BaseObject', 'Crud\Core\Object');
}
4 changes: 2 additions & 2 deletions src/Listener/BaseListener.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Crud\Listener;

use Crud\Core\Object;
use Crud\Core\BaseObject;

/**
* The Base Crud Listener
Expand All @@ -11,7 +11,7 @@
*
* @codeCoverageIgnore
*/
abstract class BaseListener extends Object
abstract class BaseListener extends BaseObject
{

/**
Expand Down

0 comments on commit ae533de

Please sign in to comment.