Do not import global classes (#41078)

This commit is contained in:
Allon Moritz 2023-06-28 14:01:50 +02:00 committed by GitHub
parent 7411a6eb64
commit c4ee583718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
202 changed files with 864 additions and 1126 deletions

View File

@ -80,6 +80,8 @@ $config
'no_break_comment' => ['comment_text' => 'No break'],
// Remove unused imports
'no_unused_imports' => true,
// Classes from the global namespace should not be imported
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
]
)
->setFinder($finder);

View File

@ -10,9 +10,6 @@
namespace Joomla\Component\Actionlogs\Administrator\Controller;
use DateTimeZone;
use Exception;
use InvalidArgumentException;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Date\Date;
@ -48,7 +45,7 @@ class ActionlogsController extends AdminController
*
* @since 3.9.0
*
* @throws Exception
* @throws \Exception
*/
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
{
@ -64,7 +61,7 @@ class ActionlogsController extends AdminController
*
* @since 3.9.0
*
* @throws Exception
* @throws \Exception
*/
public function exportLogs()
{
@ -89,7 +86,7 @@ class ActionlogsController extends AdminController
if (\count($data)) {
try {
$rows = ActionlogsHelper::getCsvData($data);
} catch (InvalidArgumentException $exception) {
} catch (\InvalidArgumentException $exception) {
$this->setMessage(Text::_('COM_ACTIONLOGS_ERROR_COULD_NOT_EXPORT_DATA'), 'error');
$this->setRedirect(Route::_('index.php?option=com_actionlogs&view=actionlogs', false));
@ -99,7 +96,7 @@ class ActionlogsController extends AdminController
// Destroy the iterator now
unset($data);
$date = new Date('now', new DateTimeZone('UTC'));
$date = new Date('now', new \DateTimeZone('UTC'));
$filename = 'logs_' . $date->format('Y-m-d_His_T');
$csvDelimiter = ComponentHelper::getComponent('com_actionlogs')->getParams()->get('csv_delimiter', ',');

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Actionlogs\Administrator\Helper;
use Generator;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Path;
@ -44,13 +43,13 @@ class ActionlogsHelper
*
* @param array|\Traversable $data The logs data objects to be exported
*
* @return Generator
* @return \Generator
*
* @since 3.9.0
*
* @throws \InvalidArgumentException
*/
public static function getCsvData($data): Generator
public static function getCsvData($data): \Generator
{
if (!is_iterable($data)) {
throw new \InvalidArgumentException(

View File

@ -11,7 +11,6 @@
namespace Joomla\Component\Actionlogs\Administrator\Model;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use stdClass;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -29,11 +28,11 @@ class ActionlogConfigModel extends BaseDatabaseModel
*
* @param string $context The context of the content
*
* @return stdClass|null An object contains content type parameters, or null if not found
* @return \stdClass|null An object contains content type parameters, or null if not found
*
* @since 4.2.0
*/
public function getLogContentTypeParams(string $context): ?stdClass
public function getLogContentTypeParams(string $context): ?\stdClass
{
$db = $this->getDatabase();
$query = $db->getQuery(true)

View File

@ -10,8 +10,6 @@
namespace Joomla\Component\Actionlogs\Administrator\Model;
use DateTimeZone;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Factory;
@ -22,7 +20,6 @@ use Joomla\Database\DatabaseIterator;
use Joomla\Database\DatabaseQuery;
use Joomla\Database\ParameterType;
use Joomla\Utilities\ArrayHelper;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -42,7 +39,7 @@ class ActionlogsModel extends ListModel
*
* @since 3.9.0
*
* @throws Exception
* @throws \Exception
*/
public function __construct($config = [])
{
@ -71,7 +68,7 @@ class ActionlogsModel extends ListModel
*
* @since 3.9.0
*
* @throws Exception
* @throws \Exception
*/
protected function populateState($ordering = 'a.id', $direction = 'desc')
{
@ -85,7 +82,7 @@ class ActionlogsModel extends ListModel
*
* @since 3.9.0
*
* @throws Exception
* @throws \Exception
*/
protected function getListQuery()
{
@ -174,7 +171,7 @@ class ActionlogsModel extends ListModel
*
* @since 3.9.0
*
* @throws Exception
* @throws \Exception
*/
private function buildDateRange($range)
{
@ -212,7 +209,7 @@ class ActionlogsModel extends ListModel
$dStart->setTime(0, 0, 0);
// Now change the timezone back to UTC.
$tz = new DateTimeZone('GMT');
$tz = new \DateTimeZone('GMT');
$dStart->setTimezone($tz);
break;
}
@ -341,7 +338,7 @@ class ActionlogsModel extends ListModel
try {
$db->execute();
} catch (RuntimeException $e) {
} catch (\RuntimeException $e) {
$this->setError($e->getMessage());
return false;
@ -363,7 +360,7 @@ class ActionlogsModel extends ListModel
{
try {
$this->getDatabase()->truncateTable('#__action_logs');
} catch (Exception $e) {
} catch (\Exception $e) {
return false;
}

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Actionlogs\Administrator\View\Actionlogs;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
@ -98,7 +97,7 @@ class HtmlView extends BaseHtmlView
*
* @since 3.9.0
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null)
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Admin\Administrator\View\Help;
use Exception;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
@ -68,7 +67,7 @@ class HtmlView extends BaseHtmlView
*
* @since 1.6
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Admin\Administrator\View\Sysinfo;
use Exception;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
@ -80,7 +79,7 @@ class HtmlView extends BaseHtmlView
*
* @since 1.6
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Admin\Administrator\View\Sysinfo;
use Exception;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
@ -37,7 +36,7 @@ class JsonView extends AbstractView
*
* @since 3.5
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Admin\Administrator\View\Sysinfo;
use Exception;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
@ -37,7 +36,7 @@ class TextView extends AbstractView
*
* @since 3.5
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Banners\Administrator\View\Banner;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
@ -66,7 +65,7 @@ class HtmlView extends BaseHtmlView
*
* @since 1.5
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{
@ -92,7 +91,7 @@ class HtmlView extends BaseHtmlView
* @return void
*
* @since 1.6
* @throws Exception
* @throws \Exception
*/
protected function addToolbar(): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Banners\Administrator\View\Banners;
use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\ContentHelper;
@ -100,7 +99,7 @@ class HtmlView extends BaseHtmlView
* @return void
*
* @since 1.6
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Banners\Administrator\View\Client;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
@ -75,7 +74,7 @@ class HtmlView extends BaseHtmlView
*
* @since 1.5
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{
@ -103,7 +102,7 @@ class HtmlView extends BaseHtmlView
*
* @since 1.6
*
* @throws Exception
* @throws \Exception
*/
protected function addToolbar(): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Banners\Administrator\View\Clients;
use Exception;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
@ -90,7 +89,7 @@ class HtmlView extends BaseHtmlView
*
* @since 1.6
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Banners\Administrator\View\Download;
use Exception;
use Joomla\CMS\Form\Form;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
@ -44,7 +43,7 @@ class HtmlView extends BaseHtmlView
*
* @since 1.6
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Banners\Administrator\View\Tracks;
use Exception;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
@ -90,7 +89,7 @@ class HtmlView extends BaseHtmlView
* @return void
*
* @since 1.6
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Banners\Administrator\View\Tracks;
use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\GenericDataException;
@ -37,7 +36,7 @@ class RawView extends BaseHtmlView
*
* @since 1.6
*
* @throws Exception
* @throws \Exception
*/
public function display($tpl = null): void
{

View File

@ -9,7 +9,6 @@
namespace Joomla\Component\Content\Administrator\Event\Model;
use BadMethodCallException;
use Joomla\CMS\Event\AbstractImmutableEvent;
// phpcs:disable PSR1.Files.SideEffects
@ -29,22 +28,22 @@ class FeatureEvent extends AbstractImmutableEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 4.0.0
*/
public function __construct($name, array $arguments = [])
{
if (!isset($arguments['extension'])) {
throw new BadMethodCallException("Argument 'extension' of event $this->name is required but has not been provided");
throw new \BadMethodCallException("Argument 'extension' of event $this->name is required but has not been provided");
}
if (!isset($arguments['extension']) || !is_string($arguments['extension'])) {
throw new BadMethodCallException("Argument 'extension' of event $this->name is not of type 'string'");
throw new \BadMethodCallException("Argument 'extension' of event $this->name is not of type 'string'");
}
if (strpos($arguments['extension'], '.') === false) {
throw new BadMethodCallException("Argument 'extension' of event $this->name has wrong format. Valid format: 'component.section'");
throw new \BadMethodCallException("Argument 'extension' of event $this->name has wrong format. Valid format: 'component.section'");
}
if (!\array_key_exists('extensionName', $arguments) || !\array_key_exists('section', $arguments)) {
@ -55,17 +54,17 @@ class FeatureEvent extends AbstractImmutableEvent
}
if (!isset($arguments['pks']) || !is_array($arguments['pks'])) {
throw new BadMethodCallException("Argument 'pks' of event $this->name is not of type 'array'");
throw new \BadMethodCallException("Argument 'pks' of event $this->name is not of type 'array'");
}
if (!isset($arguments['value']) || !is_numeric($arguments['value'])) {
throw new BadMethodCallException("Argument 'value' of event $this->name is not of type 'numeric'");
throw new \BadMethodCallException("Argument 'value' of event $this->name is not of type 'numeric'");
}
$arguments['value'] = (int) $arguments['value'];
if ($arguments['value'] !== 0 && $arguments['value'] !== 1) {
throw new BadMethodCallException("Argument 'value' of event $this->name is not 0 or 1");
throw new \BadMethodCallException("Argument 'value' of event $this->name is not 0 or 1");
}
parent::__construct($name, $arguments);

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Finder\Administrator\Indexer;
use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Table\Table;
@ -164,7 +163,7 @@ abstract class Adapter extends CMSPlugin
* @return void
*
* @since 2.5
* @throws Exception on error.
* @throws \Exception on error.
*/
public function onStartIndex()
{
@ -192,7 +191,7 @@ abstract class Adapter extends CMSPlugin
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on error.
* @throws \Exception on error.
*/
public function onBeforeIndex()
{
@ -218,7 +217,7 @@ abstract class Adapter extends CMSPlugin
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on error.
* @throws \Exception on error.
*/
public function onBuildIndex()
{
@ -300,7 +299,7 @@ abstract class Adapter extends CMSPlugin
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function change($id, $property, $value)
{
@ -331,7 +330,7 @@ abstract class Adapter extends CMSPlugin
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
abstract protected function index(Result $item);
@ -343,7 +342,7 @@ abstract class Adapter extends CMSPlugin
* @return void
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function reindex($id)
{
@ -368,7 +367,7 @@ abstract class Adapter extends CMSPlugin
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function remove($id, $removeTaxonomies = true)
{
@ -404,7 +403,7 @@ abstract class Adapter extends CMSPlugin
* @return boolean True on success, false on failure.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
abstract protected function setup();
@ -520,7 +519,7 @@ abstract class Adapter extends CMSPlugin
* @return integer The number of content items available to index.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function getContentCount()
{
@ -556,7 +555,7 @@ abstract class Adapter extends CMSPlugin
* @return Result A Result object.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function getItem($id)
{
@ -590,7 +589,7 @@ abstract class Adapter extends CMSPlugin
* @return Result[] An array of Result objects.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function getItems($offset, $limit, $query = null)
{
@ -718,7 +717,7 @@ abstract class Adapter extends CMSPlugin
* @return integer The numeric type id for the content.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function getTypeId()
{
@ -758,7 +757,7 @@ abstract class Adapter extends CMSPlugin
* @return mixed The title on success, null if not found.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function getItemMenuTitle($url)
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Finder\Administrator\Indexer;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Multilanguage;
@ -39,7 +38,7 @@ class Helper
* @return string The parsed input.
*
* @since 2.5
* @throws Exception on invalid parser.
* @throws \Exception on invalid parser.
*/
public static function parse($input, $format = 'html')
{
@ -215,7 +214,7 @@ class Helper
* @return integer The id of the content type.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
public static function addContentType($title, $mime = null)
{
@ -300,7 +299,7 @@ class Helper
* @return array Array of common terms.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
public static function getCommonWords($lang)
{
@ -373,7 +372,7 @@ class Helper
* @return boolean True on success, false on failure.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
public static function getContentExtras(Result $item)
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Finder\Administrator\Indexer;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Object\CMSObject;
@ -187,7 +186,7 @@ class Indexer
*/
$memory_table_limit = (int) ($heapsize->Value / 800);
$data->options->set('memory_table_limit', $memory_table_limit);
} catch (Exception $e) {
} catch (\Exception $e) {
// Something failed. We fall back to a reasonable guess.
$data->options->set('memory_table_limit', 7500);
}
@ -643,7 +642,7 @@ class Indexer
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
public function remove($linkId, $removeTaxonomies = true)
{
@ -701,7 +700,7 @@ class Indexer
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
public function optimize()
{
@ -962,7 +961,7 @@ class Indexer
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function toggleTables($memory)
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Finder\Administrator\Indexer;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
@ -203,7 +202,7 @@ class Query
* @param array $options An array of query options.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
public function __construct($options, DatabaseInterface $db = null)
{
@ -494,7 +493,7 @@ class Query
* @return boolean True on success, false on failure.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function processStaticTaxonomy($filterId)
{
@ -585,7 +584,7 @@ class Query
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function processDynamicTaxonomy($filters)
{
@ -729,7 +728,7 @@ class Query
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function processString($input, $lang, $mode)
{
@ -1232,7 +1231,7 @@ class Query
* @return Token A Token object.
*
* @since 2.5
* @throws Exception on database error.
* @throws \Exception on database error.
*/
protected function getTokenData($token)
{

View File

@ -10,14 +10,12 @@
namespace Joomla\Component\Installer\Administrator\Helper;
use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Object\CMSObject;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\ParameterType;
use SimpleXMLElement;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -185,7 +183,7 @@ class InstallerHelper
* @param integer $clientId client_id of an extension
* @param string $folder folder of an extension
*
* @return SimpleXMLElement
* @return \SimpleXMLElement
*
* @since 4.0.0
*/
@ -194,7 +192,7 @@ class InstallerHelper
string $type,
int $clientId = 1,
?string $folder = null
): ?SimpleXMLElement {
): ?\SimpleXMLElement {
$path = [0 => JPATH_SITE, 1 => JPATH_ADMINISTRATOR, 3 => JPATH_API][$clientId] ?? JPATH_SITE;
switch ($type) {
@ -304,7 +302,7 @@ class InstallerHelper
// Get the database driver. If it fails we cannot report whether the extension supports download keys.
try {
$db = Factory::getDbo();
} catch (Exception $e) {
} catch (\Exception $e) {
return [
'supported' => false,
'valid' => false,
@ -326,7 +324,7 @@ class InstallerHelper
try {
$extension = new CMSObject($db->setQuery($query)->loadAssoc());
} catch (Exception $e) {
} catch (\Exception $e) {
return [
'supported' => false,
'valid' => false,
@ -425,7 +423,7 @@ class InstallerHelper
{
try {
$db = Factory::getDbo();
} catch (Exception $e) {
} catch (\Exception $e) {
return [];
}
@ -483,7 +481,7 @@ class InstallerHelper
}
return $items;
} catch (Exception $e) {
} catch (\Exception $e) {
return [];
}
}

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Installer\Administrator\Model;
use Exception;
use Joomla\CMS\Form\Form;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Object\CMSObject;
@ -44,7 +43,7 @@ class UpdatesiteModel extends AdminModel
*
* @return Form|boolean A Form object on success, false on failure
*
* @throws Exception
* @throws \Exception
*
* @since 4.0.0
*/
@ -162,7 +161,7 @@ class UpdatesiteModel extends AdminModel
try {
$db->setQuery($query)->execute();
} catch (Exception $e) {
} catch (\Exception $e) {
// No problem if this fails for any reason.
}

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Installer\Administrator\Model;
use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Installer\Installer;
@ -22,7 +21,6 @@ use Joomla\CMS\Router\Route;
use Joomla\CMS\Table\UpdateSite as UpdateSiteTable;
use Joomla\Component\Installer\Administrator\Helper\InstallerHelper;
use Joomla\Database\ParameterType;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -75,14 +73,14 @@ class UpdatesitesModel extends InstallerModel
*
* @return boolean True on success
*
* @throws Exception on ACL error
* @throws \Exception on ACL error
* @since 3.4
*
*/
public function publish(&$eid = [], $value = 1)
{
if (!$this->getCurrentUser()->authorise('core.edit.state', 'com_installer')) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 403);
throw new \Exception(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 403);
}
$result = true;
@ -116,14 +114,14 @@ class UpdatesitesModel extends InstallerModel
*
* @return void
*
* @throws Exception on ACL error
* @throws \Exception on ACL error
* @since 3.6
*
*/
public function delete($ids = [])
{
if (!$this->getCurrentUser()->authorise('core.delete', 'com_installer')) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 403);
throw new \Exception(Text::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 403);
}
// Ensure eid is an array of extension ids
@ -180,7 +178,7 @@ class UpdatesitesModel extends InstallerModel
$db->execute();
$count++;
} catch (RuntimeException $e) {
} catch (\RuntimeException $e) {
$app->enqueueMessage(
Text::sprintf(
'COM_INSTALLER_MSG_UPDATESITES_DELETE_ERROR',
@ -242,14 +240,14 @@ class UpdatesitesModel extends InstallerModel
*
* @return void
*
* @throws Exception on ACL error
* @throws \Exception on ACL error
* @since 3.6
*
*/
public function rebuild(): void
{
if (!$this->getCurrentUser()->authorise('core.admin', 'com_installer')) {
throw new Exception(Text::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_NOT_PERMITTED'), 403);
throw new \Exception(Text::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_NOT_PERMITTED'), 403);
}
$db = $this->getDatabase();

View File

@ -26,7 +26,6 @@ use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use stdClass;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -697,11 +696,11 @@ class StyleModel extends AdminModel
*
* @param int $styleId The style id
*
* @return stdClass
* @return \stdClass
*
* @since 4.2.0
*/
public function getAdminTemplate(int $styleId): stdClass
public function getAdminTemplate(int $styleId): \stdClass
{
$db = $this->getDatabase();
$query = $db->getQuery(true)

View File

@ -17,7 +17,6 @@ use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Input\Input;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -65,7 +64,7 @@ class CallbackController extends BaseController
$method = $this->input->getCmd('method', '');
if (empty($method)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
PluginHelper::importPlugin('multifactorauth');
@ -77,6 +76,6 @@ class CallbackController extends BaseController
* The first plugin to handle the request should either redirect or close the application. If we are still here
* no plugin handled the request successfully. Show an error.
*/
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
}

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Users\Administrator\Controller;
use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Event\MultiFactor\NotifyActionLog;
@ -25,7 +24,6 @@ use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\Model\BackupcodesModel;
use Joomla\Component\Users\Administrator\Model\CaptiveModel;
use Joomla\Input\Input;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -64,7 +62,7 @@ class CaptiveController extends BaseController implements UserFactoryAwareInterf
* @param boolean|array $urlparams Ignored. This page is never cached.
*
* @return void
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public function display($cachable = false, $urlparams = false): void
@ -73,7 +71,7 @@ class CaptiveController extends BaseController implements UserFactoryAwareInterf
// Only allow logged in Users
if ($user->guest) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Get the view object
@ -109,7 +107,7 @@ class CaptiveController extends BaseController implements UserFactoryAwareInterf
try {
// Suppress all modules on the page except those explicitly allowed
$model->suppressAllModules();
} catch (Exception $e) {
} catch (\Exception $e) {
// If we can't kill the modules we can still survive.
}
@ -128,7 +126,7 @@ class CaptiveController extends BaseController implements UserFactoryAwareInterf
* @param array $urlparameters Ignored. This page is never cached.
*
* @return void
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public function validate($cachable = false, $urlparameters = [])
@ -150,7 +148,7 @@ class CaptiveController extends BaseController implements UserFactoryAwareInterf
$event = new NotifyActionLog('onComUsersCaptiveValidateInvalidMethod');
$this->app->getDispatcher()->dispatch($event->getName(), $event);
throw new RuntimeException(Text::_('COM_USERS_MFA_INVALID_METHOD'), 500);
throw new \RuntimeException(Text::_('COM_USERS_MFA_INVALID_METHOD'), 500);
}
if (!$model->checkTryLimit($record)) {

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Users\Administrator\Controller;
use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Event\MultiFactor\NotifyActionLog;
use Joomla\CMS\Event\MultiFactor\SaveSetup;
@ -27,7 +26,6 @@ use Joomla\Component\Users\Administrator\Model\BackupcodesModel;
use Joomla\Component\Users\Administrator\Model\MethodModel;
use Joomla\Component\Users\Administrator\Table\MfaTable;
use Joomla\Input\Input;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -69,7 +67,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
*
* @return mixed The value returned by the called Method.
*
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public function execute($task)
@ -88,7 +86,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
* @param boolean|array $urlparams Ignored. This page is never cached.
*
* @return void
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public function add($cachable = false, $urlparams = []): void
@ -133,7 +131,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
* @param boolean|array $urlparams Ignored. This page is never cached.
*
* @return void
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public function edit($cachable = false, $urlparams = []): void
@ -151,7 +149,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
$record = $this->assertValidRecordId($id, $user);
if ($id <= 0) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
/** @var MethodModel $model */
@ -182,7 +180,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
* @param boolean|array $urlparams Ignored. This page is never cached.
*
* @return void
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public function regenerateBackupCodes($cachable = false, $urlparams = []): void
@ -241,7 +239,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
$record = $this->assertValidRecordId($id, $user);
if ($id <= 0) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
$type = null;
@ -252,7 +250,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
try {
$record->delete();
} catch (Exception $e) {
} catch (\Exception $e) {
$message = $e->getMessage();
$type = 'error';
}
@ -327,7 +325,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
foreach ($pluginResults as $pluginResult) {
$result = array_merge($result, $pluginResult);
}
} catch (RuntimeException $e) {
} catch (\RuntimeException $e) {
// Go back to the edit page
$nonSefUrl = 'index.php?option=com_users&task=method.';
@ -415,7 +413,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
$record = $model->getRecord($user);
if (is_null($record) || ($record->id != $id) || ($record->user_id != $user->id)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
return $record;
@ -427,13 +425,13 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
* @param User|null $user User record. Null to use current user.
*
* @return void
* @throws RuntimeException|Exception
* @throws \RuntimeException|\Exception
* @since 4.2.0
*/
private function assertCanEdit(?User $user = null): void
{
if (!MfaHelper::canAddEditMethod($user)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
}
@ -443,13 +441,13 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
* @param User|null $user User record. Null to use current user.
*
* @return void
* @throws RuntimeException|Exception
* @throws \RuntimeException|\Exception
* @since 4.2.0
*/
private function assertCanDelete(?User $user = null): void
{
if (!MfaHelper::canDeleteMethod($user)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
}
@ -467,7 +465,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
$model = $this->getModel('Method');
if (empty($method) || !$model->methodExists($method)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
}
@ -482,7 +480,7 @@ class MethodController extends BaseControllerAlias implements UserFactoryAwareIn
$user = $this->app->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
if ($user->guest) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
}
}

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Users\Administrator\Controller;
use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Event\MultiFactor\NotifyActionLog;
use Joomla\CMS\Language\Text;
@ -23,7 +22,6 @@ use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\Helper\Mfa as MfaHelper;
use Joomla\Component\Users\Administrator\Model\MethodsModel;
use Joomla\Input\Input;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -80,7 +78,7 @@ class MethodsController extends BaseController implements UserFactoryAwareInterf
$user = $user ?? $this->getUserFactory()->loadUserById(0);
if (!MfaHelper::canDeleteMethod($user)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Delete all MFA Methods for the user
@ -94,7 +92,7 @@ class MethodsController extends BaseController implements UserFactoryAwareInterf
try {
$model->deleteAll($user);
} catch (Exception $e) {
} catch (\Exception $e) {
$message = $e->getMessage();
$type = 'error';
}
@ -132,7 +130,7 @@ class MethodsController extends BaseController implements UserFactoryAwareInterf
$user = $user ?? $this->getUserFactory()->loadUserById(0);
if (!MfaHelper::canShowConfigurationInterface($user)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
$returnURL = $this->input->getBase64('returnurl');
@ -176,7 +174,7 @@ class MethodsController extends BaseController implements UserFactoryAwareInterf
$user = $user ?? $this->getUserFactory()->loadUserById(0);
if (!MfaHelper::canAddEditMethod($user)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
$event = new NotifyActionLog('onComUsersControllerMethodsBeforeDoNotShowThisAgain', [$user]);
@ -208,7 +206,7 @@ class MethodsController extends BaseController implements UserFactoryAwareInterf
$user = $this->app->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
if ($user->guest) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
}
}

View File

@ -10,8 +10,6 @@
namespace Joomla\Component\Users\Administrator\DataShape;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -164,13 +162,13 @@ class CaptiveRenderOptions extends DataShapeObject
* @param string $value One of self::FIELD_INPUT, self::FIELD_CUSTOM
*
* @since 4.2.0
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*/
// phpcs:ignore
protected function setField_type(string $value)
{
if (!in_array($value, [self::FIELD_INPUT, self::FIELD_CUSTOM])) {
throw new InvalidArgumentException('Invalid value for property field_type.');
throw new \InvalidArgumentException('Invalid value for property field_type.');
}
$this->field_type = $value;

View File

@ -10,8 +10,6 @@
namespace Joomla\Component\Users\Administrator\DataShape;
use InvalidArgumentException;
/**
* Generic helper for handling data shapes in com_users
*
@ -29,7 +27,7 @@ abstract class DataShapeObject implements \ArrayAccess
public function __construct(array $array = [])
{
if (!is_array($array) && !($array instanceof self)) {
throw new InvalidArgumentException(sprintf('%s needs an array or a %s object', __METHOD__, __CLASS__));
throw new \InvalidArgumentException(sprintf('%s needs an array or a %s object', __METHOD__, __CLASS__));
}
foreach (($array instanceof self) ? $array->asArray() : $array as $k => $v) {
@ -61,7 +59,7 @@ abstract class DataShapeObject implements \ArrayAccess
public function merge($newValues): self
{
if (!is_array($newValues) && !($newValues instanceof self)) {
throw new InvalidArgumentException(sprintf('%s needs an array or a %s object', __METHOD__, __CLASS__));
throw new \InvalidArgumentException(sprintf('%s needs an array or a %s object', __METHOD__, __CLASS__));
}
foreach (($newValues instanceof self) ? $newValues->asArray() : $newValues as $k => $v) {
@ -96,7 +94,7 @@ abstract class DataShapeObject implements \ArrayAccess
return $this->{$name};
}
throw new InvalidArgumentException(sprintf('Property %s not found in %s', $name, __CLASS__));
throw new \InvalidArgumentException(sprintf('Property %s not found in %s', $name, __CLASS__));
}
/**
@ -120,7 +118,7 @@ abstract class DataShapeObject implements \ArrayAccess
$this->{$name} = $value;
}
throw new InvalidArgumentException(sprintf('Property %s not found in %s', $name, __CLASS__));
throw new \InvalidArgumentException(sprintf('Property %s not found in %s', $name, __CLASS__));
}
/**

View File

@ -10,8 +10,6 @@
namespace Joomla\Component\Users\Administrator\DataShape;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -207,13 +205,13 @@ class SetupRenderOptions extends DataShapeObject
* @param string $value One of self::FIELD_INPUT, self::FIELD_CUSTOM
*
* @since 4.2.0
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*/
// phpcs:ignore
protected function setField_type($value)
{
if (!in_array($value, [self::FIELD_INPUT, self::FIELD_CUSTOM])) {
throw new InvalidArgumentException('Invalid value for property field_type.');
throw new \InvalidArgumentException('Invalid value for property field_type.');
}
$this->field_type = $value;

View File

@ -65,7 +65,7 @@ abstract class Mfa
* @param User $user The user we are going to show the configuration UI for.
*
* @return string|null The HTML of the UI; null if we cannot / must not show it.
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public static function getConfigurationInterface(User $user): ?string
@ -190,7 +190,7 @@ abstract class Mfa
* @param User|null $user The user you want to know if we're allowed to edit
*
* @return boolean
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public static function canAddEditMethod(?User $user = null): bool
@ -229,7 +229,7 @@ abstract class Mfa
* @param User|null $user The user being queried.
*
* @return boolean
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public static function canDeleteMethod(?User $user = null): bool
@ -252,7 +252,7 @@ abstract class Mfa
* @param int|null $userId User ID. NULL for currently logged in user.
*
* @return MfaTable[]
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -273,7 +273,7 @@ abstract class Mfa
try {
$ids = $db->setQuery($query)->loadColumn() ?: [];
} catch (Exception $e) {
} catch (\Exception $e) {
$ids = [];
}
@ -326,7 +326,7 @@ abstract class Mfa
* @param User|null $user The user to be configured
*
* @return boolean
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public static function canShowConfigurationInterface(?User $user = null): bool

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Users\Administrator\Model;
use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Date\Date;
@ -57,7 +56,7 @@ class CaptiveModel extends BaseDatabaseModel
* @param CMSApplication|null $app The CMS application to manipulate
*
* @return void
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -77,7 +76,7 @@ class CaptiveModel extends BaseDatabaseModel
* @param bool $includeBackupCodes Should I include the backup codes record?
*
* @return array
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -162,7 +161,7 @@ class CaptiveModel extends BaseDatabaseModel
* @param User|null $user The user for which to fetch records. Skip to use the current user.
*
* @return MfaTable|null
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -338,7 +337,7 @@ class CaptiveModel extends BaseDatabaseModel
* @param Event $event The Joomla! event object
*
* @return void
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -363,7 +362,7 @@ class CaptiveModel extends BaseDatabaseModel
*
* @return void The by-reference value is modified instead.
* @since 4.2.0
* @throws Exception
* @throws \Exception
*/
private function filterModules(array &$modules): void
{
@ -390,7 +389,7 @@ class CaptiveModel extends BaseDatabaseModel
* Get a list of module positions we are allowed to display
*
* @return array
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Users\Administrator\Model;
use Exception;
use Joomla\CMS\Event\MultiFactor\GetSetup;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
@ -84,7 +83,7 @@ class MethodModel extends BaseDatabaseModel
* @param User|null $user The user record. Null to use the currently logged in user.
*
* @return array
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -123,7 +122,7 @@ class MethodModel extends BaseDatabaseModel
* @param User|null $user The user record. Null to use the currently logged in user.
*
* @return MfaTable
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -188,7 +187,7 @@ class MethodModel extends BaseDatabaseModel
* @param User|null $user The user record. Null to use the current user.
*
* @return MfaTable
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/

View File

@ -10,9 +10,6 @@
namespace Joomla\Component\Users\Administrator\Model;
use DateInterval;
use DateTimeZone;
use Exception;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
@ -20,7 +17,6 @@ use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\User\User;
use Joomla\Component\Users\Administrator\Helper\Mfa as MfaHelper;
use Joomla\Database\ParameterType;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -39,7 +35,7 @@ class MethodsModel extends BaseDatabaseModel
* @param User|null $user The user object. Skip to use the current user.
*
* @return array
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -84,7 +80,7 @@ class MethodsModel extends BaseDatabaseModel
* @param User|null $user The user object to reset MFA for. Null to use the current user.
*
* @return void
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -97,7 +93,7 @@ class MethodsModel extends BaseDatabaseModel
// If the user object is a guest (who can't have MFA) we stop with an error
if ($user->guest) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
$db = $this->getDatabase();
@ -117,7 +113,7 @@ class MethodsModel extends BaseDatabaseModel
* @param string $dateTimeText The database time string to use, e.g. "2017-01-13 13:25:36"
*
* @return string The formatted, human-readable date
* @throws Exception
* @throws \Exception
*
* @since 4.2.0
*/
@ -128,7 +124,7 @@ class MethodsModel extends BaseDatabaseModel
}
// The timestamp is given in UTC. Make sure Joomla! parses it as such.
$utcTimeZone = new DateTimeZone('UTC');
$utcTimeZone = new \DateTimeZone('UTC');
$jDate = new Date($dateTimeText, $utcTimeZone);
$unixStamp = $jDate->toUnix();
@ -140,7 +136,7 @@ class MethodsModel extends BaseDatabaseModel
// I need to display the date in the user's local timezone. That's how you do it.
$user = $this->getCurrentUser();
$userTZ = $user->getParam('timezone', 'UTC');
$tz = new DateTimeZone($userTZ);
$tz = new \DateTimeZone($userTZ);
$jDate->setTimezone($tz);
// Default format string: way in the past, the time of the day is not important
@ -162,7 +158,7 @@ class MethodsModel extends BaseDatabaseModel
// Is this timestamp yesterday?
$jYesterday = clone $jNow;
$jYesterday->setTime(0, 0, 0);
$oneSecond = new DateInterval('PT1S');
$oneSecond = new \DateInterval('PT1S');
$jYesterday->sub($oneSecond);
$checkYesterday = $jYesterday->format('Ymd', true);
@ -200,7 +196,7 @@ class MethodsModel extends BaseDatabaseModel
try {
$result = $db->setQuery($query)->loadResult();
} catch (Exception $e) {
} catch (\Exception $e) {
return;
}

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Users\Administrator\Table;
use Exception;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
@ -26,8 +25,6 @@ use Joomla\Component\Users\Administrator\Service\Encrypt;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\ParameterType;
use Joomla\Event\DispatcherInterface;
use RuntimeException;
use Throwable;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -171,7 +168,7 @@ class MfaTable extends Table implements CurrentUserInterface, UserFactoryAwareIn
// Store the record
try {
$result = parent::store($updateNulls);
} catch (Throwable $e) {
} catch (\Throwable $e) {
$this->setError($e->getMessage());
$result = false;
@ -204,7 +201,7 @@ class MfaTable extends Table implements CurrentUserInterface, UserFactoryAwareIn
*
* @since 4.2.0
* @throws \InvalidArgumentException
* @throws RuntimeException
* @throws \RuntimeException
* @throws \UnexpectedValueException
*/
public function load($keys = null, $reset = true)
@ -239,7 +236,7 @@ class MfaTable extends Table implements CurrentUserInterface, UserFactoryAwareIn
if (!$result) {
// If the record does not exist I will stomp my feet and deny your request
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
}
@ -247,7 +244,7 @@ class MfaTable extends Table implements CurrentUserInterface, UserFactoryAwareIn
// The user must be a registered user, not a guest
if ($user->guest) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Save flags used onAfterDelete
@ -331,7 +328,7 @@ class MfaTable extends Table implements CurrentUserInterface, UserFactoryAwareIn
* Regenerate backup code is the flag is set.
*
* @return void
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
private function generateBackupCodes(): void

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Users\Administrator\View\Captive;
use Exception;
use Joomla\CMS\Event\MultiFactor\BeforeDisplayMethods;
use Joomla\CMS\Event\MultiFactor\NotifyActionLog;
use Joomla\CMS\Factory;
@ -24,7 +23,6 @@ use Joomla\Component\Users\Administrator\Helper\Mfa as MfaHelper;
use Joomla\Component\Users\Administrator\Model\BackupcodesModel;
use Joomla\Component\Users\Administrator\Model\CaptiveModel;
use Joomla\Component\Users\Administrator\View\SiteTemplateTrait;
use stdClass;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -50,7 +48,7 @@ class HtmlView extends BaseHtmlView
/**
* The currently selected MFA Method record against which we'll be authenticating
*
* @var null|stdClass
* @var null|\stdClass
* @since 4.2.0
*/
public $record = null;
@ -102,7 +100,7 @@ class HtmlView extends BaseHtmlView
*
* @return void A string if successful, otherwise an Error object.
*
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
public function display($tpl = null)

View File

@ -10,11 +10,8 @@
namespace Joomla\Component\Users\Administrator\View;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use ReflectionException;
use ReflectionObject;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -31,7 +28,7 @@ trait SiteTemplateTrait
* Set a specific site template style in the frontend application
*
* @return void
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
private function setSiteTemplateStyle(): void
@ -52,11 +49,11 @@ trait SiteTemplateTrait
$app->getInput()->set('templateStyle', $templateStyle);
try {
$refApp = new ReflectionObject($app);
$refApp = new \ReflectionObject($app);
$refTemplate = $refApp->getProperty('template');
$refTemplate->setAccessible(true);
$refTemplate->setValue($app, null);
} catch (ReflectionException $e) {
} catch (\ReflectionException $e) {
return;
}

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Contact\Site\Model;
use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\TagsHelper;
@ -84,7 +83,7 @@ class FormModel extends \Joomla\Component\Contact\Administrator\Model\ContactMod
*
* @return mixed Contact item data object on success, false on failure.
*
* @throws Exception
* @throws \Exception
*
* @since 4.0.0
*/
@ -100,7 +99,7 @@ class FormModel extends \Joomla\Component\Contact\Administrator\Model\ContactMod
if (!$table->load($itemId)) {
return false;
}
} catch (Exception $e) {
} catch (\Exception $e) {
Factory::getApplication()->enqueueMessage($e->getMessage());
return false;
@ -146,7 +145,7 @@ class FormModel extends \Joomla\Component\Contact\Administrator\Model\ContactMod
*
* @since 4.0.0
*
* @throws Exception
* @throws \Exception
*/
public function save($data)
{
@ -174,7 +173,7 @@ class FormModel extends \Joomla\Component\Contact\Administrator\Model\ContactMod
*
* @since 4.0.0
*
* @throws Exception
* @throws \Exception
*/
protected function populateState()
{
@ -229,7 +228,7 @@ class FormModel extends \Joomla\Component\Contact\Administrator\Model\ContactMod
*
* @since 4.0.0
* @throws Exception
* @throws \Exception
*/
public function getTable($name = 'Contact', $prefix = 'Administrator', $options = [])
{

View File

@ -10,7 +10,6 @@
namespace Joomla\Component\Tags\Site\Helper;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Helper\RouteHelper as CMSRouteHelper;
use Joomla\CMS\Menu\AbstractMenu;
@ -85,7 +84,7 @@ class RouteHelper extends CMSRouteHelper
* @return string URL link to pass to the router
*
* @since 3.1
* @throws Exception
* @throws \Exception
*
* @deprecated 4.3 will be removed in 6.0
* Use RouteHelper::getComponentTagRoute() instead
@ -106,7 +105,7 @@ class RouteHelper extends CMSRouteHelper
* @return string URL link to pass to the router
*
* @since 4.2.0
* @throws Exception
* @throws \Exception
*/
public static function getComponentTagRoute(string $id, string $language = '*'): string
{
@ -140,7 +139,7 @@ class RouteHelper extends CMSRouteHelper
* @return string URL link to pass to the router
*
* @since 3.7
* @throws Exception
* @throws \Exception
*
* @deprecated 4.3 will be removed in 6.0
* Use RouteHelper::getComponentTagsRoute() instead
@ -161,7 +160,7 @@ class RouteHelper extends CMSRouteHelper
* @return string URL link to pass to the router
*
* @since 4.2.0
* @throws Exception
* @throws \Exception
*/
public static function getComponentTagsRoute(string $language = '*'): string
{
@ -177,7 +176,7 @@ class RouteHelper extends CMSRouteHelper
*
* @return null
*
* @throws Exception
* @throws \Exception
*/
protected static function _findItem($needles = null)
{

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Application;
use InvalidArgumentException;
use Joomla\CMS\Console;
use Joomla\CMS\Extension\ExtensionManagerTrait;
use Joomla\CMS\Factory;
@ -483,7 +482,7 @@ class ConsoleApplication extends Application implements DispatcherAwareInterface
public static function getRouter($name = null, array $options = [])
{
if (empty($name)) {
throw new InvalidArgumentException('A router name must be set in console application.');
throw new \InvalidArgumentException('A router name must be set in console application.');
}
$options['mode'] = Factory::getApplication()->get('sef');

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Application;
use JLoader;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -31,7 +29,7 @@ trait ExtensionNamespaceMapper
*/
public function createExtensionNamespaceMap()
{
JLoader::register('JNamespacePsr4Map', JPATH_LIBRARIES . '/namespacemap.php');
\JLoader::register('JNamespacePsr4Map', JPATH_LIBRARIES . '/namespacemap.php');
$extensionPsr4Loader = new \JNamespacePsr4Map();
$extensionPsr4Loader->load();
}

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Application;
use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Encrypt\Aes;
@ -23,7 +22,6 @@ use Joomla\Component\Users\Administrator\Helper\Mfa as MfaHelper;
use Joomla\Component\Users\Administrator\Table\MfaTable;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\ParameterType;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -54,7 +52,7 @@ trait MultiFactorAuthenticationHandler
* Handle the redirection to the Multi-factor Authentication captive login or setup page.
*
* @return boolean True if we are currently handling a Multi-factor Authentication captive page.
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
protected function isHandlingMultiFactorAuthentication(): bool
@ -62,7 +60,7 @@ trait MultiFactorAuthenticationHandler
// Multi-factor Authentication checks take place only for logged in users.
try {
$user = $this->getIdentity() ?? null;
} catch (Exception $e) {
} catch (\Exception $e) {
return false;
}
@ -121,7 +119,7 @@ trait MultiFactorAuthenticationHandler
// Prevent non-interactive (non-HTML) content from being loaded until MFA is validated.
if ($isMFAPending && $isNonHtml) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
if ($isMFAPending && !$isMFADisallowed) {
@ -184,7 +182,7 @@ trait MultiFactorAuthenticationHandler
* Does the current user need to complete MFA authentication before being allowed to access the site?
*
* @return boolean
* @throws Exception
* @throws \Exception
* @since 4.2.0
*/
private function isMultiFactorAuthenticationPending(): bool
@ -258,7 +256,7 @@ trait MultiFactorAuthenticationHandler
// Make sure we are logged in
try {
$user = $this->getIdentity();
} catch (Exception $e) {
} catch (\Exception $e) {
// This would happen if we are in CLI or under an old Joomla! version. Either case is not supported.
return false;
}
@ -359,7 +357,7 @@ trait MultiFactorAuthenticationHandler
try {
$result = $db->setQuery($query)->loadResult();
} catch (Exception $e) {
} catch (\Exception $e) {
$result = 1;
}
@ -494,7 +492,7 @@ trait MultiFactorAuthenticationHandler
// Is this already decrypted?
try {
$decrypted = @json_decode($stringToDecrypt, true);
} catch (Exception $e) {
} catch (\Exception $e) {
$decrypted = null;
}

View File

@ -15,7 +15,6 @@ use Joomla\CMS\Log\Log;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Version;
use Joomla\Registry\Registry;
use RuntimeException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
@ -338,7 +337,7 @@ class Changelog extends CMSObject
try {
$http = HttpFactory::getHttp($httpOption);
$response = $http->get($url);
} catch (RuntimeException $e) {
} catch (\RuntimeException $e) {
$response = null;
}

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Console;
use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\LanguageAwareInterface;
use Joomla\CMS\Language\LanguageAwareTrait;
@ -24,7 +23,6 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use UnexpectedValueException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
@ -247,7 +245,7 @@ EOF;
try {
$language = $this->getLanguage();
} catch (UnexpectedValueException $e) {
} catch (\UnexpectedValueException $e) {
@trigger_error(sprintf('Language must be set in 6.0 in %s', __METHOD__), E_USER_DEPRECATED);
$language = Factory::getLanguage();
}
@ -437,7 +435,7 @@ EOF;
// End of Pausing Section
}
}
} catch (Exception $e) {
} catch (\Exception $e) {
// Display the error
$this->ioStyle->error($e->getMessage());

View File

@ -35,7 +35,7 @@ class AuthenticationFailedExceptionHandler implements ExceptionHandlerInterface
*
* @since 4.0.0
*/
public function manages(Exception $e)
public function manages(\Exception $e)
{
return $e instanceof AuthenticationFailed;
}
@ -43,13 +43,13 @@ class AuthenticationFailedExceptionHandler implements ExceptionHandlerInterface
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 401;
$error = ['title' => 'Forbidden'];

View File

@ -35,7 +35,7 @@ class CheckinCheckoutExceptionHandler implements ExceptionHandlerInterface
*
* @since 4.0.0
*/
public function manages(Exception $e)
public function manages(\Exception $e)
{
return $e instanceof CheckinCheckout;
}
@ -43,13 +43,13 @@ class CheckinCheckoutExceptionHandler implements ExceptionHandlerInterface
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 400;

View File

@ -26,13 +26,13 @@ class InvalidParameterExceptionHandler extends \Tobscure\JsonApi\Exception\Handl
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 400;
$error = ['title' => $e->getMessage()];

View File

@ -35,7 +35,7 @@ class InvalidRouteExceptionHandler implements ExceptionHandlerInterface
*
* @since 4.0.0
*/
public function manages(Exception $e)
public function manages(\Exception $e)
{
return $e instanceof RouteNotFoundException;
}
@ -43,13 +43,13 @@ class InvalidRouteExceptionHandler implements ExceptionHandlerInterface
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 404;
$error = ['title' => 'Resource not found'];

View File

@ -35,7 +35,7 @@ class NotAcceptableExceptionHandler implements ExceptionHandlerInterface
*
* @since 4.0.0
*/
public function manages(Exception $e)
public function manages(\Exception $e)
{
return $e instanceof NotAcceptable;
}
@ -43,13 +43,13 @@ class NotAcceptableExceptionHandler implements ExceptionHandlerInterface
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 406;
$error = ['title' => 'Not Acceptable'];

View File

@ -35,7 +35,7 @@ class NotAllowedExceptionHandler implements ExceptionHandlerInterface
*
* @since 4.0.0
*/
public function manages(Exception $e)
public function manages(\Exception $e)
{
return $e instanceof NotAllowed;
}
@ -43,13 +43,13 @@ class NotAllowedExceptionHandler implements ExceptionHandlerInterface
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 403;
$error = ['title' => 'Access Denied'];

View File

@ -35,7 +35,7 @@ class ResourceNotFoundExceptionHandler implements ExceptionHandlerInterface
*
* @since 4.0.0
*/
public function manages(Exception $e)
public function manages(\Exception $e)
{
return $e instanceof ResourceNotFound;
}
@ -43,13 +43,13 @@ class ResourceNotFoundExceptionHandler implements ExceptionHandlerInterface
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 404;
$error = ['title' => 'Resource not found'];

View File

@ -35,7 +35,7 @@ class SaveExceptionHandler implements ExceptionHandlerInterface
*
* @since 4.0.0
*/
public function manages(Exception $e)
public function manages(\Exception $e)
{
return $e instanceof Save;
}
@ -43,13 +43,13 @@ class SaveExceptionHandler implements ExceptionHandlerInterface
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 400;

View File

@ -35,7 +35,7 @@ class SendEmailExceptionHandler implements ExceptionHandlerInterface
*
* @since 4.0.0
*/
public function manages(Exception $e)
public function manages(\Exception $e)
{
return $e instanceof SendEmail;
}
@ -43,13 +43,13 @@ class SendEmailExceptionHandler implements ExceptionHandlerInterface
/**
* Handle the provided exception.
*
* @param Exception $e The exception being handled
* @param \Exception $e The exception being handled
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @since 4.0.0
*/
public function handle(Exception $e)
public function handle(\Exception $e)
{
$status = 400;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event;
use BadMethodCallException;
use Joomla\Event\Event;
use Joomla\Event\Event as BaseEvent;
use Joomla\String\Normalise;
@ -54,7 +53,7 @@ abstract class AbstractEvent extends BaseEvent
* @return static
*
* @since 4.0.0
* @throws BadMethodCallException If you do not provide a subject argument
* @throws \BadMethodCallException If you do not provide a subject argument
*/
public static function create(string $eventName, array $arguments = [])
{
@ -81,7 +80,7 @@ abstract class AbstractEvent extends BaseEvent
// Make sure a non-empty subject argument exists and that it is an object
if (!isset($arguments['subject']) || empty($arguments['subject']) || !\is_object($arguments['subject'])) {
throw new BadMethodCallException("No subject given for the $eventName event");
throw new \BadMethodCallException("No subject given for the $eventName event");
}
// Create and return the event object

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -38,12 +36,12 @@ class AbstractImmutableEvent extends AbstractEvent
* @param array $arguments The event arguments.
*
* @since 4.0.0
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct(string $name, array $arguments = [])
{
if ($this->constructed) {
throw new BadMethodCallException(
throw new \BadMethodCallException(
sprintf('Cannot reconstruct the AbstractImmutableEvent %s.', $this->name)
);
}
@ -62,11 +60,11 @@ class AbstractImmutableEvent extends AbstractEvent
* @return void
*
* @since 4.0.0
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function offsetSet($name, $value)
{
throw new BadMethodCallException(
throw new \BadMethodCallException(
sprintf(
'Cannot set the argument %s of the immutable event %s.',
$name,
@ -83,11 +81,11 @@ class AbstractImmutableEvent extends AbstractEvent
* @return void
*
* @since 4.0.0
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function offsetUnset($name)
{
throw new BadMethodCallException(
throw new \BadMethodCallException(
sprintf(
'Cannot remove the argument %s of the immutable event %s.',
$name,

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\Model;
use BadMethodCallException;
use Joomla\CMS\Event\AbstractImmutableEvent;
// phpcs:disable PSR1.Files.SideEffects
@ -29,18 +28,18 @@ class BeforeBatchEvent extends AbstractImmutableEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 4.0.0
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('src', $arguments)) {
throw new BadMethodCallException("Argument 'src' is required for event $name");
throw new \BadMethodCallException("Argument 'src' is required for event $name");
}
if (!\array_key_exists('type', $arguments)) {
throw new BadMethodCallException("Argument 'type' is required for event $name");
throw new \BadMethodCallException("Argument 'type' is required for event $name");
}
parent::__construct($name, $arguments);

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\MultiFactor;
use DomainException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\User\User;
@ -50,7 +49,7 @@ class BeforeDisplayMethods extends AbstractImmutableEvent
public function setUser(User $value): User
{
if (empty($value) || ($value->id <= 0) || ($value->guest == 1)) {
throw new DomainException(sprintf('Argument \'user\' of event %s must be a non-guest User object.', $this->name));
throw new \DomainException(sprintf('Argument \'user\' of event %s must be a non-guest User object.', $this->name));
}
return $value;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\MultiFactor;
use DomainException;
use Joomla\CMS\Event\AbstractImmutableEvent;
// phpcs:disable PSR1.Files.SideEffects
@ -41,13 +40,13 @@ class Callback extends AbstractImmutableEvent
* @param string|null $value The value to validate
*
* @return string
* @throws DomainException
* @throws \DomainException
* @since 4.2.0
*/
public function setMethod(string $value): string
{
if (empty($value)) {
throw new DomainException(sprintf("Argument 'method' of event %s must be a non-empty string.", $this->name));
throw new \DomainException(sprintf("Argument 'method' of event %s must be a non-empty string.", $this->name));
}
return $value;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\MultiFactor;
use DomainException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
@ -59,7 +58,7 @@ class Captive extends AbstractImmutableEvent implements ResultAwareInterface
public function setRecord(MfaTable $value): MfaTable
{
if (empty($value)) {
throw new DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name));
throw new \DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name));
}
return $value;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\MultiFactor;
use DomainException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
@ -59,7 +58,7 @@ class GetSetup extends AbstractImmutableEvent implements ResultAwareInterface
public function setRecord(MfaTable $value): MfaTable
{
if (empty($value)) {
throw new DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name));
throw new \DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name));
}
return $value;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\MultiFactor;
use DomainException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
@ -63,7 +62,7 @@ class SaveSetup extends AbstractImmutableEvent implements ResultAwareInterface
public function setRecord(MfaTable $value): MfaTable
{
if (empty($value)) {
throw new DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name));
throw new \DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name));
}
return $value;
@ -80,7 +79,7 @@ class SaveSetup extends AbstractImmutableEvent implements ResultAwareInterface
public function setInput(Input $value): Input
{
if (empty($value)) {
throw new DomainException(sprintf('Argument \'input\' of event %s must be an Input object.', $this->name));
throw new \DomainException(sprintf('Argument \'input\' of event %s must be an Input object.', $this->name));
}
return $value;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\MultiFactor;
use DomainException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
@ -63,7 +62,7 @@ class Validate extends AbstractImmutableEvent implements ResultAwareInterface
public function setRecord(MfaTable $value): MfaTable
{
if (empty($value)) {
throw new DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name));
throw new \DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name));
}
return $value;
@ -80,7 +79,7 @@ class Validate extends AbstractImmutableEvent implements ResultAwareInterface
public function setUser(User $value): User
{
if (empty($value) || ($value->id <= 0) || ($value->guest == 1)) {
throw new DomainException(sprintf('Argument \'user\' of event %s must be a non-guest User object.', $this->name));
throw new \DomainException(sprintf('Argument \'user\' of event %s must be a non-guest User object.', $this->name));
}
return $value;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\Plugin\System\Webauthn;
use InvalidArgumentException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
@ -42,7 +41,7 @@ class AjaxChallenge extends AbstractImmutableEvent implements ResultAwareInterfa
}
if (!is_string($data) || @json_decode($data) === null) {
throw new InvalidArgumentException(sprintf('Event %s only accepts JSON results.', $this->getName()));
throw new \InvalidArgumentException(sprintf('Event %s only accepts JSON results.', $this->getName()));
}
}
}

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\QuickIcon;
use BadMethodCallException;
use DomainException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\ReshapeArgumentsAware;
use Joomla\CMS\Event\Result\ResultAware;
@ -39,7 +37,7 @@ class GetIconEvent extends AbstractImmutableEvent implements ResultAwareInterfac
* @param array $arguments The event arguments.
*
* @since 4.2.0
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct(string $name, array $arguments = [])
{
@ -60,7 +58,7 @@ class GetIconEvent extends AbstractImmutableEvent implements ResultAwareInterfac
public function setContext(string $value)
{
if (empty($value)) {
throw new DomainException(sprintf("Argument 'context' of event %s must be a non-empty string.", $this->name));
throw new \DomainException(sprintf("Argument 'context' of event %s must be a non-empty string.", $this->name));
}
}
}

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event;
use DomainException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -79,12 +77,12 @@ trait ReshapeArgumentsAware
// Am I missing any mandatory arguments?
if ($missingKeys) {
throw new DomainException(sprintf('Missing arguments for %s event: %s', $this->getName(), implode(', ', $missingKeys)));
throw new \DomainException(sprintf('Missing arguments for %s event: %s', $this->getName(), implode(', ', $missingKeys)));
}
// Do I have unknown arguments?
if ($extraKeys) {
throw new DomainException(sprintf('Unknown arguments for %s event: %s', $this->getName(), implode(', ', $missingKeys)));
throw new \DomainException(sprintf('Unknown arguments for %s event: %s', $this->getName(), implode(', ', $missingKeys)));
}
// Reconstruct the arguments in the order specified in $argumentTypes

View File

@ -90,7 +90,7 @@ trait ResultAware
protected function setResult(array $value)
{
if ($this->preventSetArgumentResult) {
throw new BadMethodCallException('You are not allowed to set the result argument directly. Use addResult() instead.');
throw new \BadMethodCallException('You are not allowed to set the result argument directly. Use addResult() instead.');
}
// Always assume that the last element of the array is the result the handler is trying to append.

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -46,7 +44,7 @@ interface ResultAwareInterface
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -50,7 +48,7 @@ trait ResultTypeArrayAware
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0
@ -66,7 +64,7 @@ trait ResultTypeArrayAware
}
if (!is_array($data)) {
throw new InvalidArgumentException(sprintf('Event %s only accepts Array results.', $this->getName()));
throw new \InvalidArgumentException(sprintf('Event %s only accepts Array results.', $this->getName()));
}
}
}

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -39,7 +37,7 @@ trait ResultTypeBooleanAware
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0
@ -51,7 +49,7 @@ trait ResultTypeBooleanAware
}
if (!is_bool($data)) {
throw new InvalidArgumentException(sprintf('Event %s only accepts Boolean results.', $this->getName()));
throw new \InvalidArgumentException(sprintf('Event %s only accepts Boolean results.', $this->getName()));
}
}
}

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -50,7 +48,7 @@ trait ResultTypeFloatAware
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0
@ -66,7 +64,7 @@ trait ResultTypeFloatAware
}
if (!is_float($data)) {
throw new InvalidArgumentException(sprintf('Event %s only accepts Float results.', $this->getName()));
throw new \InvalidArgumentException(sprintf('Event %s only accepts Float results.', $this->getName()));
}
}
}

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -50,7 +48,7 @@ trait ResultTypeIntegerAware
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0
@ -66,7 +64,7 @@ trait ResultTypeIntegerAware
}
if (!is_int($data)) {
throw new InvalidArgumentException(sprintf('Event %s only accepts Integer results.', $this->getName()));
throw new \InvalidArgumentException(sprintf('Event %s only accepts Integer results.', $this->getName()));
}
}
}

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -32,7 +30,7 @@ trait ResultTypeMixedAware
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -50,7 +48,7 @@ trait ResultTypeNumericAware
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0
@ -66,7 +64,7 @@ trait ResultTypeNumericAware
}
if (!is_numeric($data)) {
throw new InvalidArgumentException(sprintf('Event %s only accepts Numeric results.', $this->getName()));
throw new \InvalidArgumentException(sprintf('Event %s only accepts Numeric results.', $this->getName()));
}
}
}

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -60,7 +58,7 @@ trait ResultTypeObjectAware
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0
@ -76,7 +74,7 @@ trait ResultTypeObjectAware
}
if (!is_object($data)) {
throw new InvalidArgumentException(sprintf('Event %s only accepts object results.', $this->getName()));
throw new \InvalidArgumentException(sprintf('Event %s only accepts object results.', $this->getName()));
}
if (empty($this->resultAcceptableClasses)) {
@ -91,6 +89,6 @@ trait ResultTypeObjectAware
$acceptableTypes = implode(', ', $this->resultAcceptableClasses);
$messageTemplate = 'Event %s only accepts object results which are instances of one of %s.';
throw new InvalidArgumentException(sprintf($messageTemplate, $this->getName(), $acceptableTypes));
throw new \InvalidArgumentException(sprintf($messageTemplate, $this->getName(), $acceptableTypes));
}
}

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Result;
use InvalidArgumentException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -50,7 +48,7 @@ trait ResultTypeStringAware
* @param mixed $data The data to type check
*
* @return void
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*
* @internal
* @since 4.2.0
@ -66,7 +64,7 @@ trait ResultTypeStringAware
}
if (!is_string($data)) {
throw new InvalidArgumentException(sprintf('Event %s only accepts String results.', $this->getName()));
throw new \InvalidArgumentException(sprintf('Event %s only accepts String results.', $this->getName()));
}
}
}

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Table\TableInterface;
@ -28,14 +27,14 @@ abstract class AbstractEvent extends AbstractImmutableEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 1.0
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('subject', $arguments)) {
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
throw new \BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
}
parent::__construct($name, $arguments);
@ -48,12 +47,12 @@ abstract class AbstractEvent extends AbstractImmutableEvent
*
* @return TableInterface
*
* @throws BadMethodCallException If the argument is not of the expected type.
* @throws \BadMethodCallException If the argument is not of the expected type.
*/
protected function setSubject($value)
{
if (!\is_object($value) || !($value instanceof TableInterface)) {
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is not of the expected type");
throw new \BadMethodCallException("Argument 'subject' of event {$this->name} is not of the expected type");
}
return $value;

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -32,12 +30,12 @@ class AfterDeleteEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('pk', $arguments)) {
throw new BadMethodCallException("Argument 'pk' is required for event $name");
throw new \BadMethodCallException("Argument 'pk' is required for event $name");
}
parent::__construct($name, $arguments);

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -33,16 +31,16 @@ class AfterLoadEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('result', $arguments)) {
throw new BadMethodCallException("Argument 'result' is required for event $name");
throw new \BadMethodCallException("Argument 'result' is required for event $name");
}
if (!\array_key_exists('row', $arguments)) {
throw new BadMethodCallException("Argument 'row' is required for event $name");
throw new \BadMethodCallException("Argument 'row' is required for event $name");
}
parent::__construct($name, $arguments);
@ -55,7 +53,7 @@ class AfterLoadEvent extends AbstractEvent
*
* @return boolean
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setResult($value)
{
@ -69,12 +67,12 @@ class AfterLoadEvent extends AbstractEvent
*
* @return array|null
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setRow($value)
{
if (!\is_null($value) && !\is_array($value)) {
throw new BadMethodCallException("Argument 'row' of event {$this->name} is not of the expected type");
throw new \BadMethodCallException("Argument 'row' of event {$this->name} is not of the expected type");
}
return $value;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
use stdClass;
// phpcs:disable PSR1.Files.SideEffects
@ -35,20 +34,20 @@ class AfterMoveEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('row', $arguments)) {
throw new BadMethodCallException("Argument 'row' is required for event $name");
throw new \BadMethodCallException("Argument 'row' is required for event $name");
}
if (!\array_key_exists('delta', $arguments)) {
throw new BadMethodCallException("Argument 'delta' is required for event $name");
throw new \BadMethodCallException("Argument 'delta' is required for event $name");
}
if (!\array_key_exists('where', $arguments)) {
throw new BadMethodCallException("Argument 'ignore' is required for event $name");
throw new \BadMethodCallException("Argument 'ignore' is required for event $name");
}
parent::__construct($name, $arguments);
@ -57,16 +56,16 @@ class AfterMoveEvent extends AbstractEvent
/**
* Setter for the rows argument
*
* @param stdClass|null $value The value to set
* @param \stdClass|null $value The value to set
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setRow($value)
{
if (!($value instanceof stdClass) && !empty($value)) {
throw new BadMethodCallException("Argument 'row' of event {$this->name} must be an stdClass object or null");
if (!($value instanceof \stdClass) && !empty($value)) {
throw new \BadMethodCallException("Argument 'row' of event {$this->name} must be an stdClass object or null");
}
return $value;
@ -79,12 +78,12 @@ class AfterMoveEvent extends AbstractEvent
*
* @return integer
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setDelta($value)
{
if (!is_numeric($value)) {
throw new BadMethodCallException("Argument 'delta' of event {$this->name} must be an integer");
throw new \BadMethodCallException("Argument 'delta' of event {$this->name} must be an integer");
}
return (int) $value;
@ -97,12 +96,12 @@ class AfterMoveEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setWhere($value)
{
if (!empty($value) && !\is_string($value)) {
throw new BadMethodCallException("Argument 'where' of event {$this->name} must be empty or string");
throw new \BadMethodCallException("Argument 'where' of event {$this->name} must be empty or string");
}
return $value;

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -33,12 +31,12 @@ class AfterReorderEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('where', $arguments)) {
throw new BadMethodCallException("Argument 'ignore' is required for event $name");
throw new \BadMethodCallException("Argument 'ignore' is required for event $name");
}
parent::__construct($name, $arguments);
@ -51,12 +49,12 @@ class AfterReorderEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setWhere($value)
{
if (!empty($value) && !\is_string($value) && !\is_array($value)) {
throw new BadMethodCallException("Argument 'where' of event {$this->name} must be empty or string or array of strings");
throw new \BadMethodCallException("Argument 'where' of event {$this->name} must be empty or string or array of strings");
}
return $value;

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -32,12 +30,12 @@ class AfterStoreEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('result', $arguments)) {
throw new BadMethodCallException("Argument 'result' is required for event $name");
throw new \BadMethodCallException("Argument 'result' is required for event $name");
}
parent::__construct($name, $arguments);
@ -50,7 +48,7 @@ class AfterStoreEvent extends AbstractEvent
*
* @return boolean
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setResult($value)
{

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -33,16 +31,16 @@ class BeforeBindEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('src', $arguments)) {
throw new BadMethodCallException("Argument 'src' is required for event $name");
throw new \BadMethodCallException("Argument 'src' is required for event $name");
}
if (!\array_key_exists('ignore', $arguments)) {
throw new BadMethodCallException("Argument 'ignore' is required for event $name");
throw new \BadMethodCallException("Argument 'ignore' is required for event $name");
}
parent::__construct($name, $arguments);
@ -55,12 +53,12 @@ class BeforeBindEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setSrc($value)
{
if (!empty($value) && !\is_object($value) && !\is_array($value)) {
throw new BadMethodCallException("Argument 'src' of event {$this->name} must be empty, object or array");
throw new \BadMethodCallException("Argument 'src' of event {$this->name} must be empty, object or array");
}
return $value;
@ -73,12 +71,12 @@ class BeforeBindEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setIgnore($value)
{
if (!empty($value) && !\is_array($value)) {
throw new BadMethodCallException("Argument 'ignore' of event {$this->name} must be empty or array");
throw new \BadMethodCallException("Argument 'ignore' of event {$this->name} must be empty or array");
}
return $value;

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -32,12 +30,12 @@ class BeforeCheckinEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('pk', $arguments)) {
throw new BadMethodCallException("Argument 'pk' is required for event $name");
throw new \BadMethodCallException("Argument 'pk' is required for event $name");
}
parent::__construct($name, $arguments);

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -33,16 +31,16 @@ class BeforeCheckoutEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('userId', $arguments)) {
throw new BadMethodCallException("Argument 'userId' is required for event $name");
throw new \BadMethodCallException("Argument 'userId' is required for event $name");
}
if (!\array_key_exists('pk', $arguments)) {
throw new BadMethodCallException("Argument 'pk' is required for event $name");
throw new \BadMethodCallException("Argument 'pk' is required for event $name");
}
parent::__construct($name, $arguments);
@ -55,12 +53,12 @@ class BeforeCheckoutEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setUserId($value)
{
if (!is_numeric($value) || empty($value)) {
throw new BadMethodCallException("Argument 'userId' of event {$this->name} must be an integer");
throw new \BadMethodCallException("Argument 'userId' of event {$this->name} must be an integer");
}
return (int) $value;

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -32,12 +30,12 @@ class BeforeDeleteEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('pk', $arguments)) {
throw new BadMethodCallException("Argument 'pk' is required for event $name");
throw new \BadMethodCallException("Argument 'pk' is required for event $name");
}
parent::__construct($name, $arguments);

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -33,16 +31,16 @@ class BeforeLoadEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('keys', $arguments)) {
throw new BadMethodCallException("Argument 'keys' is required for event $name");
throw new \BadMethodCallException("Argument 'keys' is required for event $name");
}
if (!\array_key_exists('reset', $arguments)) {
throw new BadMethodCallException("Argument 'reset' is required for event $name");
throw new \BadMethodCallException("Argument 'reset' is required for event $name");
}
parent::__construct($name, $arguments);

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
use Joomla\Database\DatabaseQuery;
// phpcs:disable PSR1.Files.SideEffects
@ -35,20 +34,20 @@ class BeforeMoveEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('query', $arguments)) {
throw new BadMethodCallException("Argument 'query' is required for event $name");
throw new \BadMethodCallException("Argument 'query' is required for event $name");
}
if (!\array_key_exists('delta', $arguments)) {
throw new BadMethodCallException("Argument 'delta' is required for event $name");
throw new \BadMethodCallException("Argument 'delta' is required for event $name");
}
if (!\array_key_exists('where', $arguments)) {
throw new BadMethodCallException("Argument 'where' is required for event $name");
throw new \BadMethodCallException("Argument 'where' is required for event $name");
}
parent::__construct($name, $arguments);
@ -61,12 +60,12 @@ class BeforeMoveEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setQuery($value)
{
if (!($value instanceof DatabaseQuery)) {
throw new BadMethodCallException("Argument 'query' of event {$this->name} must be of DatabaseQuery type");
throw new \BadMethodCallException("Argument 'query' of event {$this->name} must be of DatabaseQuery type");
}
return $value;
@ -79,12 +78,12 @@ class BeforeMoveEvent extends AbstractEvent
*
* @return integer
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setDelta($value)
{
if (!is_numeric($value)) {
throw new BadMethodCallException("Argument 'delta' of event {$this->name} must be an integer");
throw new \BadMethodCallException("Argument 'delta' of event {$this->name} must be an integer");
}
return (int) $value;
@ -97,12 +96,12 @@ class BeforeMoveEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setWhere($value)
{
if (!empty($value) && !\is_string($value)) {
throw new BadMethodCallException("Argument 'where' of event {$this->name} must be empty or string");
throw new \BadMethodCallException("Argument 'where' of event {$this->name} must be empty or string");
}
return $value;

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -34,20 +32,20 @@ class BeforePublishEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('pks', $arguments)) {
throw new BadMethodCallException("Argument 'pks' is required for event $name");
throw new \BadMethodCallException("Argument 'pks' is required for event $name");
}
if (!\array_key_exists('state', $arguments)) {
throw new BadMethodCallException("Argument 'state' is required for event $name");
throw new \BadMethodCallException("Argument 'state' is required for event $name");
}
if (!\array_key_exists('userId', $arguments)) {
throw new BadMethodCallException("Argument 'userId' is required for event $name");
throw new \BadMethodCallException("Argument 'userId' is required for event $name");
}
parent::__construct($name, $arguments);
@ -60,12 +58,12 @@ class BeforePublishEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setQuery($value)
{
if (!empty($value) && !\is_array($value)) {
throw new BadMethodCallException("Argument 'pks' of event {$this->name} must be empty or an array");
throw new \BadMethodCallException("Argument 'pks' of event {$this->name} must be empty or an array");
}
return $value;
@ -78,12 +76,12 @@ class BeforePublishEvent extends AbstractEvent
*
* @return integer
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setState($value)
{
if (!is_numeric($value)) {
throw new BadMethodCallException("Argument 'state' of event {$this->name} must be an integer");
throw new \BadMethodCallException("Argument 'state' of event {$this->name} must be an integer");
}
return (int) $value;
@ -96,12 +94,12 @@ class BeforePublishEvent extends AbstractEvent
*
* @return integer
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setUserId($value)
{
if (!is_numeric($value)) {
throw new BadMethodCallException("Argument 'userId' of event {$this->name} must be an integer");
throw new \BadMethodCallException("Argument 'userId' of event {$this->name} must be an integer");
}
return (int) $value;

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
use Joomla\Database\DatabaseQuery;
// phpcs:disable PSR1.Files.SideEffects
@ -34,16 +33,16 @@ class BeforeReorderEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('query', $arguments)) {
throw new BadMethodCallException("Argument 'query' is required for event $name");
throw new \BadMethodCallException("Argument 'query' is required for event $name");
}
if (!\array_key_exists('where', $arguments)) {
throw new BadMethodCallException("Argument 'where' is required for event $name");
throw new \BadMethodCallException("Argument 'where' is required for event $name");
}
parent::__construct($name, $arguments);
@ -56,12 +55,12 @@ class BeforeReorderEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setQuery($value)
{
if (!($value instanceof DatabaseQuery)) {
throw new BadMethodCallException("Argument 'query' of event {$this->name} must be of DatabaseQuery type");
throw new \BadMethodCallException("Argument 'query' of event {$this->name} must be of DatabaseQuery type");
}
return $value;
@ -74,12 +73,12 @@ class BeforeReorderEvent extends AbstractEvent
*
* @return mixed
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*/
protected function setWhere($value)
{
if (!empty($value) && !\is_string($value) && !\is_array($value)) {
throw new BadMethodCallException("Argument 'where' of event {$this->name} must be empty or string or array of strings");
throw new \BadMethodCallException("Argument 'where' of event {$this->name} must be empty or string or array of strings");
}
return $value;

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -33,16 +31,16 @@ class BeforeStoreEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('updateNulls', $arguments)) {
throw new BadMethodCallException("Argument 'updateNulls' is required for event $name");
throw new \BadMethodCallException("Argument 'updateNulls' is required for event $name");
}
if (!\array_key_exists('k', $arguments)) {
throw new BadMethodCallException("Argument 'k' is required for event $name");
throw new \BadMethodCallException("Argument 'k' is required for event $name");
}
parent::__construct($name, $arguments);

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Table;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -34,16 +32,16 @@ class SetNewTagsEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('newTags', $arguments)) {
throw new BadMethodCallException("Argument 'newTags' is required for event $name");
throw new \BadMethodCallException("Argument 'newTags' is required for event $name");
}
if (!\array_key_exists('replaceTags', $arguments)) {
throw new BadMethodCallException("Argument 'replaceTags' is required for event $name");
throw new \BadMethodCallException("Argument 'replaceTags' is required for event $name");
}
parent::__construct($name, $arguments);

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\View;
use BadMethodCallException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\MVC\View\ViewInterface;
@ -30,30 +29,30 @@ class DisplayEvent extends AbstractImmutableEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 4.0.0
*/
public function __construct($name, array $arguments = [])
{
if (!isset($arguments['subject'])) {
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
throw new \BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
}
if (!($arguments['subject'] instanceof ViewInterface)) {
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is not of type 'ViewInterface'");
throw new \BadMethodCallException("Argument 'subject' of event {$this->name} is not of type 'ViewInterface'");
}
if (!isset($arguments['extension'])) {
throw new BadMethodCallException("Argument 'extension' of event {$this->name} is required but has not been provided");
throw new \BadMethodCallException("Argument 'extension' of event {$this->name} is required but has not been provided");
}
if (!isset($arguments['extension']) || !is_string($arguments['extension'])) {
throw new BadMethodCallException("Argument 'extension' of event {$this->name} is not of type 'string'");
throw new \BadMethodCallException("Argument 'extension' of event {$this->name} is not of type 'string'");
}
if (strpos($arguments['extension'], '.') === false) {
throw new BadMethodCallException("Argument 'extension' of event {$this->name} has wrong format. Valid format: 'component.section'");
throw new \BadMethodCallException("Argument 'extension' of event {$this->name} has wrong format. Valid format: 'component.section'");
}
if (!\array_key_exists('extensionName', $arguments) || !\array_key_exists('section', $arguments)) {

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\WebAsset;
use BadMethodCallException;
use Joomla\CMS\Event\AbstractImmutableEvent;
// phpcs:disable PSR1.Files.SideEffects
@ -29,14 +28,14 @@ abstract class AbstractEvent extends AbstractImmutableEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 4.0.0
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('subject', $arguments)) {
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
throw new \BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
}
parent::__construct($name, $arguments);

View File

@ -9,7 +9,6 @@
namespace Joomla\CMS\Event\WebAsset;
use BadMethodCallException;
use Joomla\CMS\WebAsset\WebAssetItemInterface;
use Joomla\CMS\WebAsset\WebAssetRegistryInterface;
@ -30,7 +29,7 @@ class WebAssetRegistryAssetChanged extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 4.0.0
*/
@ -40,15 +39,15 @@ class WebAssetRegistryAssetChanged extends AbstractEvent
// Check for required arguments
if (!\array_key_exists('asset', $arguments) || !($arguments['asset'] instanceof WebAssetItemInterface)) {
throw new BadMethodCallException("Argument 'asset' of event $name is not of the expected type");
throw new \BadMethodCallException("Argument 'asset' of event $name is not of the expected type");
}
if (!\array_key_exists('assetType', $arguments) || !is_string($arguments['assetType'])) {
throw new BadMethodCallException("Argument 'assetType' of event $name is not of the expected type");
throw new \BadMethodCallException("Argument 'assetType' of event $name is not of the expected type");
}
if (!\array_key_exists('change', $arguments) || !is_string($arguments['change'])) {
throw new BadMethodCallException("Argument 'change' of event $name is not of the expected type");
throw new \BadMethodCallException("Argument 'change' of event $name is not of the expected type");
}
}
@ -59,14 +58,14 @@ class WebAssetRegistryAssetChanged extends AbstractEvent
*
* @return WebAssetRegistryInterface
*
* @throws BadMethodCallException if the argument is not of the expected type
* @throws \BadMethodCallException if the argument is not of the expected type
*
* @since 4.0.0
*/
protected function setSubject($value)
{
if (!$value || !($value instanceof WebAssetRegistryInterface)) {
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is not of the expected type");
throw new \BadMethodCallException("Argument 'subject' of event {$this->name} is not of the expected type");
}
return $value;

View File

@ -9,11 +9,8 @@
namespace Joomla\CMS\Event\Workflow;
use BadMethodCallException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use function explode;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -31,26 +28,26 @@ abstract class AbstractEvent extends AbstractImmutableEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 4.0.0
*/
public function __construct($name, array $arguments = [])
{
if (!\array_key_exists('subject', $arguments)) {
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
throw new \BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
}
if (!\array_key_exists('extension', $arguments)) {
throw new BadMethodCallException("Argument 'extension' of event {$this->name} is required but has not been provided");
throw new \BadMethodCallException("Argument 'extension' of event {$this->name} is required but has not been provided");
}
if (strpos($arguments['extension'], '.') === false) {
throw new BadMethodCallException("Argument 'extension' of event {$this->name} has wrong format. Valid format: 'component.section'");
throw new \BadMethodCallException("Argument 'extension' of event {$this->name} has wrong format. Valid format: 'component.section'");
}
if (!\array_key_exists('extensionName', $arguments) || !\array_key_exists('section', $arguments)) {
$parts = explode('.', $arguments['extension']);
$parts = \explode('.', $arguments['extension']);
$arguments['extensionName'] = $arguments['extensionName'] ?? $parts[0];
$arguments['section'] = $arguments['section'] ?? $parts[1];

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Workflow;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -28,7 +26,7 @@ class WorkflowFunctionalityUsedEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 4.0.0
*/

View File

@ -9,8 +9,6 @@
namespace Joomla\CMS\Event\Workflow;
use BadMethodCallException;
// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
@ -28,7 +26,7 @@ class WorkflowTransitionEvent extends AbstractEvent
* @param string $name The event name.
* @param array $arguments The event arguments.
*
* @throws BadMethodCallException
* @throws \BadMethodCallException
*
* @since 4.0.0
*/

Some files were not shown because too many files have changed in this diff Show More