Commit b362e366 authored by TYPO3 Release Team's avatar TYPO3 Release Team
Browse files

[TASK] Make TYPO3 Core PSR-2 standard compliant

In our efforts to achieve a better interoperability
with other PHP projects, the PHP code base of the
TYPO3 Core switches to the PHP coding guideline
standard PSR-2.

See http://www.php-fig.org/psr/psr-2/ for more
information.

Resolves: #70515
Releases: master
Change-Id: I734c0d838af157003decfeb5fc0a11dddcb87bf5
Reviewed-on: http://review.typo3.org/43918


Reviewed-by: default avatarTYPO3 Release Team <typo3cms@typo3.org>
Tested-by: default avatarTYPO3 Release Team <typo3cms@typo3.org>
parent 886626f3
......@@ -28,7 +28,7 @@ if (version_compare(PHP_VERSION, '5.5.0', '<')) {
}
// Set up the application for the Frontend
call_user_func(function() {
call_user_func(function () {
$classLoader = require __DIR__ . '/typo3/../vendor/autoload.php';
(new \TYPO3\CMS\Frontend\Http\Application($classLoader))->run();
});
......@@ -21,9 +21,9 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\Controller;
call_user_func(function() {
call_user_func(function () {
$classLoader = require __DIR__ . '/../vendor/autoload.php';
(new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function() {
(new \TYPO3\CMS\Backend\Http\Application($classLoader))->run(function () {
$originalRequestedFilenameParts = parse_url(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
$originalRequestedFilename = basename($originalRequestedFilenameParts['path']);
......
......@@ -15,7 +15,7 @@
/**
* Main entry point for all backend-related scripts.
*/
call_user_func(function() {
call_user_func(function () {
$classLoader = require __DIR__ . '/../vendor/autoload.php';
(new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
});
......@@ -20,8 +20,8 @@ use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
/**
* Module 'about' shows some standard information for TYPO3 CMS: About-text, version number and so on.
*/
class AboutController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
class AboutController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* @var
*/
......@@ -35,7 +35,8 @@ class AboutController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
/**
* @param \TYPO3\CMS\About\Domain\Repository\ExtensionRepository $extensionRepository
*/
public function injectExtensionRepository(\TYPO3\CMS\About\Domain\Repository\ExtensionRepository $extensionRepository) {
public function injectExtensionRepository(\TYPO3\CMS\About\Domain\Repository\ExtensionRepository $extensionRepository)
{
$this->extensionRepository = $extensionRepository;
}
......@@ -44,7 +45,8 @@ class AboutController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
*
* @param ViewInterface $view
*/
protected function initializeView(ViewInterface $view) {
protected function initializeView(ViewInterface $view)
{
/** @var BackendTemplateView $view */
parent::initializeView($view);
// Disable Path
......@@ -56,7 +58,8 @@ class AboutController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
*
* @return void
*/
public function indexAction() {
public function indexAction()
{
$extensions = $this->extensionRepository->findAllLoaded();
$this->view
->assign('TYPO3Version', TYPO3_version)
......@@ -64,5 +67,4 @@ class AboutController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
->assign('TYPO3UrlDonate', TYPO3_URL_DONATE)
->assign('loadedExtensions', $extensions);
}
}
......@@ -19,8 +19,8 @@ namespace TYPO3\CMS\About\Domain\Model;
*
* @entity
*/
class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
*/
......@@ -44,57 +44,64 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* @param string $author
*/
public function setAuthor($author) {
public function setAuthor($author)
{
$this->author = $author;
}
/**
* @return string
*/
public function getAuthor() {
public function getAuthor()
{
return $this->author;
}
/**
* @param string $authorEmail
*/
public function setAuthorEmail($authorEmail) {
public function setAuthorEmail($authorEmail)
{
$this->authorEmail = $authorEmail;
}
/**
* @return string
*/
public function getAuthorEmail() {
public function getAuthorEmail()
{
return $this->authorEmail;
}
/**
* @param string $key
*/
public function setKey($key) {
public function setKey($key)
{
$this->key = $key;
}
/**
* @return string
*/
public function getKey() {
public function getKey()
{
return $this->key;
}
/**
* @param string $title
*/
public function setTitle($title) {
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getTitle() {
public function getTitle()
{
return $this->title;
}
}
......@@ -17,8 +17,8 @@ namespace TYPO3\CMS\About\Domain\Repository;
/**
* Repository for TYPO3\CMS\About\Domain\Model\Extension
*/
class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
*/
......@@ -27,7 +27,8 @@ class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
/**
* @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
*/
public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager) {
public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
}
......@@ -36,7 +37,8 @@ class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\About\Domain\Model\Extension>
*/
public function findAllLoaded() {
public function findAllLoaded()
{
$loadedExtensions = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class);
$loadedExtensionsArray = $GLOBALS['TYPO3_LOADED_EXT'];
foreach ($loadedExtensionsArray as $extensionKey => $extension) {
......@@ -55,5 +57,4 @@ class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
}
return $loadedExtensions;
}
}
......@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Aboutmodules\Controller;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
......@@ -29,8 +28,8 @@ use TYPO3\CMS\Lang\LanguageService;
* Will display the list of main- and sub-modules available to the user.
* Each module will be show with description and a link to the module.
*/
class ModulesController extends ActionController {
class ModulesController extends ActionController
{
/**
* Language Service property. Used to access localized labels
*
......@@ -48,7 +47,8 @@ class ModulesController extends ActionController {
/**
* @param LanguageService $languageService Language Service to inject
*/
public function __construct(LanguageService $languageService = NULL) {
public function __construct(LanguageService $languageService = null)
{
parent::__construct();
$this->languageService = $languageService ?: $GLOBALS['LANG'];
}
......@@ -58,7 +58,8 @@ class ModulesController extends ActionController {
*
* @param ViewInterface $view
*/
protected function initializeView(ViewInterface $view) {
protected function initializeView(ViewInterface $view)
{
/** @var BackendTemplateView $view */
parent::initializeView($view);
// Disable Path
......@@ -70,7 +71,8 @@ class ModulesController extends ActionController {
*
* @return void
*/
public function indexAction() {
public function indexAction()
{
$warnings = array();
$contentWarnings = '';
// Hook for additional warnings
......@@ -114,10 +116,11 @@ class ModulesController extends ActionController {
*
* @return array
*/
protected function getModulesData() {
protected function getModulesData()
{
/** @var $loadedModules \TYPO3\CMS\Backend\Module\ModuleLoader */
$loadedModules = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Module\ModuleLoader::class);
$loadedModules->observeWorkspaces = TRUE;
$loadedModules->observeWorkspaces = true;
$loadedModules->load($GLOBALS['TBE_MODULES']);
$mainModulesData = array();
foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
......@@ -140,7 +143,8 @@ class ModulesController extends ActionController {
* @param array $subModulesInfo Sub module information
* @return array
*/
protected function getSubModuleData($moduleName, array $subModulesInfo = array()) {
protected function getSubModuleData($moduleName, array $subModulesInfo = array())
{
$subModulesData = array();
foreach ($subModulesInfo as $subModuleName => $subModuleInfo) {
$subModuleKey = $moduleName . '_' . $subModuleName . '_tab';
......@@ -154,5 +158,4 @@ class ModulesController extends ActionController {
}
return $subModulesData;
}
}
......@@ -21,8 +21,8 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
/**
* This is the ajax handler for backend login after timeout.
*/
class AjaxLoginHandler {
class AjaxLoginHandler
{
/**
* Handles the actual login process, more specifically it defines the response.
* The login details were sent in as part of the ajax request and automatically logged in
......@@ -34,16 +34,17 @@ class AjaxLoginHandler {
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function loginAction(ServerRequestInterface $request, ResponseInterface $response) {
public function loginAction(ServerRequestInterface $request, ResponseInterface $response)
{
if ($this->isAuthorizedBackendSession()) {
$result = ['success' => TRUE];
$result = ['success' => true];
if ($this->hasLoginBeenProcessed()) {
$formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
$formProtection->setSessionTokenFromRegistry();
$formProtection->persistSessionToken();
}
} else {
$result = ['success' => FALSE];
$result = ['success' => false];
}
$response->getBody()->write(json_encode(['login' => $result]));
......@@ -57,7 +58,8 @@ class AjaxLoginHandler {
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function logoutAction(ServerRequestInterface $request, ResponseInterface $response) {
public function logoutAction(ServerRequestInterface $request, ResponseInterface $response)
{
$backendUser = $this->getBackendUser();
$backendUser->logoff();
......@@ -76,12 +78,13 @@ class AjaxLoginHandler {
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function refreshAction(ServerRequestInterface $request, ResponseInterface $response) {
public function refreshAction(ServerRequestInterface $request, ResponseInterface $response)
{
$this->getBackendUser()->checkAuthentication();
$response->getBody()->write(json_encode([
'refresh' => [
'success' => TRUE
'success' => true
]
]));
return $response;
......@@ -94,19 +97,20 @@ class AjaxLoginHandler {
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function isTimedOutAction(ServerRequestInterface $request, ResponseInterface $response) {
public function isTimedOutAction(ServerRequestInterface $request, ResponseInterface $response)
{
$session = [
'timed_out' => FALSE,
'will_time_out' => FALSE,
'locked' => FALSE
'timed_out' => false,
'will_time_out' => false,
'locked' => false
];
$backendUser = $this->getBackendUser();
if (@is_file(PATH_typo3conf . 'LOCK_BACKEND')) {
$session['locked'] = TRUE;
$session['locked'] = true;
} elseif (!isset($backendUser->user['uid'])) {
$session['timed_out'] = TRUE;
$session['timed_out'] = true;
} else {
$backendUser->fetchUserSession(TRUE);
$backendUser->fetchUserSession(true);
$ses_tstamp = $backendUser->user['ses_tstamp'];
$timeout = $backendUser->auth_timeout_field;
// If 120 seconds from now is later than the session timeout, we need to show the refresh dialog.
......@@ -122,9 +126,10 @@ class AjaxLoginHandler {
*
* @return bool
*/
protected function isAuthorizedBackendSession() {
protected function isAuthorizedBackendSession()
{
$backendUser = $this->getBackendUser();
return $backendUser !== NULL && $backendUser instanceof BackendUserAuthentication && isset($backendUser->user['uid']);
return $backendUser !== null && $backendUser instanceof BackendUserAuthentication && isset($backendUser->user['uid']);
}
/**
......@@ -132,7 +137,8 @@ class AjaxLoginHandler {
*
* @return bool
*/
protected function hasLoginBeenProcessed() {
protected function hasLoginBeenProcessed()
{
$loginFormData = $this->getBackendUser()->getLoginFormData();
return $loginFormData['status'] === 'login' && !empty($loginFormData['uname']) && !empty($loginFormData['uident']);
}
......@@ -140,7 +146,8 @@ class AjaxLoginHandler {
/**
* @return BackendUserAuthentication|NULL
*/
protected function getBackendUser() {
return isset($GLOBALS['BE_USER']) ? $GLOBALS['BE_USER'] : NULL;
protected function getBackendUser()
{
return isset($GLOBALS['BE_USER']) ? $GLOBALS['BE_USER'] : null;
}
}
......@@ -22,8 +22,8 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Avatar renderer class
*/
class Avatar {
class Avatar
{
/**
* Array of sorted and initiated avatar providers
*
......@@ -34,7 +34,8 @@ class Avatar {
/**
* Construct
*/
public function __construct() {
public function __construct()
{
$this->validateSortAndInitiateAvatarProviders();
}
......@@ -46,7 +47,8 @@ class Avatar {
* @param bool $showIcon show the record icon
* @return string
*/
public function render(array $backendUser = NULL, $size = 32, $showIcon = FALSE) {
public function render(array $backendUser = null, $size = 32, $showIcon = false)
{
if (!is_array($backendUser)) {
$backendUser = $this->getBackendUser()->user;
}
......@@ -70,7 +72,8 @@ class Avatar {
* @param int $size
* @return string
*/
public function getImgTag(array $backendUser = NULL, $size = 32) {
public function getImgTag(array $backendUser = null, $size = 32)
{
if (!is_array($backendUser)) {
$backendUser = $this->getBackendUser()->user;
}
......@@ -79,7 +82,7 @@ class Avatar {
$avatarImage = $this->getImage($backendUser, $size);
if ($avatarImage) {
$imageTag = '<img src="' . htmlspecialchars($avatarImage->getUrl(TRUE)) . '"' .
$imageTag = '<img src="' . htmlspecialchars($avatarImage->getUrl(true)) . '"' .
'width="' . (int)$avatarImage->getWidth() . '" ' .
'height="' . (int)$avatarImage->getHeight() . '" />';
}
......@@ -94,14 +97,15 @@ class Avatar {
* @param int $size
* @return Image|NULL
*/
public function getImage(array $backendUser, $size) {
public function getImage(array $backendUser, $size)
{
foreach ($this->avatarProviders as $provider) {
$avatarImage = $provider->getImage($backendUser, $size);
if (!empty($avatarImage)) {
return $avatarImage;
}
}
return NULL;
return null;
}
/**
......@@ -110,7 +114,8 @@ class Avatar {
* @return void
* @throws \RuntimeException
*/
protected function validateSortAndInitiateAvatarProviders() {
protected function validateSortAndInitiateAvatarProviders()
{
if (
empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['avatarProviders'])
|| !is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['backend']['avatarProviders'])
......@@ -140,8 +145,8 @@ class Avatar {
*
* @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
*/
protected function getBackendUser() {
protected function getBackendUser()
{
return $GLOBALS['BE_USER'];
}
}
......@@ -17,8 +17,8 @@ namespace TYPO3\CMS\Backend\Backend\Avatar;
/**
* Class AvatarProviderInterface
*/
interface AvatarProviderInterface {
interface AvatarProviderInterface
{
/**
* Get Image
*
......@@ -27,5 +27,4 @@ interface AvatarProviderInterface {
* @return Image|NULL
*/
public function getImage(array $backendUser, $size);
}
......@@ -22,8 +22,8 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class DefaultAvatarProvider
*/
class DefaultAvatarProvider implements AvatarProviderInterface {
class DefaultAvatarProvider implements AvatarProviderInterface
{
/**
* Get Image
*
......@@ -31,7 +31,8 @@ class DefaultAvatarProvider implements AvatarProviderInterface {
* @param int $size
* @return Image|NULL
*/
public function getImage(array $backendUser, $size) {
public function getImage(array $backendUser, $size)
{
$fileUid = $this->getAvatarFileUid($backendUser['uid']);
// Get file object
......@@ -48,10 +49,9 @@ class DefaultAvatarProvider implements AvatarProviderInterface {
$processedImage->getProperty('width'),
$processedImage->getProperty('height')
);
} catch (FileDoesNotExistException $e) {
// No image found
$image = NULL;
$image = null;
}
return $image;
......@@ -63,7 +63,8 @@ class DefaultAvatarProvider implements AvatarProviderInterface {
* @param int $beUserId
* @return int
*/
protected function getAvatarFileUid($beUserId) {
protected function getAvatarFileUid($beUserId)
{
$file = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
'uid_local',
'sys_file_reference',
......@@ -77,7 +78,8 @@ class DefaultAvatarProvider implements AvatarProviderInterface {
/**
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
protected function getDatabaseConnection() {
protected function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}
}
......@@ -21,8 +21,8 @@ use TYPO3\CMS\Core\Utility\PathUtility;
*
* Holds url + dimensions of avatar image
*/
class Image {
class Image
{
/**
* Url of avatar image. Needs to be relative to the website root or an absolute URL.
*
......@@ -47,7 +47,8 @@ class Image {
* @param int $width width of image
* @param int $height height of image
*/
public function __construct($url, $width, $height) {
public function __construct($url, $width, $height)
{
$this->url = $url;
$this->width = (int)$width;
$this->height = (int)$height;
......@@ -59,7 +60,8 @@ class Image {
* @param bool $relativeToCurrentScript Determines whether the URL returned should be relative to the current script, in case it is relative at all.
* @return string
*/
public function getUrl($relativeToCurrentScript = FALSE) {
public function getUrl($relativeToCurrentScript = false)
{
$url = $this->url;
if ($relativeToCurrentScript && !GeneralUtility::isValidUrl($url)) {
......@@ -76,7 +78,8 @@ class Image {
*
* @return int
*/
public function getWidth() {
public function getWidth()
{
return $this->width;
}
......@@ -85,7 +88,8 @@ class Image {
*
* @return int
*/
public function getHeight() {
public function getHeight()
{
return $this->height;
}
}
......@@ -25,8 +25,8 @@ use TYPO3\CMS\Core\Page\PageRenderer;
/**
* Render cache clearing toolbar item
*/
class ClearCacheToolbarItem implements ToolbarItemInterface {
class ClearCacheToolbarItem implements ToolbarItemInterface
{