>= PHP7.0 refactoring (#3343)
* Fix loosly comparison to strict + argument types and return types for >=7.0 * Change hard-coded strings to ::class, * Fix unit-tests failures - some relative to 7.0 phpunit env deployment * Fix exception string + format return types * Change string representation of new classes in traceLog to ::class Credit to @arthurkushman
This commit is contained in:
parent
74b3780ab5
commit
bbc33710c1
|
|
@ -93,7 +93,7 @@ class Asset extends Extendable
|
|||
|
||||
/**
|
||||
* Prepares the theme datasource for the model.
|
||||
* @param \Cms\Classes\Theme $theme Specifies a parent theme.
|
||||
* @param \Cms\Classes\Theme|string $theme Specifies a parent theme.
|
||||
* @return $this
|
||||
*/
|
||||
public static function inTheme($theme)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,6 @@ class CmsController extends ControllerBase
|
|||
*/
|
||||
public function run($url = '/')
|
||||
{
|
||||
return App::make('Cms\Classes\Controller')->run($url);
|
||||
return App::make(Controller::class)->run($url);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class CmsException extends ApplicationException
|
|||
$trace = $exception->getTrace();
|
||||
if (isset($trace[1]['class'])) {
|
||||
$class = $trace[1]['class'];
|
||||
if (!is_subclass_of($class, 'Cms\Classes\CodeBase')) {
|
||||
if (!is_subclass_of($class, CodeBase::class)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class MediaLibrary extends SystemMediaLibrary
|
|||
*/
|
||||
protected function init()
|
||||
{
|
||||
traceLog('Class Cms\Classes\MediaLibrary has been deprecated, use System\Classes\MediaLibrary instead.');
|
||||
traceLog('Class Cms\Classes\MediaLibrary has been deprecated, use ' . SystemMediaLibrary::class . ' instead.');
|
||||
parent::init();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class MediaLibraryItem extends SystemMediaLibraryItem
|
|||
{
|
||||
public function __construct()
|
||||
{
|
||||
traceLog('Class Cms\Classes\MediaLibraryItem has been deprecated, use System\Classes\MediaLibraryItem instead.');
|
||||
traceLog('Class Cms\Classes\MediaLibraryItem has been deprecated, use ' . SystemMediaLibraryItem::class . ' instead.');
|
||||
parent::__construct(...func_get_args());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class Page extends CmsCompoundObject
|
|||
* Returns name of a PHP class to us a parent for the PHP class created for the object's PHP section.
|
||||
* @return mixed Returns the class name or null.
|
||||
*/
|
||||
public function getCodeClassParent()
|
||||
public function getCodeClassParent() : string
|
||||
{
|
||||
return '\Cms\Classes\PageCode';
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ class Page extends CmsCompoundObject
|
|||
* This method is used by the form widget.
|
||||
* @return array Returns an array of strings.
|
||||
*/
|
||||
public function getLayoutOptions()
|
||||
public function getLayoutOptions() : array
|
||||
{
|
||||
if (!($theme = Theme::getEditTheme())) {
|
||||
throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found'));
|
||||
|
|
@ -107,12 +107,12 @@ class Page extends CmsCompoundObject
|
|||
* Helper that returns a nicer list of pages for use in dropdowns.
|
||||
* @return array
|
||||
*/
|
||||
public static function getNameList()
|
||||
public static function getNameList() : array
|
||||
{
|
||||
$result = [];
|
||||
$pages = self::sortBy('baseFileName')->all();
|
||||
foreach ($pages as $page) {
|
||||
$result[$page->baseFileName] = $page->title.' ('.$page->baseFileName.')';
|
||||
$result[$page->baseFileName] = $page->title . ' (' . $page->baseFileName . ')';
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
@ -124,7 +124,7 @@ class Page extends CmsCompoundObject
|
|||
* @param array $params Route parameters to consider in the URL.
|
||||
* @return string
|
||||
*/
|
||||
public static function url($page, $params = [])
|
||||
public static function url($page, array $params = []) : string
|
||||
{
|
||||
/*
|
||||
* Reuse existing controller or create a new one,
|
||||
|
|
@ -153,17 +153,17 @@ class Page extends CmsCompoundObject
|
|||
* @param string $type Specifies the menu item type
|
||||
* @return array Returns an array
|
||||
*/
|
||||
public static function getMenuTypeInfo($type)
|
||||
public static function getMenuTypeInfo(string $type) : array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
if ($type == 'cms-page') {
|
||||
if ($type === 'cms-page') {
|
||||
$theme = Theme::getActiveTheme();
|
||||
$pages = self::listInTheme($theme, true);
|
||||
$references = [];
|
||||
|
||||
foreach ($pages as $page) {
|
||||
$references[$page->getBaseFileName()] = $page->title . ' ['.$page->getBaseFileName().']';
|
||||
$references[$page->getBaseFileName()] = $page->title . ' [' . $page->getBaseFileName() . ']';
|
||||
}
|
||||
|
||||
$result = [
|
||||
|
|
@ -193,11 +193,11 @@ class Page extends CmsCompoundObject
|
|||
* The URL is specified relative to the website root, it includes the subdirectory name, if any.
|
||||
* @return mixed Returns an array. Returns null if the item cannot be resolved.
|
||||
*/
|
||||
public static function resolveMenuItem($item, $url, $theme)
|
||||
public static function resolveMenuItem($item, string $url, Theme $theme)
|
||||
{
|
||||
$result = null;
|
||||
|
||||
if ($item->type == 'cms-page') {
|
||||
if ($item->type === 'cms-page') {
|
||||
if (!$item->reference) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -221,11 +221,11 @@ class Page extends CmsCompoundObject
|
|||
* @param string $type Specifies the page link type
|
||||
* @return array
|
||||
*/
|
||||
public static function getRichEditorTypeInfo($type)
|
||||
public static function getRichEditorTypeInfo(string $type) : array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
if ($type == 'cms-page') {
|
||||
if ($type === 'cms-page') {
|
||||
$theme = Theme::getActiveTheme();
|
||||
$pages = self::listInTheme($theme, true);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ class Partial extends CmsCompoundObject
|
|||
*/
|
||||
public function getCodeClassParent()
|
||||
{
|
||||
return '\Cms\Classes\PartialCode';
|
||||
return PartialCode::class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Media extends MediaController
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
traceLog('Controller Cms\Controllers\Media has been deprecated, use Backend\Controller\Media instead.');
|
||||
traceLog('Controller Cms\Controllers\Media has been deprecated, use ' . MediaController::class . ' instead.');
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class MediaFinder extends BackendMediaFinder
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
traceLog('FormWidget Cms\FormWidgets\MediaFinder has been deprecated, use Backend\FormWidgets\MediaFinder instead.');
|
||||
traceLog('FormWidget Cms\FormWidgets\MediaFinder has been deprecated, use ' . BackendMediaFinder::class . ' instead.');
|
||||
|
||||
$this->assetPath = '/modules/backend/formwidgets/mediafinder/assets';
|
||||
$this->viewPath = base_path('/modules/backend/formwidgets/mediafinder/partials');
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class MediaManager extends BackendMediaManager
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
traceLog('Widget Cms\Widgets\MediaManager has been deprecated, use Backend\Widgets\MediaManager instead.');
|
||||
traceLog('Widget Cms\Widgets\MediaManager has been deprecated, use ' . BackendMediaManager::class . ' instead.');
|
||||
|
||||
$this->assetPath = '/modules/backend/widgets/mediamanager/assets';
|
||||
$this->viewPath = base_path('/modules/backend/widgets/mediamanager/partials');
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class MailTemplate extends Model
|
|||
*/
|
||||
public static function registerCallback(callable $callback)
|
||||
{
|
||||
traceLog('MailTemplate::registerCallback is deprecated, use System\Classes\MailManager::registerCallback instead');
|
||||
traceLog('MailTemplate::registerCallback is deprecated, use ' . MailManager::class . '::registerCallback instead');
|
||||
MailManager::instance()->registerCallback($callback);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue