Commit 34f3bbd9 authored by Seamus Lee's avatar Seamus Lee

(NFC) Upgrade Civi Folder to the new coder version

parent b9e9e8dd
......@@ -32,6 +32,7 @@ namespace Civi\API\Event;
* @package Civi\API\Event
*/
class PrepareEvent extends Event {
/**
* @param array $apiRequest
* The full description of the API request.
......
......@@ -32,6 +32,7 @@ namespace Civi\API\Event;
* @package Civi\API\Event
*/
class ResolveEvent extends Event {
/**
* @param array $apiRequest
* The full description of the API request.
......
......@@ -8,6 +8,7 @@ require_once 'api/Exception.php';
* @package Civi\API\Exception
*/
class NotImplementedException extends \API_Exception {
/**
* @param string $message
* The human friendly error message.
......
......@@ -8,6 +8,7 @@ require_once 'api/Exception.php';
* @package Civi\API\Exception
*/
class UnauthorizedException extends \API_Exception {
/**
* @param string $message
* The human friendly error message.
......
......@@ -119,7 +119,7 @@ class ExternalBatch {
while (!empty($this->processes)) {
usleep(self::POLL_INTERVAL);
foreach (array_keys($this->processes) as $idx) {
/** @var Process $process */
/** @var \Symfony\Component\Process\Process $process */
$process = $this->processes[$idx];
if (!$process->isRunning()) {
$parsed = json_decode($process->getOutput(), TRUE);
......@@ -179,7 +179,7 @@ class ExternalBatch {
/**
* @param array $apiCall
* Array with keys: entity, action, params.
* @return Process
* @return \Symfony\Component\Process\Process
* @throws \CRM_Core_Exception
*/
public function createProcess($apiCall) {
......
......@@ -31,7 +31,6 @@ use Civi\API\Event\PrepareEvent;
use Civi\API\Event\ExceptionEvent;
use Civi\API\Event\ResolveEvent;
use Civi\API\Event\RespondEvent;
use Civi\API\Provider\ProviderInterface;
/**
* @package Civi
......@@ -217,7 +216,7 @@ class Kernel {
* Array(0 => ProviderInterface, 1 => array $apiRequest).
*/
public function resolve($apiRequest) {
/** @var ResolveEvent $resolveEvent */
/** @var \Civi\API\Event\ResolveEvent $resolveEvent */
$resolveEvent = $this->dispatcher->dispatch(Events::RESOLVE, new ResolveEvent($apiRequest, $this));
$apiRequest = $resolveEvent->getApiRequest();
if (!$resolveEvent->getApiProvider()) {
......@@ -229,14 +228,14 @@ class Kernel {
/**
* Determine if the API request is allowed (under current policy)
*
* @param ProviderInterface $apiProvider
* @param \Civi\API\Provider\ProviderInterface $apiProvider
* The API provider responsible for executing the request.
* @param array $apiRequest
* The full description of the API request.
* @throws Exception\UnauthorizedException
*/
public function authorize($apiProvider, $apiRequest) {
/** @var AuthorizeEvent $event */
/** @var \Civi\API\Event\AuthorizeEvent $event */
$event = $this->dispatcher->dispatch(Events::AUTHORIZE, new AuthorizeEvent($apiProvider, $apiRequest, $this));
if (!$event->isAuthorized()) {
throw new \Civi\API\Exception\UnauthorizedException("Authorization failed");
......@@ -246,7 +245,7 @@ class Kernel {
/**
* Allow third-party code to manipulate the API request before execution.
*
* @param ProviderInterface $apiProvider
* @param \Civi\API\Provider\ProviderInterface $apiProvider
* The API provider responsible for executing the request.
* @param array $apiRequest
* The full description of the API request.
......@@ -254,7 +253,7 @@ class Kernel {
* The revised API request.
*/
public function prepare($apiProvider, $apiRequest) {
/** @var PrepareEvent $event */
/** @var \Civi\API\Event\PrepareEvent $event */
$event = $this->dispatcher->dispatch(Events::PREPARE, new PrepareEvent($apiProvider, $apiRequest, $this));
return $event->getApiRequest();
}
......@@ -262,7 +261,7 @@ class Kernel {
/**
* Allow third-party code to manipulate the API response after execution.
*
* @param ProviderInterface $apiProvider
* @param \Civi\API\Provider\ProviderInterface $apiProvider
* The API provider responsible for executing the request.
* @param array $apiRequest
* The full description of the API request.
......@@ -272,7 +271,7 @@ class Kernel {
* The revised $result.
*/
public function respond($apiProvider, $apiRequest, $result) {
/** @var RespondEvent $event */
/** @var \Civi\API\Event\RespondEvent $event */
$event = $this->dispatcher->dispatch(Events::RESPOND, new RespondEvent($apiProvider, $apiRequest, $result, $this));
return $event->getResponse();
}
......@@ -287,7 +286,7 @@ class Kernel {
// Question: Would it better to eliminate $this->apiProviders and just use $this->dispatcher?
$entityNames = [];
foreach ($this->getApiProviders() as $provider) {
/** @var ProviderInterface $provider */
/** @var \Civi\API\Provider\ProviderInterface $provider */
$entityNames = array_merge($entityNames, $provider->getEntityNames($version));
}
$entityNames = array_unique($entityNames);
......@@ -307,7 +306,7 @@ class Kernel {
// Question: Would it better to eliminate $this->apiProviders and just use $this->dispatcher?
$actionNames = [];
foreach ($this->getApiProviders() as $provider) {
/** @var ProviderInterface $provider */
/** @var \Civi\API\Provider\ProviderInterface $provider */
$actionNames = array_merge($actionNames, $provider->getActionNames($version, $entity));
}
$actionNames = array_unique($actionNames);
......@@ -345,7 +344,8 @@ class Kernel {
$data['action'] = \CRM_Utils_Array::value('action', $apiRequest);
if (\CRM_Utils_Array::value('debug', \CRM_Utils_Array::value('params', $apiRequest))
&& empty($data['trace']) // prevent recursion
// prevent recursion
&& empty($data['trace'])
) {
$data['trace'] = $e->getTraceAsString();
}
......@@ -459,7 +459,7 @@ class Kernel {
}
/**
* @param ProviderInterface $apiProvider
* @param \Civi\API\Provider\ProviderInterface $apiProvider
* The API provider responsible for executing the request.
* @return Kernel
*/
......
......@@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* conventions.
*/
class MagicFunctionProvider implements EventSubscriberInterface, ProviderInterface {
/**
* @return array
*/
......@@ -285,7 +286,8 @@ class MagicFunctionProvider implements EventSubscriberInterface, ProviderInterfa
}
// Check for standalone action files; to match _civicrm_api_resolve(), only load the first one
$loaded_files = []; // array($relativeFilePath => TRUE)
// array($relativeFilePath => TRUE)
$loaded_files = [];
$include_dirs = array_unique(explode(PATH_SEPARATOR, get_include_path()));
foreach ($include_dirs as $include_dir) {
foreach ([$camelName, 'Generic'] as $name) {
......@@ -299,7 +301,8 @@ class MagicFunctionProvider implements EventSubscriberInterface, ProviderInterfa
foreach ($iterator as $fileinfo) {
$file = $fileinfo->getFilename();
if (array_key_exists($file, $loaded_files)) {
continue; // action provided by an earlier item on include_path
// action provided by an earlier item on include_path
continue;
}
$parts = explode(".", $file);
......
......@@ -27,13 +27,11 @@
namespace Civi\API\Provider;
use Civi\API\Events;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* An API "provider" provides a means to execute API requests.
*/
interface ProviderInterface {
/**
* @param array $apiRequest
* The full description of the API request.
......
......@@ -34,6 +34,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* This class defines operations for inspecting the API's metadata.
*/
class ReflectionProvider implements EventSubscriberInterface, ProviderInterface {
/**
* @return array
*/
......@@ -68,7 +69,8 @@ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface
$this->apiKernel = $apiKernel;
$this->actions = [
'Entity' => ['get', 'getactions'],
'*' => ['getactions'], // 'getfields'
// 'getfields'
'*' => ['getactions'],
];
}
......
......@@ -102,7 +102,7 @@ class StaticProvider extends AdhocProvider {
* @param array $apiRequest
* The full description of the API request.
* @return array
* Formatted API result
* Formatted API result
* @throws \API_Exception
*/
public function doCreate($apiRequest) {
......@@ -131,7 +131,7 @@ class StaticProvider extends AdhocProvider {
* @param array $apiRequest
* The full description of the API request.
* @return array
* Formatted API result
* Formatted API result
* @throws \API_Exception
*/
public function doGet($apiRequest) {
......@@ -142,7 +142,7 @@ class StaticProvider extends AdhocProvider {
* @param array $apiRequest
* The full description of the API request.
* @return array
* Formatted API result
* Formatted API result
* @throws \API_Exception
*/
public function doDelete($apiRequest) {
......
......@@ -25,6 +25,7 @@
+--------------------------------------------------------------------+
*/
namespace Civi\API;
use Civi\API\Exception\UnauthorizedException;
/**
......
......@@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* and validates that the fields are provided correctly.
*/
class APIv3SchemaAdapter implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -50,6 +50,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* eg Amy's contact_id).
*/
class ChainSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -227,7 +227,8 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
$exception = NULL;
$self = $this;
\CRM_Core_Transaction::create(TRUE)->run(function($tx) use ($entity, $action, $entityId, &$exception, $self) {
$tx->rollback(); // Just to be safe.
// Just to be safe.
$tx->rollback();
$params = [
'version' => 3,
......
......@@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* @package Civi\API\Subscriber
*/
class I18nSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -36,6 +36,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* Civi\API\Annotation\Permission.
*/
class PermissionCheck implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -44,6 +44,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* @package Civi\API\Subscriber
*/
class TransactionSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -29,7 +29,6 @@ namespace Civi\API\Subscriber;
use Civi\API\Events;
use Civi\API\Event\AuthorizeEvent;
use Civi\API\Event\RespondEvent;
use Civi\API\WhitelistRule;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
......@@ -75,7 +74,7 @@ class WhitelistSubscriber implements EventSubscriberInterface {
public function __construct($rules) {
$this->rules = [];
foreach ($rules as $rule) {
/** @var WhitelistRule $rule */
/** @var \Civi\API\WhitelistRule $rule */
if ($rule->isValid()) {
$this->rules[] = $rule;
}
......@@ -89,7 +88,7 @@ class WhitelistSubscriber implements EventSubscriberInterface {
* Determine which, if any, whitelist rules apply this request.
* Reject unauthorized requests.
*
* @param AuthorizeEvent $event
* @param \Civi\API\Event\AuthorizeEvent $event
* @throws \CRM_Core_Exception
*/
public function onApiAuthorize(AuthorizeEvent $event) {
......@@ -108,7 +107,7 @@ class WhitelistSubscriber implements EventSubscriberInterface {
/**
* Apply any filtering rules based on the chosen whitelist rule.
* @param RespondEvent $event
* @param \Civi\API\Event\RespondEvent $event
*/
public function onApiRespond(RespondEvent $event) {
$apiRequest = $event->getApiRequest();
......
......@@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* @package Civi\API\Subscriber
*/
class XDebugSubscriber implements EventSubscriberInterface {
/**
* @return array
*/
......
......@@ -48,7 +48,7 @@ namespace Civi\API;
*/
class WhitelistRule {
static $IGNORE_FIELDS = [
public static $IGNORE_FIELDS = [
'check_permissions',
'debug',
'offset',
......
<?php
namespace Civi\ActionSchedule\Event;
use Civi\ActionSchedule\MappingInterface;
use Symfony\Component\EventDispatcher\Event;
/**
......@@ -51,7 +50,7 @@ class MailingQueryEvent extends Event {
/**
* The mapping record which produced this mailing.
*
* @var MappingInterface
* @var \Civi\ActionSchedule\MappingInterface
*/
public $mapping;
......@@ -64,7 +63,7 @@ class MailingQueryEvent extends Event {
/**
* @param \CRM_Core_DAO_ActionSchedule $actionSchedule
* @param MappingInterface $mapping
* @param \Civi\ActionSchedule\MappingInterface $mapping
* @param \CRM_Utils_SQL_Select $query
*/
public function __construct($actionSchedule, $mapping, $query) {
......
......@@ -21,7 +21,7 @@ class MappingRegisterEvent extends Event {
/**
* Register a new mapping.
*
* @param MappingInterface $mapping
* @param \Civi\ActionSchedule\MappingInterface $mapping
* The new mapping.
* @return MappingRegisterEvent
*/
......
......@@ -112,7 +112,7 @@ abstract class Mapping implements MappingInterface {
/**
* The basic entity to query (label).
*
* @var
* @var string
* Ex: 'Activity', 'Event'
*/
private $entity_label;
......@@ -339,6 +339,6 @@ abstract class Mapping implements MappingInterface {
* @param array $defaultParams
* @return \CRM_Utils_SQL_Select
*/
public abstract function createQuery($schedule, $phase, $defaultParams);
abstract public function createQuery($schedule, $phase, $defaultParams);
}
......@@ -44,6 +44,7 @@ class Manager {
/**
* @param \CRM_Core_Resources $res
* The resource manager.
* @param $cache
*/
public function __construct($res, \CRM_Utils_Cache_Interface $cache = NULL) {
$this->res = $res;
......
......@@ -32,6 +32,7 @@ namespace Civi\CCase;
* @package Civi\CCase
*/
interface CaseChangeListener {
/**
* @param \Civi\CCase\Event\CaseChangeEvent $event
*
......
......@@ -26,6 +26,7 @@
*/
namespace Civi\CCase\Event;
use Civi\Core\Event\GenericHookEvent;
/**
......
......@@ -37,7 +37,7 @@ class Events {
*
* We do not want to fire case-change events recursively.
*/
static $isActive = [];
public static $isActive = [];
/**
* Following a change to an activity or case, fire the case-change event.
......
......@@ -7,6 +7,7 @@ namespace Civi\CiUtil;
* @package Civi\CiUtil
*/
class Arrays {
/**
* @param $arr
* @param $col
......
......@@ -7,6 +7,7 @@ namespace Civi\CiUtil\Command;
* @package Civi\CiUtil\Command
*/
class AntagonistCommand {
/**
* @param $argv
*/
......
......@@ -7,6 +7,7 @@ namespace Civi\CiUtil\Command;
* @package Civi\CiUtil\Command
*/
class CompareCommand {
/**
* @param $argv
*/
......@@ -19,7 +20,8 @@ class CompareCommand {
$parser = ['\Civi\CiUtil\PHPUnitParser', 'parseJsonResults'];
$printerType = 'txt';
$suites = []; // array('file' => string, 'results' => array)
// array('file' => string, 'results' => array)
$suites = [];
for ($i = 1; $i < count($argv); $i++) {
switch ($argv[$i]) {
case '--phpunit-json':
......@@ -50,7 +52,8 @@ class CompareCommand {
}
}
$tests = []; // array(string $name)
// array(string $name)
$tests = [];
foreach ($suites as $suite) {
$tests = array_unique(array_merge(
$tests,
......
......@@ -7,6 +7,7 @@ namespace Civi\CiUtil\Command;
* @package Civi\CiUtil\Command
*/
class LsCommand {
/**
* @param $argv
*/
......
......@@ -7,8 +7,8 @@ namespace Civi\CiUtil;
* @package Civi\CiUtil
*/
class ComparisonPrinter {
var $headers;
var $hasHeader = FALSE;
public $headers;
public $hasHeader = FALSE;
/**
* @param $headers
......
......@@ -7,9 +7,9 @@ namespace Civi\CiUtil;
* @package Civi\CiUtil
*/
class CsvPrinter {
var $file;
var $headers;
var $hasHeader = FALSE;
public $file;
public $headers;
public $hasHeader = FALSE;
/**
* @param $file
......
......@@ -5,6 +5,7 @@ namespace Civi\CiUtil;
* Parse Jenkins result files
*/
class JenkinsParser {
/**
* @param string $content
* Xml data.
......
......@@ -5,6 +5,7 @@ namespace Civi\CiUtil;
* Parse phpunit result files
*/
class PHPUnitParser {
/**
* @param string $content
* Phpunit streaming JSON.
......
......@@ -7,6 +7,7 @@ use Symfony\Component\Finder\Finder;
* Search for PHPUnit test cases
*/
class PHPUnitScanner {
/**
* @param $path
* @return array <string> class names
......
......@@ -84,6 +84,9 @@ class AssetBuilder {
];
}
/**
* @var mixed
*/
protected $cacheEnabled;
/**
......@@ -238,8 +241,7 @@ class AssetBuilder {
protected function getCachePath($fileName = NULL) {
// imageUploadDir has the correct functional properties but a wonky name.
$suffix = ($fileName === NULL) ? '' : (DIRECTORY_SEPARATOR . $fileName);
return
\CRM_Utils_File::addTrailingSlash(\CRM_Core_Config::singleton()->imageUploadDir)
return \CRM_Utils_File::addTrailingSlash(\CRM_Core_Config::singleton()->imageUploadDir)
. 'dyn' . $suffix;
}
......@@ -255,8 +257,7 @@ class AssetBuilder {
protected function getCacheUrl($fileName = NULL) {
// imageUploadURL has the correct functional properties but a wonky name.
$suffix = ($fileName === NULL) ? '' : ('/' . $fileName);
return
\CRM_Utils_File::addTrailingSlash(\CRM_Core_Config::singleton()->imageUploadURL, '/')
return \CRM_Utils_File::addTrailingSlash(\CRM_Core_Config::singleton()->imageUploadURL, '/')
. 'dyn' . $suffix;
}
......
<?php
namespace Civi\Core;
use Civi\API\Provider\ActionObjectProvider;
use Civi\Core\Event\SystemInstallEvent;
use Civi\Core\Lock\LockManager;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\FileCacheReader;
use Doctrine\Common\Cache\FilesystemCache;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Tools\Setup;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
// TODO use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
......@@ -58,7 +48,7 @@ class Container {
* - CIVICRM_DOMAIN_ID
* - CIVICRM_TEMPLATE_COMPILEDIR
*
* @return ContainerInterface
* @return \Symfony\Component\DependencyInjection\ContainerInterface
*/
public function loadContainer() {
// Note: The container's raison d'etre is to manage construction of other
......@@ -95,7 +85,7 @@ class Container {
/**
* Construct a new container.
*
* @var ContainerBuilder
* @var \Symfony\Component\DependencyInjection\ContainerBuilder
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
*/
public function createContainer() {
......@@ -309,7 +299,7 @@ class Container {
}
/**
* @param ContainerInterface $container
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* @return \Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher
*/
public function createEventDispatcher($container) {
......@@ -352,7 +342,7 @@ class Container {
}
/**
* @return LockManager
* @return \Civi\Core\Lock\LockManager
*/
public static function createLockManager() {
// Ideally, downstream implementers could override any definitions in
......@@ -424,7 +414,7 @@ class Container {
}
/**
* @param ContainerInterface $container
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* @return \CRM_Core_Resources
*/
public static function createResources($container) {
......@@ -437,7 +427,7 @@ class Container {
}
/**
* @param ContainerInterface $container
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* @return \CRM_Core_PrevNextCache_Interface
*/
public static function createPrevNextCache($container) {
......
......@@ -27,7 +27,6 @@
namespace Civi\Core;
use Civi;
use Civi\Core\Event\SystemInstallEvent;
/**
......
......@@ -250,7 +250,8 @@ class ResolverApi {
}
class ResolverGlobalCallback {
private $mode, $path;
private $mode;
private $path;
/**
* Class constructor.
......
......@@ -67,10 +67,17 @@ class SettingsManager {
protected $cache;
/**
* @var
* @var array
* Array (int $id => SettingsBag $bag).
*/
protected $bagsByDomain = [], $bagsByContact = [];
protected $bagsByDomain = [];
/**
* @var array
* Array (int $id => SettingsBag $bag).
*/
protected $bagsByContact = [];
/**
* @var array|NULL
......@@ -310,7 +317,8 @@ class SettingsManager {
$this->mandatory = NULL;
$this->cache->flush();
\Civi::cache('settings')->flush(); // SettingsMetadata; not guaranteed to use same cache.
// SettingsMetadata; not guaranteed to use same cache.
\Civi::cache('settings')->flush();
foreach ($this->bagsByDomain as $bag) {
/** @var SettingsBag $bag */
......
......@@ -56,7 +56,6 @@ class StaticTriggers {
$this->triggers = $triggers;
}
/**
* Add our list of triggers to the global list.
*
......
......@@ -28,8 +28,6 @@
namespace Civi\Core\SqlTrigger;
use Civi\Core\Event\GenericHookEvent;
/**
* Build a set of SQL triggers for tracking timestamps on an entity.
*
......
......@@ -207,8 +207,8 @@ class SqlTriggers {
if (!file_exists($this->getFile())) {
// Ugh. Need to let user know somehow. This is the first change.
\CRM_Core_Session::setStatus(ts('The mysql commands you need to run are stored in %1', [
1 => $this->getFile(),
]),
1 => $this->getFile(),
]),
'',
'alert',
['expires' => 0]
......
......@@ -23,6 +23,9 @@ class Requirements {
*/
const REQUIREMENT_ERROR = 2;